Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error recovery is missing #4

Open
mingodad opened this issue Jul 30, 2023 · 9 comments
Open

Error recovery is missing #4

mingodad opened this issue Jul 30, 2023 · 9 comments

Comments

@mingodad
Copy link

While converting some grammars I noticed that the error for error recovering is not implemented.

Example grammar using error recovery that works with bison:

%nonassoc error
%left '(' ')'
%left '+' '-'
%left '*' '/'
%nonassoc integer

%%

stmts:
	stmts stmt
	| stmt
	| %prec '('
	;

stmt:
	expr ';'
	| error ';'
	;

expr:
	expr '+' expr
	| expr '-' expr
	| expr '*' expr
	| expr '/' expr
	| expr error expr
	| '(' expr ')'
	| integer
	;

%%

//[0-9]+	integer
@BenHanson
Copy link
Owner

BenHanson commented Jul 30, 2023

Yes, I'm not intending to implement this feature.

Also if you try to use a huge grammar with parsertl generally it will likely struggle. Ideally I would use bison style table compression (making sure to dodge the GPL mind you), but getting this far was enough of a struggle I have to admit!

@mingodad
Copy link
Author

And what about byacc https://github.com/ThomasDickey/byacc-snapshots:
Bison generating postgresql-16:

/usr/bin/time bison-nb postgresql16b2-naked.y
1.36user 0.03system 0:01.37elapsed 101%CPU (0avgtext+0avgdata 17204maxresident)k
0inputs+4072outputs (0major+10888minor)pagefaults 0swaps

/usr/bin/time byacc-nb postgresql16b2-naked.y
1.59user 0.02system 0:01.61elapsed 99%CPU (0avgtext+0avgdata 42124maxresident)k
0inputs+6800outputs (0major+10631minor)pagefaults 0swaps

@mingodad
Copy link
Author

Here is the postgresql-16 naked grammar:
postgresql16b2-naked.y.zip

@mingodad
Copy link
Author

It seems that even lemon struggles with postgresl-16:

/usr/bin/time lemon-nb -s postgresql16b2-naked.lemon
Parser statistics:
  terminal symbols...................   522
  non-terminal symbols...............   706
  total symbols......................  1228
  rules..............................  3293
  states.............................  3490
  conflicts..........................     0
  action table entries............... 129153
  lookahead table entries............ 129174
  total table size (bytes)........... 546522
15.43user 0.25system 0:15.81elapsed 99%CPU (0avgtext+0avgdata 422128maxresident)k
0inputs+123656outputs (0major+105236minor)pagefaults 0swaps

postgresql16b2-naked.lemon.zip

@BenHanson
Copy link
Owner

And what about byacc https://github.com/ThomasDickey/byacc-snapshots

That actually looks really interesting.

@mingodad
Copy link
Author

I have a fork here https://github.com/mingodad/lalr-parser-test with some cosmetic changes.

@mingodad
Copy link
Author

@BenHanson
Copy link
Owner

BenHanson commented Aug 3, 2023

After seeing Charles Baker's description of supporting "error", I might have a look at this at some point.

@mingodad
Copy link
Author

mingodad commented Aug 3, 2023

That would be a nice addition !
Also instead of reporting errors one by one, probably trying to recover and going forward and showing the accumulated errors would be nice.
Another interesting error recovering and messaging is done here https://github.com/sqmedeiros/lpeglabel#relabel-syntax .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants