help-bison
[Top][All Lists]
Advanced

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

Re: Top Dowm Variable Communication


From: Ramón García
Subject: Re: Top Dowm Variable Communication
Date: Sat, 25 Aug 2007 04:41:18 +0200

Sorry, my initial answer was not quite correct.

The way to do this in Bison is to access the semantic value of the
previous non-terminal in the parent rule as $0. For example:

A: B C D
  C: X { $0 is the semantic value of B}

This is risky. One has to take care that in all places where a
non-terminal is referenced, the non-terminal bellow is the expected
one; or whatever it is, it has the expected semantic value.

In your example,
> Register_decl
>         : REGISTER IDENTIFIER Register_decl_contd;
> Register_decl_contd
>         : '.' IDENTIFIER ...something...
>                 { access register name as $0 ... }
>         | '=' IDENTIFIER ...something...
>                 { idem ... }
>         | '[' IDENTIFIER ...something...
>                 { idem }

But this is correct if the first line of this example contains the
only right hand side that has Register_decl_contd. Only in this case
it is safe to assume that IDENTIFIER is the semantic value stored
bellow in the stack.

Best regards,

Ramon




reply via email to

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