-
With the current grammar definition for javascript, some keywords cannot be used as identifier names, even though the browser supports them. The es standard allows it: Keywords and Reserved Words
Is there a better way to avoid getting syntax errors due to conditional keywords? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can use semantic predicates in the following way: getter
: {_input.LT(1).getText().equals("get")}? Identifier propertyName
; But it's not a very good solution: it's target-specific and it looks cumbersome. The feature for contextual keywords was suggested some time ago: Token value comparison operator. Unfortunately, unlikely it will be implemented in ANTLR 4. |
Beta Was this translation helpful? Give feedback.
You can use semantic predicates in the following way:
But it's not a very good solution: it's target-specific and it looks cumbersome.
The feature for contextual keywords was suggested some time ago: Token value comparison operator. Unfortunately, unlikely it will be implemented in ANTLR 4.