Function rustlr::rustler[][src]

pub fn rustler(grammarname: &str, option: &str)
Expand description

this is the only function that can invoke the parser generator externally, without running rustlr (rustlr::main) directly. It expects to find a file of the form grammarname.grammar. The option argument that can currently only be “lr1” or “lalr”. It generates a grammar in a file named grammarnameparser.rs.

Example:

Given the grammar called test1.grammar,

 rustler("test1","lalr");

would generate this parser. Since this grammar is small enought (requiring less than 16 LALR states), the generated parser is readable, which is appropriate for testing. For larger grammars, the parser generator switches to a binary representation.