[antlr-interest] Fwd: How can I check in a code section of which type a token is?
Austin Hastings
Austin_Hastings at Yahoo.com
Sun Oct 7 16:56:39 PDT 2007
OJ,
You could check if the first character of $c.text was a double-quote (").
Or you could put logic in the grammar to handle that in a subrule:
value_param returns [ value ]
: STRING_CONST { $value = $STRING_CONST.text; }
| identifier { $value = myFetchValueFunction($identifier.text); }
;
=Austin
OJAY78 at gmx.de wrote:
> Hi @all,
>
> I have such an Rule alternative
> 'IsEqual''('a=function_type ',' b=identifier','c=(STRING_CONST|identifier)')'
> {
>
> if ($c.type==STRING_CONST)????
> }
>
> How can I detect inside my code Section if c is of the typ STRING_CONST or identifier. Thanks for your help!!
>
More information about the antlr-interest
mailing list