[antlr-interest] help regrading actions in antlr grammer
atif azad
atif.azad at hotmail.com
Sun Aug 26 18:52:00 PDT 2007
Hello Dear
I am a student .And I am trying to add actions to this grammer as below.
I want to get a list of OPCODES and then operands on the terminal.
Can any one plz help me how can I do it without using the string Template
and will be useful if also using the string template.
i will be greatful.
Here is the grammer
grammar assemb;
options {output=template; rewrite=true;}
program
: (stat)+
;
stat: OPCODE operands
;
operands
:REGISTER SEMI
| REGISTER COMMA REGISTER SEMI
;
OPCODE :
'add'
|'store'
|'load'
|'call'
|'ret'
|'print' ;
REGISTER :
'r1'
|'r2'
|'r3'
|'r4' ;
NUM : '[0-9]+' ;
ID : '[a-zA-Z]+' ;
EOL
: (('\r')? '\n') ;
WS
: (
| (' ' | '\t')
) { $channel=HIDDEN; }
;
SEMI:
';'
;
COMMA:
','
;
Regards
Azad , Atif
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
More information about the antlr-interest
mailing list