1
votes

I am working on a grammar that allows for keywords as identifiers, and the current suggestion seems to be to do something like:

id : 'if'|'call'|'then'|ID;

My language has a lot of keywords, so I've been doing:

id: ~(PLUS | MINUS);

Basically any token that's NOT a non-keyword token.

Is there a way to have all of my keyword tokens be prepended with some string and wildcard match that? e.g.

K_PLUS: '+';
K_MINUS: '-';
ID: <everything else>;

id : ID | ~(K_*);
1

1 Answers

0
votes

No, that is not possible unfortunately.