BenHanson / parsertl14

C++14 version of parsertl
32 stars 4 forks source link

Adding "%fallback" directive ? #13

Open mingodad opened 9 months ago

mingodad commented 9 months ago

On this commit I've added an experimental "%fallback" directive similar to the one used by the lemon parser generator https://sqlite.org/src/doc/trunk/doc/lemon.html#pfallback , for some grammars there is a huge performance gain when building the parser:

/usr/bin/time ./parsertl-playground "postgres16-fallback.g" test.sql
Parser user grammar success: 1
Warning: Token "UMINUS" does not have a lexer definiton.
Parser input success: 1
0.24user 0.02system 0:00.27elapsed 100%CPU (0avgtext+0avgdata 40696maxresident)k
0inputs+0outputs (0major+13932minor)pagefaults 0swaps

/usr/bin/time ./parsertl-playground "postgres16.g" test.sql
Parser user grammar success: 1
Warning: Token "UMINUS" does not have a lexer definiton.
Parser input success: 1
0.74user 0.03system 0:00.77elapsed 99%CPU (0avgtext+0avgdata 100900maxresident)k
0inputs+0outputs (0major+33640minor)pagefaults 0swaps