Re: Tree-like construction while parsing the input file

2009-01-11 Thread Hans Aberg
On 11 Jan 2009, at 18:37, Ilyes Gouta wrote: Then the parse tree of those before will be constructed before those latter. In your example, item_declaration will be constructed before item_list, so one can have actions item_declaration {...} item_list {...} Here, the first action {...} can on

Re: Tree-like construction while parsing the input file

2009-01-11 Thread Ilyes Gouta
Hi Hans, item_list: >> | item_declaration item_list >> ; >> > > But sometimes one can do a trick by combining non-terminals into one rule. > Then the parse tree of those before will be constructed before those latter. > In your example, item_declaration will be constructed before item_list, so >

Re: Tree-like construction while parsing the input file

2009-01-10 Thread Hans Aberg
On 10 Jan 2009, at 16:41, Ilyes Gouta wrote: Here is a snippet of my grammar: input: | declaration input ; item_list: | item_declaration item_list ; enum_item: id { add_node_item(handle, &$1); } | id '=' expr { add_node_item(handle, &$1); } ; declaration:

Tree-like construction while parsing the input file

2009-01-10 Thread Ilyes Gouta
Hi, I'm writing a simple C header file parser using bison and I would like to build a tree structure (a simplified AST) which will hold all the elements of a given .h file. Here is a snippet of my grammar: input: | declaration input ; item_list: | item_declaration item_list ; enum_item: