help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: problem compiling bison with gcc 3.0.5


From: Martin Trautmann
Subject: Re: problem compiling bison with gcc 3.0.5
Date: Sat, 02 Mar 2002 13:50:21 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204

Hi,

please send only to the list. I subscribed.

Hans Aberg wrote:
+ Why can't such a conflict be avoided with %prec precedences?


It has to do with the precedence algorithm used; see for example
  http://www.cs.vu.nl/~dick/PTAPG.html
and the "Modern Compiler Design" book by the same authors.

I downloaded it, but I will need some time to read it.
My problem is, that I want to create two parallel expression parsers:
exp:
    simple_exp  %prec normal
  | complex_exp
;
simple_exp: simple_exp '+' simple_exp
  | '+' simple_exp %prec UMINUS
  | any_simple_token
;
complex_exp: complex_exp '+' complex_exp
  | '+' complex_exp %prec UMINUS
  | simple_exp %prec very_very_low
  | any_complex_token
;

The complex expression creates parse trees in the memory but it shouldn't be used for simple expressions like 1 + 1; The generated parser works like I want it, but why isn't it possible to tell with %prec very_very_low that it shouldn't be used when there is an alternative rule with %prec normal.

  * passing some objects to the yyparse() function


Check YYPARSE_PARAM, Bison manual sec 4.2.4.

I am using YYPARSE_PARAM at the moment, but its very nasty. Its only
possible to pass a void* pointer. This would be very easy to make the
type changeable.
The problem with the void* pointer is that the casts are quite long and
I don't like that in the actions. So I created lots of functions that
get the void* pointer and the other parameters, cast the pointer and call the right function of the casted object.


bye

Martin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]