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

Expected operator, found EOI #943

Open
lambdaknight opened this issue Nov 1, 2023 · 3 comments
Open

Expected operator, found EOI #943

lambdaknight opened this issue Nov 1, 2023 · 3 comments
Labels

Comments

@lambdaknight
Copy link

Describe the bug
Pratt parser fails to parse a set of Pairs if EOI is included in them.

To Reproduce
Steps to reproduce the behavior:

  1. Modify the derive/examples/calc.rs example to not do the calls on lines 93-98.

Expected behavior
It should work?

Additional context
Seems like EOI should be ignored or handled in some other way than requiring you to manually handle the parse tree for one level.

@lambdaknight
Copy link
Author

Also of note is that it seems like going one level deep into the parse tree isn't enough. A call to pairs.next().unwrap().into_inner() returns the expr just below program, but it still has the EOI token in the Pairs

@tomtau
Copy link
Contributor

tomtau commented Nov 2, 2023

@segeljakt

@tenstad
Copy link

tenstad commented Mar 29, 2024

.op(Op::postfix(Rule::EOI))

and

.map_postfix(|lhs, op| match op.as_rule() {
    Rule::EOI => lhs,

seems to work 😄

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

No branches or pull requests

3 participants