Closed stoneRdev closed 3 years ago
@stoneRdev, %whitespace
only works on tokens. So you have to apply token operators < ... >
to token rules. Here is the example:
ASSIGNMENT_TOKEN <- < ("=" !"=") >
LEFT_EXPR <- < [a-zA-Z0-9]+ >
%whitespace <- [ \t\r]*
Hope it helps!
Yes that was the ticket! Much appreciated! And thank you for your work on this project!
So, when using macros to perform precedence climbing,
%whitespace
doesn't capture anything, and using precedence climbing seems to exclude other tokens. So parsing things likea=1
is fine, but when whitespace appears it goes bonk. Here's an example grammar explaining what I mean:Parsing the sample input
a=1
is fine, but parsinga = 1
produces1:2 syntax error, unexpected ' ', expecting <LEFT_EXPR>.
Adding the%whitespace <- [ \t\r]*
rule does not fix this, nor does making a~WS <- [ \t\r]*
and adding it to the macro like so:Infact, as soon as another token gets added to this maco, it complains that
3:1 'precedence' instruction cannot be applied to 'ASSIGNMENT_INFIX'.
So how is one expected to parse whitespace in the precedence climbing macros?
I will try to figure it out but any help is greatly appreciated