[antlr-interest] How to draw information from a returned AST
Priya
priya.uky at gmail.com
Fri Jan 13 12:49:46 PST 2006
Hello all,
I'm a newbie to antlr. I am currently working on an ANTLR-C++
compiler that parses a subset of C syntax.
Shown below is a portion of my parser grammar.
function_arg:
( !(COMMA!)? t1:type ( n:Name (l:LSQB d:Decimal_Number RSQB!)?)?);
type :(
d1:"char"^ COLON! de:Decimal_Number {#type=#(#d1,#(de)); }
| d:"char"^ { #type=#(#d,#[Nint,"4"]);}
| i2:"int"^ COLON! de1:Decimal_Number {#type=#(#i2,#(de1));}
| i1:"int"^ {#type=#(#i1,#[Nint,"8"]);}
| "void"! { #type=#(#[Nint,"int"],#[Nint,"0"]);})
) ;
ex:
(int:3 a,int:4 b[5])
int:3 is the notation i'm using to declare 3 bit integer.
for int:3 ,type will return an AST like
int
|
|
3
to the call from function_arg rule. In function_arg rule ,how can I
operate on the returned tree to record the datatype and bit precision
information ?
Thanks in advance
Priya
More information about the antlr-interest
mailing list