rustmatic
rustmatic copied to clipboard
Identifier which starts with a keyword
tried to add RETURN
as a keyword, but the test parse_a_function
fails, since the function in the test is called ReturnFive
.
I guess it fails here?
identifier = @{
!keyword ~ ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")*
}
Is there a limitation in the standard that you can't start an identifier with a keyword?
Is there a limitation in the standard that you can't start an identifier with a keyword?
I think it's just the way that pattern was written. Instead of using !keyword
to make sure an identifier isn't a keyword, it should use some sort of word boundary. I'm not sure how we'd express the equivalent using Pest though.
I see that if I remove the requirement for not starting with a keyword, that is:
identifier = @{
ASCII_ALPHA ~ (ASCII_ALPHANUMERIC | "_")*
}
, then I'm allowed to add ^"return"
and all tests pass.
Are the grammar rules searched from top to bottom in the .pest file?
I didn't have time to investigate further now, just wanted to drop you a note.