[parser] Pager's algorithm. Faster.

As good as LALR but the implementation isn't embarassing. (Still
pretty bad though.)

Honestly the next thing to do is to delete LALR and just use Pager's
and also rebuild ConfigSet et al to be ItemSet so that Pager's alg
can go even faster. I think I want to keep LR1 just for completeness
so I might as well not delete SLR and LR0, although I *could* I
suppose.
This commit is contained in:
John Doty 2024-10-05 16:00:41 -07:00
parent 5e3b1141ca
commit eef1db72da
3 changed files with 436 additions and 39 deletions

View file

@ -1,4 +1,5 @@
# This is an example grammar.
import parser
from parser import (
Assoc,
Grammar,
@ -22,6 +23,8 @@ from parser import (
class FineGrammar(Grammar):
# generator = parser.GenerateLR1
# generator = parser.GeneratePager
# generator = parser.GenerateLALR
start = "File"
trivia = ["BLANKS", "LINE_BREAK", "COMMENT"]
@ -524,7 +527,9 @@ if __name__ == "__main__":
# TODO: Actually generate a lexer/parser for some runtime.
grammar = FineGrammar()
grammar.build_table()
table = grammar.build_table()
# print(table.format())
lexer = grammar.compile_lexer()
dump_lexer_table(lexer)