[antlr-interest] could not even do k=1 for decision xx; reason: timed out

Gavin Lambert antlr at mirality.co.nz
Sat Aug 8 20:09:24 PDT 2009


At 14:08 9/08/2009, Graham Wideman wrote:
>The basic issue is what the arguments to -> ^(NEWTOKEN[args] are 
>expected to be (ie: their types) and where such args can be 
>obtained from.

The arguments must match one of the available implementations of 
the tree adaptor's create method (with one extra parameter for the 
token type) -- unless you're using heterogeneous trees, as Tomasz 
was.  Then it's the constructor of the node type that 
matters.  Assuming you're using the standard nodes then you'll 
have these possibilities:

   no args: creates a blank token with the token type as its text
   [text]: creates a blank token with the specified text
   [token]: copies the specified token but changes its type
   [token, text]: copies the specified token but changes its type 
and text

>It wasn't clear to me if some form of this (eg: 
>$parserRule.something) should work... ie: should it be possible 
>to get a token from a parser rule?  Some further light on this 
>would be helpful.

You can use $rule.start and $rule.stop to get the start and end 
tokens of the range matched by a rule, or you can specify your own 
return values for a rule to return other specific tokens.  In both 
cases you need to be careful if the rule can successfully match no 
tokens at all (or not the one you're asking for).



More information about the antlr-interest mailing list