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

Unwanted space consumption in rule parameter #308

Open
thaven opened this issue Feb 19, 2022 · 0 comments
Open

Unwanted space consumption in rule parameter #308

thaven opened this issue Feb 19, 2022 · 0 comments

Comments

@thaven
Copy link

thaven commented Feb 19, 2022

In a grammar I did something like this:

IdentifierCont <~ [a-zA-Z0-9_]+

Word(Lit) <- Lit !IdentifierCont

I use it to parse keywords and assure the keyword does not appear just as the start of an identifier: Word("keyword")

Now it turns out this gets expanded to: Word!(pegged.peg.wrapAround!(Spacing, pegged.peg.literal!"keyword", Spacing)). This is obviously not what I intended.

Putting the call in a <- rule prevents this, but makes things cumbersome when space consumption is wanted around the keyword (which would often be the case). IMO when I explicitly pass a single parser to a parameterized rule, that thing should be passed without addition, no matter the type of rule. Space consumption may happen inside the parameterized rule, if that rule is defined to be space-consuming.

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

1 participant