[Top][All Lists]

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

Re: [bug-bison] Bug in string-valued terminals

From: Joel E. Denny
Subject: Re: [bug-bison] Bug in string-valued terminals
Date: Tue, 28 Dec 2010 20:51:16 -0500 (EST)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

Hi Tom,

On Sat, 25 Dec 2010, Tom Roberts wrote:

> I want to have the grammar define the keywords as literal strings, so on first
> call my yylex() will build up its list of keywords by scanning yytname[] for
> entries beginning with '"'.

As you no doubt know, yytname is requested using %token-table.  However, 
since 2001 (according to our vc log), Bison's TODO has described 
%token-table as a broken feature that might not be worth keeping. 
Unfortunately, %token-table originated before my time, and I have no 
practical experience with it, so it's hard for me to determine the best 
way forward.

> In both bison-2.4.3/doc/bison.info and on page 84 of
> http://www.gnu.org/software/bison/manual/bison.pdf , the example code to map a
> string terminal to the return value from yylex() is incomplete -- it only
> gives a loop over yytname[], without telling the user what value to return.

I agree that the documentation is unclear here.

> The loop variable is i, and the value that must be returned is yytoknum[i].
> But yytoknum[] is inside that #ifdef and is not available.

The manual does not document yytoknum, and that's usually a sign it wasn't 
intended for users.

Does anyone remember exactly how yytname was originally intended to be 

reply via email to

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