help!a problem of token management,
1 posts in topic
Flat View  Flat View

Posted By:   Xiaoyu_MAO
Posted On:   Wednesday, May 11, 2005 06:26 AM

i am a freshman of Antlr, i met the trouble in the management of tokens: Here is an exemple:

trdesc : TR transition INT;

when it met a TR, i want to add an action:
{Transition t = new Transition(); t.id = PN_transition_No++;}
/*Transition is a class i defined*/

After transition:
{t.label = transition.getText(); ???/* the generated parser cannot find 'transition' */}
/*my question is how to get the content of transition?*/

after INT
{t.value = ???} /*how to get the value of INT*/


Re: help!a problem of token management,

Posted By:   Kai_Koehne  
Posted On:   Saturday, May 14, 2005 11:51 AM

Something like

trdesc: TR { Transition t = new Transition; t.id = PN_transition_No++; }
tr:transition { t.label = #tr.getText(); }
INT { t.value = #INT.getText(); }


trdesc: TR tr:transition INT
Transition t = new Transition();
t.id = PN_transition_No++;
t.label = #tr.getText();
t.value = #INT.getText();

should do.


Kai Koehne
About | Sitemap | Contact