help-bison
[Top][All Lists]
Advanced

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

RE: Literals and Tokens


From: Hans Aberg
Subject: RE: Literals and Tokens
Date: Thu, 26 Jun 2003 19:34:06 +0200

At 09:54 -0400 2003/06/26, Jeganatan, Srividhya wrote:

>But if I define a token for ';' and use that token in place of the ';',
>I see a conflict in the first set of rules (for D):
>';'    shift, and go to state 802
>';'    [reduce using rule 494 (D)]

If you would have made the change everywhere, there would be no ';'
present. So you probably missed at some places.

But if the change would have been made everyehere, except for renumbering
of states and tokens, there would have been no change.

You should look at the little dot in the conflicted states in the .output
file: This will tell you exactly what the problem is.

Glancing briefly at your grammar, you have perhaps thrown in ';' tokens in
a sloppy way. Make sure this is correct before moving on.

Otherwise, you might resolve shift/reduce conflicts by prcedence
declarations on the tokens before and after the . in the conflicted state.
If one thinks Bison's preference for shift over reduce is OK, one also
ignore the problem using %expect.

>Here is the exact grammar I mentioned in my previous mail.
>
>FIRST SET:
>===========
>A: '{' B '}'
>
>B: B C D |    --------- C is optional
>   C D
>
>D: A |
>   KEYWORD1 E KEYWORD1 F |    ------------- E & F are not empty
>   D KEYWORD2 D |
>   D ';'
>
>F: Y |
>   '{' Y '}' |
>   ';'
>
>Y  ->  X .       (rule 555)
>Y  ->  X . Y     (rule 556)
>Y  ->  X . ';' Y (rule 557)
>
>X is all set of terminals.
>
>In the second set of rules (for Y) I see a conflict,
>
>';'    shift, and go to state 640
>';'       [reduce using rule 555 (Y)]
>
>None of these non-terminals can be "empty".
>
>But if I define a token for ';' and use that token in place of the ';',
>I see a conflict in the first set of rules (for D):
>';'    shift, and go to state 802
>';'    [reduce using rule 494 (D)]
>
>Could you please suggest how to resolve such conflicts?
>
>Thanks
>Srividhya.
>
>-----Original Message-----
>From: Jeganatan, Srividhya
>Sent: Thursday, June 26, 2003 9:31 AM
>To: 'Hans Aberg'
>Cc: 'address@hidden'
>Subject: RE: Literals and Tokens
>
>
>Thanks for the reply.
>But I need a bit more information.
>
>I have some rules like this in my grammar:
>A:A SOMEKEYWORD A |
>  A ';'
>
>and some other rules like this:
>Y  ->  X .                (rule 555)
>Y  ->  X . aclist     (rule 556)
>Y  ->  X . ';' aclist (rule 557)
>
>X is all set of terminals.
>
>In the second set of rules I see a conflict,
>
>';'    shift, and go to state 640
>';'       [reduce using rule 555 (Y)]
>
>None of these non-terminals can be "empty".
>
>But if I define a token for ';' and use that token in place of the ';',
>I see a conflict in the first set of rules:
>';'    shift, and go to state 802
>';'    [reduce using rule 494 (A)]
>
>Could you please suggest how to resolve such conflicts?
>
>Thanks
>Srividhya.
>-----Original Message-----
>From: Hans Aberg [mailto:address@hidden
>Sent: Thursday, June 26, 2003 4:43 AM
>To: Jeganatan, Srividhya
>Cc: 'address@hidden'
>Subject: Re: Literals and Tokens
>
>
>At 16:33 -0400 2003/06/25, Jeganatan, Srividhya wrote:
>>Is there a difference between using a single character literal in a rule
>and
>>a token representing the literal?
>
>A character token gets its character number as its external token number.
>Other tokens get external token numbers starting at 258. In reality,
>though, Bison translates these number to internal ones, using a translation
>table.
>
>  Hans Aberg







reply via email to

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