help-bison
[Top][All Lists]
Advanced

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

Re: How to solve this kind of ambiguities?


From: Sylvain Schmitz
Subject: Re: How to solve this kind of ambiguities?
Date: Fri, 04 Aug 2006 16:16:50 +0200
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

Dong Tiger wrote:
Look at the following expression( c-like syntax):

      1 - 2 * (TYPE_OR_VAR) - 1

The real token type of TYPE_OR_VAR is unknown. The expression could be
parsed as the following two options:

1. TYPE_OR_VAR is a typename. Then "(TYPE_OR_VAR)-1" is a cast expression.
And the expression equals to:
     1 - ( 2 * ( (TYPE_OR_VAR)-1))

2. TYPE_OR_VAR is a variable. Then the expression equals to:
     1 - 2 * TYPE_OR_VAR - 1

I would like to choose the second option but I can't do it with "%dprec". As
when the ambiguity happens, the two options
are shifted by the same rule.

What can I do to get around this problem?

Your lexer could lookup your symbol table and return TYPE in one case and VAR in the other.

--
  Sylvain




reply via email to

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