Mail Archives: djgpp/1999/06/26/23:48:52
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 -