Skip to content

v2.6.0

Compare
Choose a tag to compare
@ehwan ehwan released this 29 Aug 10:53
· 33 commits to main since this release

Add GLR parser generator

Adding %glr; directive will switch the parser generation to GLR parser.
With this directive, any Shift/Reduce, Reduce/Reduce conflicts will not be treated as errors.

Resolving Ambiguities

You can resolve the ambiguties through the reduce action.
Simply, returning Result::Err(Error) from the reduce action will revoke current path.


Add tree feature

[dependencies]
rusty_lr = { version = "2.6.0", features=["tree"] }

For debugging purpose, tree feature enables the automatic construction of the syntax tree.
You can call context.to_tree_list() to get the reduced syntax tree.

let parser = Parser::new();
let mut context = parser.begin();
/// feed tokens...
println!( "{:?}", context.to_tree_list() ); // print tree list with `Debug` trait
println!( "{}", context.to_tree_list() );   // print tree list with `Display` trait
TreeList
├─A
│ └─M
│   └─P
│     └─Number
│       ├─WS0
│       │ └─_space_Star1
│       │   └─_space_Plus0
│       │     ├─_space_Plus0
│       │     │ └─' '
│       │     └─' '
│       ├─_Digit_Plus3
│       │ └─Digit
│       │   └─_TerminalSet2
│       │     └─'1'
│       └─WS0
│         └─_space_Star1
│           └─_space_Plus0
│             └─' '
├─'+'
├─M
│ └─P
... continue