I'm building an AST using ANTLR. I want to write a production that matches this string:
${identifier}
In my grammar file I have:
reference
: DOLLAR LBRACE IDENT RBRACE -> ^(NODE_VAR_REFERENCE IDENT)
;
This works fine. I'm using my own adaptor to emit tree nodes.
The rewrite rule used creates for me two nodes: one for NODE_VAR_REFERENCE
and one for IDENT
.
What I want to do is create only one node (for the NODE_VAR_REFERENCE
token), and this node must have the IDENT
token in its "token" field.
Is this possible using a rewrite rule? Thanks.