Skip to content

Unwanted space consumption in rule parameter #308

@thaven

Description

@thaven

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions