delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/26/23:48:52

Message-ID: <37759EE2.48904F14@unb.ca>
Date: Sat, 26 Jun 1999 23:47:46 -0400
From: Endlisnis <s257m AT unb DOT ca>
Organization: Nortel Networks
X-Mailer: Mozilla 4.51 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Re: Bison and particular expressions.
References: <01bebe6a$ad62d9a0$LocalHost AT thendren>
Reply-To: djgpp AT delorie DOT com

Christopher Nelson wrote:

> the proper way to have a list of this type is to do the following:
>
> listitem: item
> |    listitem ',' item
> ;
> listofitems: listitem
> ;

    The problem with this, is "item" is different in different contexts.  This
would work fine for parameter lists, but I need to compensate for variable
declarations in the form "int a,b,c,*d, **&e;" as well.  I've been able to
solve my problem with some excelent help provided by Doug Eleveld.  It had to
do with combining the "item" and the "," into one item to allow bison to use a
look-ahead token to resolve some conflicts.

> in addition, it is partially a lexical problem.  c is a very complex
> language to parse specifically because of typedef's and some special-case
> problems.  one part of what you should do is have the lexical-analyzer
> understand id contexts.  that way you can write the recursive list like
> this:

[snip]

I've think I got typedef's working, as well as structs and simple classes
(without methods) without lexical tie-ins.  Besides, scope stuff can be done to
make lexical tie-ins tricky [like]:
struct a {int a;};

int j()
{int m,a;
}


--
     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT HotMail DOT com
          ICQ: 32959047


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019