ANTRL: token to text in rewrite rule
- by Antonio
I'm building an AST using ANTLR.
I want to write a production that match a this string:
${identifier}
so, 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 NODE_VAR_REFERENCE token) and this node must have the IDENT token in his "token" field.
Is this possible using a rewrite rule? Thanks.