[Top][All Lists]

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

Re: YYEOF shouldn't be defined with bison -y

From: Hans Åberg
Subject: Re: YYEOF shouldn't be defined with bison -y
Date: Thu, 7 Dec 2017 18:59:09 +0100

> On 5 Dec 2017, at 02:32, Dimitrios Apostolou <address@hidden> wrote:
> I am generating a parser as part of a different project, and that project is
> configured with AC_PROG_YACC. As such, it invokes Bison with "-y" option, and
> I would expect that Bison tries hard to fail when the parser uses non-portable
> features, such as YYEOF.
> This is not the case however, and the project was released, and this was
> discovered after longtime that somebody built it with byacc instead of
> Bison. With that version of byacc, the generated parser C code failed to build
> with "undefined symbol YYEOF".
> I would expect that "bison -y" undefines YYEOF, so that the software that uses
> YYEOF fails to build.

The generated parser  .c file is intended to run on all platforms, so by 
setting the makefile to only compile if the grammar .y file is altered, such 
problems might be avoided. Automake AC_PROG_YACC is only designed for Yacc 
compatibility, so otherwise, for example if you want the program to be Bison, 
another symbol should be used.

According to POSIX [1], the names starting with YY are for the implementation 
of the Yacc program, so if such are used in the grammar, it is not portable 
(like names starting with _ in C). From a Flex .l file, one can return EOF.

1. http://pubs.opengroup.org/onlinepubs/009604599/utilities/yacc.html

reply via email to

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