Oddity in StackerParser.y.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Oddity in StackerParser.y.

Ralph Corderoy

Hi,

    $ g -1 '^Module' StackerParser.y
    /* A module is just a DefinitionList */
    Module    :                 { SCI->handle_module_start( ); }
              DefinitionList    { $$ = SCI->handle_module_end( $2 ); } ;
    $

It's been years since I was heavily into yacc, but shouldn't it be
s/$2/$1/?

Cheers,


Ralph.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Oddity in StackerParser.y.

Jeff Cohen
No, $2 is correct.  The { } code block before DefinitionList is counted
(or more precisely, the empty sequence of terminals preceding it is
counted).

Ralph Corderoy wrote:

>Hi,
>
>    $ g -1 '^Module' StackerParser.y
>    /* A module is just a DefinitionList */
>    Module    :                 { SCI->handle_module_start( ); }
>              DefinitionList    { $$ = SCI->handle_module_end( $2 ); } ;
>    $
>
>It's been years since I was heavily into yacc, but shouldn't it be
>s/$2/$1/?
>
>Cheers,
>
>
>Ralph.
>
>
>_______________________________________________
>LLVM Developers mailing list
>[hidden email]         http://llvm.cs.uiuc.edu
>http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
>  
>

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: Oddity in StackerParser.y.

Reid Spencer
In reply to this post by Ralph Corderoy
Nope.  $2 refers to "DefinitionList" .. its the second thing in the
production named "Module".

Reid.

On Thu, 2006-04-20 at 17:07 +0100, Ralph Corderoy wrote:

> Hi,
>
>     $ g -1 '^Module' StackerParser.y
>     /* A module is just a DefinitionList */
>     Module    :                 { SCI->handle_module_start( ); }
>               DefinitionList    { $$ = SCI->handle_module_end( $2 ); } ;
>     $
>
> It's been years since I was heavily into yacc, but shouldn't it be
> s/$2/$1/?
>
> Cheers,
>
>
> Ralph.
>
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Oddity in StackerParser.y.

Ralph Corderoy
In reply to this post by Jeff Cohen

Hi Jeff,

> Ralph Corderoy wrote:
> >    /* A module is just a DefinitionList */
> >    Module    :                 { SCI->handle_module_start( ); }
> >              DefinitionList    { $$ = SCI->handle_module_end( $2 ); } ;
>
> No, $2 is correct.  The { } code block before DefinitionList is
> counted (or more precisely, the empty sequence of terminals preceding
> it is counted).

Ah, thanks.  I found it in the Bison manual too:
http://www.gnu.org/software/bison/manual/html_mono/bison.html.gz#Mid_002dRule-Actions

Cheers,


Ralph.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev