[antlr-interest] Need help on constructing trees

kototama kototama kototamo at gmail.com
Fri Jul 14 08:46:52 PDT 2006


Hi,

Here is an extract of my grammar for a tiny programming language :

public_section!: PUBLIC LBRACE v:var_decl_list m:method_def_list RBRACE
{#public_section = #( [PUBLIC_SECTION, "public_section"],
#([VAR_DECLS,"var_decls"], v) , #([METHOD_DEFS, "method_defs"], m) );}
;

var_decl_list: (var_decl)*
;

var_decl!: LET t:type i:id (ASSIGN v:value)? EOS
      { #var_decl = #([VAR_DECL, "var_decl"], t, i, #([INIT_VALUE, "value"],
v)); }
;

I would like to simplify the public_section like this :

public_section!: PUBLIC LBRACE (v:var_decl)* m:method_def_list RBRACE

to avoid the definition of var_decl_list. Is it possible ? I don't find the
correct way to build the tree ("var_decls" contains only the last definition
if I do so).

Thanks in advance for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060714/70a32e99/attachment.html


More information about the antlr-interest mailing list