An LL1 grammar checker
- Bison is an old, C-based, LR checker/parser generator
- Its syntax is simple enough and easy to teach
- It lacks creature comforts of EBNF
cargo run -- example_grammar.txt
There are only 3 kinds of statements for this program. All end in semicolons for clarity.
The start rule must be explicitly declared. Only one start rule may be declared in a file.
Example: start start_rule;
Terminals are explicitly listed in a terminal statement.
Example: terminal terminal1 terminal2;
Rules follow Bison's syntax with the added support for EBNF.
Syntax | Meaning |
---|---|
%empty |
Empty rule (mandatory) |
item1 item2 |
A sequence of 2 items |
`a | b` |
[ contents ] |
optional (0 or 1) contents |
{ contents } |
repetition (1 or more) contents |
Example: rule_name : option1 | item1 item2 | [ item3 item4 ];
Comments may start with either //
or #
and terminate at the newline, as they are not statements.