How to exclude whitespace from location information? #228
Unanswered
radekstatebox
asked this question in
Q&A
Replies: 1 comment
-
Your suggestion might be cleaner once #337 lands. Something like: Trail_<R, n> = @(r:R { return { sourceSpan: location(), [n]: r } }) _
Identifier = Trail_<identifier, "name"> Except. You'd really like access to the rule name of R so you didn't also have to pass in "name". @quadristan I haven't fully internalized how templates work yet, do you have any insights? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The usual way to ignore whitespace is by appending a whitespace rule to each terminal:
However, now the location includes the whitespace:
For the input
a b
, the location for the first identifier would be:Is there a nice way to exclude the trailing whitespace from the location information? I could move the
location()
call to the definition ofidentifier
like so:But that doesn’t really scale to more complicated productions (especially non-terminals).
Beta Was this translation helpful? Give feedback.
All reactions