-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Start by having rules for your keywords:
Then have a rule for any keyword:
Finally, use the
This should do the trick. You can, of course, use more complicated grammars if you want to exclude everything that contains a keyword or more complicated patterns. |
Beta Was this translation helpful? Give feedback.
-
okay cool, but is identifier by default includes
|
Beta Was this translation helpful? Give feedback.
-
That's just because the grammar matches the "test1" part of the input and ignores the rest. You need to explicitly enforce that the input ends after your label. Use:
|
Beta Was this translation helpful? Give feedback.
-
It worked! |
Beta Was this translation helpful? Give feedback.
-
You're welcome, thanks for choosing the PEGTL :) |
Beta Was this translation helpful? Give feedback.
Start by having rules for your keywords:
Then have a rule for any keyword:
Finally, use the
minus<>
rule to match an identifier and make sure it is not a keyword.This should do the trick. You can, of course, use more complicated grammars if you want to exclude everything that contains a keyword or more complicated patterns.