bug-bison
[Top][All Lists]
Advanced

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

Re: yyparse being prototyped in y.tab.h causes problems.


From: Akim Demaille
Subject: Re: yyparse being prototyped in y.tab.h causes problems.
Date: Tue, 18 Aug 2015 21:36:26 +0200

Hi!

> Le 18 août 2015 à 15:35, Kaz Kylheku <address@hidden> a écrit :

> While on the topic of POSIX, what does it have to say about
> the y.tab.h header file?
> 
>  -d  Write the header file; by default only the code
>      file is written. The #define statements associate the
>      token codes assigned by yacc with the user-declared
>      token names. This allows source files other than
>      y.tab.c to access the token codes.
> 
> According to this, y.tab.h is supposed to just #define
> the token codes!
> 
> (Unfortunately, the spec forgets the obvious: that lexers
> also need YYSTYPE from y.tab.h, and traditional Yacc
> implementations provide it.)

I'm not reading this as exclusive.  It should at least contain
that.

> In any case, users who want who want additional declarations
> can easily write their own header like "y.decl.h". The
> %code functionality for depositing additional material in
> y.tab.h is superfluous, solving a problem that is already
> solved by the C preprocessor, and the fact that you can
> #include your own header between %{ and %} in the grammar
> file. Anyone who has needed a global declaration for yyparse
> (or anything else exported by the .y file) in the past 40
> years probably did exactly that.

That's not entirely true.  Things have changed in the meanwhile,
and C, for instance, now has prototypes.  And compilers issue
warning when a function is not prototype and is not static for
instance.  So I beg to disagree: Bison tries to address today's
needs.

And %code is not superfluous.  For instance, we also support
Java.  And how do you extend a macro?




reply via email to

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