Function lbnf::parse

source ·
pub fn parse(input: &str) -> Result<Grammar, ParseError<usize, Token<'_>, &str>>
Expand description

Parse the given string as LBNF grammar. Returns Grammar if the provided grammar is valid.

Errors

Will return Err if the provided grammar fails to parse.

Examples

use lbnf::parse;

let grammar = r#"
   EAdd.  Exp ::= Exp "+" Exp ;
   EInt.  Exp ::= Integer     ;
"#;
assert!(parse(grammar).is_ok());