[antlr-interest] How to get value of next token match - regd.

Ashok Varikuti asoka250 at gmail.com
Wed Nov 12 03:29:35 PST 2008


Gavin Lambert wrote:
> At 23:55 12/11/2008, Ashok Varikuti wrote:
> >node_id[Object g,String subID] returns [int nodeID] @init {
> >nodeID=0;}
> >    :
> >    ( i=id
> >    | ^(COLON i=id (r=ID) ? ( compass ) ? )
> >    ) {}
> [...]
> >For this sample edge  cluster_A --> B, in the edges function,
> >start=node_id[g,subID] is the first match.
> >How do I do something like this, ( ^(D_EDGE_OP  (
> >start=edges[g,subID] | start=node_id[g,subID] (get value
> >of matched id in node_id func here) end=node_id[g,subID]
> >That is, I want to get the id of the matched node(which is
> >obvious node_id func) in the edges function.
>
> You mean like $start.nodeID?  Or something else?
>
> (To do that you'd need to make your node_id rule assign the ID to the 
> $nodeID return value as well.)
>
>
I can assign the ID to the return value, but I am returning an integer 
value and the text of the ID can be string too. Hence my wish to 
lookahead and get the ID value. Can I do something like this:-
$node_id[g,subID].ID to get the ID value. $start.nodeID doesn't work 
since start is of type integer. Thnkx gavin for ur response.

-- 
Ashok R Varikuti
Graduate Research Assistant
CIS Dept, Kansas State University
785-304-2401
ashokv at ksu.edu




More information about the antlr-interest mailing list