[antlr-interest] variable definition in java.g
a_j_key
key at prontomail.com
Tue Apr 29 02:10:59 PDT 2003
Hi all,
After reading some posts and thinking about my problem, I could
change my approach, but I'm still stuck with the following:
variable declaration in Java: e.g. int a, b, c; double d;
What I want to do is to create something like a 'var-node' for the
first expression, and var-node for the second. I should looks like:
VAR_NODE
|
- VARIABLE_DEF
|
... a
|-VARIABLE_DEF
|
.... b
VAR_NODE
|
- VARIABLE_DEF
|
.... d
Here is my grammar:
declaration!
: m:modifiers t:typeSpec[false] v:variableNode[#m,#t]
{#declaration = #v;}
;
variableDefinitions[AST mods, AST t]
: variableNode[getASTFactory().dupTree(mods),
getASTFactory().dupTree(t)]
( COMMA!
variableNode[getASTFactory().dupTree(mods),
getASTFactory().dupTree(t)]
)*
;
variableNode[AST mods, AST t]
: vd:variableDeclarator
#variableNode = #(#["VAR_NODE, "VAR_NODE"], vd);
variableDeclarator![AST mods, AST t]
: id:IDENT d:declaratorBrackets[t] v:varInitializer
{#variableDeclarator = #(#[VARIABLE_DEF,"VARIABLE_DEF"], mods,
#(#[TYPE,"TYPE"],d), id, v);}
;
Thanks for your suggestions,
a.j.key
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list