Hi Laurence,

Thanks for your comments!

>  fexpr: /* Empty  */
>  {
>   /* Action for empty case  */
>  };
>
>  fexpr: expr
>  {
>   /* Action for `expr' case  */
> };

I wasn't aware the one could duplicate a rule so that it has two
possible bodies. But it's alright, there is a second, much prettier
approach.

>  I'm not sure about your `block'.  It may make sense from the point of
>  view of a formal grammar, but in practice, it means parsing the same
>  input multiple times.  Have you got a solution for this yet?

Well, my purpose is to construct an abstract syntax tree given a
script. The block rule in may grammar is defined as following:

block: '{' {ctx->scope++;} declarations statements '}' {ctx->scope--;
fancy_stuff();} ;

Basically, parsing the input multiple time isn't really an issue for
my case (actually I don't understand your point here), since what I'm
doing is just recognizing/reducing the different script components,
building the ast nodes (filling the right information) and linking
these nodes properly to form the final tree once everything is reduced
to the primary block. I've got pretty much everything working (this
includes nodes for identifiers, unary and binary operations, array
fetches and stores (indexed accesses), jumps and conditional jumps).
Once the ast is constructed, I switch off flex/bison and all the
remaining work is done using that tree, this includes types
propagation (for the float and int conversions), registers allocations
and then native opcode emitters.

Best regards,
Ilyes Gouta.


_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to