Posted By:
Ben_Yeung
Posted On:
Thursday, August 30, 2001 12:16 PM
I have read the article "http://www.antlr.org/fieldguide/whitespace/" and I have a hard time to understand the meaning of action involved ( "{#call = #(#[CALL,"CALL"], #call);} ). Can anyone spare some time to explain to me ? Thanks, Ben The complete parser rule is as follows: class InstrParser extends Parser; options { buildAST = true; k=2; } tokens { CALL // define imaginary token CALL } slist : ( stat )+ ; stat: LBRACE^ (stat)+ RBRACE | "if"^ expr "then" stat ("else" stat)?
More>>
I have read the article "http://www.antlr.org/fieldguide/whitespace/" and I have a hard time to understand the meaning of action involved
( "{#call = #(#[CALL,"CALL"], #call);} ).
Can anyone spare some time to explain to me ?
Thanks,
Ben
The complete parser rule is as follows:
class InstrParser extends Parser;
options {
buildAST = true;
k=2;
}
tokens {
CALL // define imaginary token CALL
}
slist
: ( stat )+
;
stat: LBRACE^ (stat)+ RBRACE
| "if"^ expr "then" stat ("else" stat)?
| ID ASSIGN^ expr SEMI
| call
;
expr
: mexpr (PLUS^ mexpr)*
;
mexpr
: atom (STAR^ atom)*
;
atom: INT
| ID
;
call: ID LPAREN (expr)? RPAREN SEMI
{#call = #(#[CALL,"CALL"], #call);}
^^^ This is line I don't understand.
;
<<Less