[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Strange behavior
From: |
Hans Aberg |
Subject: |
Re: Strange behavior |
Date: |
Mon, 29 Mar 2004 19:46:07 +0200 |
At 09:34 +0200 2004/03/29, Laurent Deniau wrote:
>Nothing about my question?
I think your question was answered by Tim Van Holder: Due to limitation in
lookahead in the LALR(1) parser generator algorithm, one has to fiddle
around with the grammar to find a form that works.
>> This is not really a Bison question, but a question of implementing a
>> language using the LALR(1) parsing algorithm. As your language is
>> well-known, it might be worthwhile asking around in the newsgroup
>> comp.compilers, or in some of the C newsgroups to see if somebody already
>> has done it. Some C compilers might already have it (GNU C?).
>
>My question has nothing to do with the C99 grammar. It was just to fix
>the background, nothing more.
So therefore, if the implemented language is known, it can be worth to look
around for tricks that may be required to implement it.
>> Tip: It is might be better to avoid the single quote ')' constructs, and
>> instead use
>> %token LP "("
>> %token RP ")"
>> ...
>> %%
>> ...>direct_abstract_declarator
>> : "(" abstract_declarator ")"
...
>> Then your Flex grammar must have lines
>> "(" { return RP; }
>> etc.
...
>Using string here is quite dangerous since you replace the character
>ASCII value by a string literal address. No a good idea...
In the handshake with the lexer, one is instead using usual token numbers
instead of character code numbers, which should in principle enable a
smaller parser token table. The strings are only exported to the parser to
a table used for error message printouts, which has strings in it anyway.
Hans Aberg