[Top][All Lists]

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

Re: why are locations dictated by bison?

From: Bruce Lilly
Subject: Re: why are locations dictated by bison?
Date: Thu, 17 Jan 2002 12:43:20 -0500

Hans Aberg wrote:
> One idea presented on the Bison lists is that Bison have two modes, one
> YACC compatible, and another Bison mode that better addresses the need of
> modern parser generators (which is what it already has, but one might push
> it more systematically).
> If now Bison and Flex might be tuned together, could not the Flex lexer have
> #ifndef YYEOF
> #define YYEOF
> #endif
> and return YYEOF instead? Then Bison x.tab.h file should define this macro,
> and the manuals should in future say to return YYEOF instead of 0.
> Then in the future, the Bison mode might define YYEOF to -1, whereas in the
> Yacc/Lex mode it would always be defined to 0.

It's not a mere case of bison vs. yacc. Any combination of
{bison, yacc, byacc, etc.} with {flex, lex, etc.} might be
used.  For maximum portability of source distributions,
specific "features" of a particular implementation of
lexical analyzer or parser generator should not be assumed
unless there is absolutely no other viable alternative.
And code littered with lots of preprocessor conditionals
is difficult to maintain.

What's the big deal anyway; handling ASCII NUL is as simple

%token NUL

in the parser .y file and

\0 { return NUL; }

in the lexical analyzer .l file (assuming the lexical analyzer
generator can handle NUL at all).  Given that simplicity, why
introduce incompatibility and maintenance headaches?

reply via email to

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