Skip to content

[javascript] are conditional/contextual keywords a good idea? #3309

Answered by KvanTTT
meraedit asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by meraedit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants