View Code? Open in Web Editor
NEW
Generating LR parser for a given grammar.
License: MIT License
create-lr-parser's Introduction
- Construct the parsing table
- Trace the parse stack of input string
- Draw the DFA
- Put each rule in a single line
- Rules must be in form
LHS => RHS
- NON-TERMINALS
- must start with (`)
- be UPPERCASE
- use only
[A-Z]
and (_
) for NONTERMINALS
- Terminals must be lower case
- If there are many rhs of a lhs
- put all in the same line
- separate them with (|)
- e.g.:
X => Y | Z | !εpslon
- Use the form (
!εpslon
) for writing epslons
- Example grammar:
- `E => `T `E_
- `E_ => + `T `E_ | !εpslon
- `T => `F `T_
- `T_ => * `F `T_ | !εpslon
- `F => ( `E ) | id
- python 3
- numpy
- Pandas
- Matplotlib
- Networkx
- pygraphviz (optional)
![result of SLR parser](https://camo.githubusercontent.com/ce557e6915434291a53274fcc030c72ad56513a3827447c8c1e7f2e4666687e0/68747470733a2f2f6c68332e676f6f676c6575736572636f6e74656e742e636f6d2f77506a4970706d6c6d734c664f4361317748506166693268776a34455050626e6a355a502d53695459416775725970537a6570333556342d71686e43653162304a414a504962534b5a666b306538357569746f75377146654766573941676a67685844694a6635795f7752637831384c48784b6f3570387a314e4a41546f6f716b51737050586d4c3d77313036362d683338392d6e6f)
create-lr-parser's People
Contributors
Watchers