From 08c373c48fed56d99759d54588081aefa297af3c Mon Sep 17 00:00:00 2001 From: Philipp A Date: Mon, 29 Oct 2018 11:19:47 +0100 Subject: added parser module --- src/parser/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/parser/mod.rs') diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 79c66ba..07a2278 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -1 +1,35 @@ pub mod token; + +#[derive(Parser)] +#[grammar = "rst.pest"] +pub struct RstParser; + + + +#[test] +fn line() { + use pest::Parser; + let result = RstParser::parse(Rule::plain, &"line\n").expect("unsuccessful parse").next().unwrap(); + eprintln!("{}", result); +} + +#[test] +fn title() { + use pest::Parser; + let result = RstParser::parse(Rule::heading, &"\ +Title +===== +").expect("unsuccessful parse").next().unwrap(); + eprintln!("{}", result); +} + +#[test] +fn heading_title() { + use pest::Parser; + let result = RstParser::parse(Rule::heading_title, &"\ +----- +Title +----- +").expect("unsuccessful parse").next().unwrap(); + eprintln!("{}", result); +} -- cgit v1.2.3