help-bison
[Top][All Lists]
Advanced

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

Re: x + (y) + z


From: Hans Aberg
Subject: Re: x + (y) + z
Date: Sun, 06 Mar 2005 15:41:05 +0100
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

At 14:43 +0000 2005/03/05, Derek M Jones wrote:
>>The normal way to resolve this would be to let the lexer check the lookup
>>table to see what y is: a type or a number identifier, and then return that
>>type. WHy does this not work for you.
>
>Because I don't have a symbol table to look things up in.
>Perhaps I should have pointed this out (it also answers
>Frank Heckenbach's question).  When parsing the visible
>source (ie not doing any preprocessing; well apart from
>ignoring the directives) a statement/declaration at a time
>the content of a symbol table are likely to be very incomplete.

You are not processing the C language, but some other language, with the
context dependencies of the C language removed. Perhaps check the newsgroup
comp.comilers for better input on that problem.

>>The commands %left and %right handles left and right associativity.
>
>Good alternative suggestion.  But this still requires tree rewriting
>after the expression has been parsed. My %gooa option proposal
>avoids this grammar violence.

Featuritis should be posted in bug-bison. You can only expect to get such
features into Bison if there is someone willing to volunteer doing the work.

Alternatively, you might introduce a new token-name both for type-names and
number-names. I.e., instead of
%token type-name number-name
you write
%token token-type-name
%%
type-name: token-type-name;
number-name: token-type-name;

You then get a correct GLR parse, and can try to sort out the ambiguity
later.

  Hans Aberg






reply via email to

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