Holub grammar problem?

Steven Gollery <sgollery@tuba.aix.calpoly.edu>
Fri, 30 Sep 1994 18:18:08 GMT

          From comp.compilers

Related articles
Holub grammar problem? sgollery@tuba.aix.calpoly.edu (Steven Gollery) (1994-09-30)
Re: Holub grammar problem? aldy@andrews.edu (1994-10-03)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Steven Gollery <sgollery@tuba.aix.calpoly.edu>
Keywords: books, parse, question
Organization: Compilers Central
Date: Fri, 30 Sep 1994 18:18:08 GMT

I've looked at the list of errata for Holub's Compiler Design in C, and
I don't see any mention of a problem I've run into with it. It's
probably just something I don't understand about the grammar -- if so
I would appreciate it if someone would explain it to me.

I don't see how the grammar can handle local variables with types that
have been previously defined as typedefs. Holub's lexer returns TTYPE
when it finds a name that has been typedef'd. Local variable declarations
use these productions:

local_defs : def_list ;
def_list : def_list def
                        | /* epsilon */
def : specifiers decl_list SEMI
                        | specifiers SEMI
specifiers : type_or_class
                        | specifiers type_or_class
type_or_class : type_specifier
                            | CLASS
type_specifer : TYPE
                            | enum_specifier
                            | struct_specifier

Since enum_specifier has to start with the ENUM token, and
struct_specifier has to start with STRUCT, I don't see how a def can
possibly involve a TTYPE.

Hopefully someone can set me straight me straight on this. Or -- if it is
actually a problem with the grammar -- can suggest a fix: everything I've
though of so far results in about 8 conflicts of one sort or the other.

Any help appreciated.

Steven Gollery

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.