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

errors are not being raised after parsing a rule #102

Open
mgood7123 opened this issue Dec 8, 2018 · 2 comments
Open

errors are not being raised after parsing a rule #102

mgood7123 opened this issue Dec 8, 2018 · 2 comments

Comments

@mgood7123
Copy link

mgood7123 commented Dec 8, 2018

when the parser successfully parses a rule then errors parsing another rule due to it not being able to match any rules it should raise an error but it doesnt

for example

passedrule
failedrule

passedrule gets passed then failedrule gets silently skipped and halts the parsing but suceeds, and the ast tree only shows the ast for passedrule

failedrule

failedrule gets raised and error is reported since no rules previously match

@orangeduck
Copy link
Owner

Can you give an example?

@ghaberek
Copy link

ghaberek commented Feb 6, 2021

I know this is a 2+ year old issue but I think I ran into the same problem. What I realized is that my top-level rule didn't have any start/end terminators, so the parser would just silently exit on any unrecognized input instead of failing with an error.

Notice the example language definition ends this way:

mpca_lang(MPCA_LANG_DEFAULT,
  " expression : <product> (('+' | '-') <product>)*; "
  " product    : <value>   (('*' | '/')   <value>)*; "
  " value      : /[0-9]+/ | '(' <expression> ')';    "
  " maths      : /^/ <expression> /$/;               ", // note start /^/ and end /$/ terminators
  Expr, Prod, Value, Maths, NULL);

But my last rule looked like this, without the terminators:

  " maths      : <expression> ;               ",

Once I put those in, the parser would properly error out on any unrecognized or invalid input.

Hope this helps!

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

3 participants