This project is heavily inspired by LYRON, a universal compiler framework.
Modify config.yml
if necessary, place your test file, e.g., test.txt
, and then execute
cat test.txt | java -jar parse-tree.jar
You can also execute the jar file directly and input your test code in the console.
Take the regular expression (a|b)*abb
for example.
Take the regular expressions a*b+
, a
, abb
for example.
-
Get the predefined grammar.
1. S'->S 2. S->CβBA 3. A->Aαβ 4. A->αβ 5. B->C 6. B->Dβ 7. C->α 8. D->α
-
Write a config file (in YAML format).
nonterminalSymbols: # ? name ? A ? B ? C ? D ? S terminalSymbols: # name: regex α: a β: b ignoredSymbols: startSymbol: S productions: # - left part -> right part - S -> C β B A - A -> A α β - A -> α β - B -> C - B -> D β - C -> α - D -> α
-
Generate the parse table.
ACTION GOTO α β $ S A B C D 0 s1 3 2 1 r7 2 s4 3 acc 4 s5 6 7 8 5 r7 r8 6 s10 9 7 r5 8 s11 9 s12 r2 10 s13 11 r6 12 s14 13 r4 r4 14 r3 r3 -
Generate the parse tree.
The input string is
abababab
.