1
votes

is it possible in ANTLR 4 to create a parser rule with arguments of type 'token', i.e. a sort of a rule

list[elem Token] : '[' elem (',' elem)* ']';

which should match a list of tokens of the type 'elem'. For example, list[ID] should match a list of identifiers while list[String] should match a list of strings both following the syntax given in the above rule.

1

1 Answers

0
votes

No, such semantic checks are generally done after parsing, in a listener or visitor (which ANTLR generates as well).