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

Compound rules may be recorded in ParsingError along with atomic rules #893

Open
MucTepDayH16 opened this issue Jul 17, 2023 · 0 comments
Open
Labels

Comments

@MucTepDayH16
Copy link
Contributor

MucTepDayH16 commented Jul 17, 2023

With the following peg file:

ident = @{ &ASCII_ALPHA ~ (ASCII_ALPHA | ASCII_DIGIT | "_")+ }
integer = @{ ASCII_NONZERO_DIGIT ~ ASCII_DIGIT* | "0" }

ident_index = { ident ~ "[" ~ integer ~ "]" }
value = { ident_index | ident }

I'm trying to parse ident_index with non-matching string, the error ParsingError { positives: [ident], negatives: [] } is produced. How should I specify wether the expected rule is ident_index or ident (or both as in value)?

The only way to do it is marking ident_index as atomic (@). But my goal is to produce rule ident_index with inner: [ident, integer] and with spaces allowed between rules.

Maybe it will be useful to add modifier that will act as normal rule, but will produce itself on rule mismatch within.

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

1 participant