Parse.y (was Ripper and 1.8)

Hi all,

I've been poking around Ripper for the last couple a days and during that process I started to look at parse.y as it's currently in CVS (Ruby 1.9 that is).
I'm not very knowledgeable about yacc and parsers in general but I just wanted to ask a quick question.

In parse.y I see alot of /*%%%*/ and /*% --code-- %*/"constructs" for example:

···

-----
primary : literal
                > strings
                > xstring
                > regexp
                > words
                > qwords
                > var_ref
                > backref
                > tFID
                    {
                    /*%%%*/
                        $$ = NEW_FCALL($1, 0);
                    /*%
                        $$ = method_arg(dispatch1(fcall, $1), arg_new());
                    %*/
                    }
-------

I've started reading the bison manual but I can't find any reference to this construct.
My question: Are these lines just comments or are they instructing bison?

Again, any help is greatly appreciated.

With kind regards,
Jonathan

In parse.y I see alot of /*%%%*/ and /*% --code-- %*/"constructs" for

Look at the file

ruby/ext/ripper/tools/preproc.rb

Guy Decoux

Jonathan Maasland wrote:

                   /*%%%*/
                       $$ = NEW_FCALL($1, 0);
                   /*%
                       $$ = method_arg(dispatch1(fcall, $1), arg_new());
                   %*/

It's a construct needed for Ripper.

For Bison, the code of the first line is normal code, the second is comment. So the relevant part for Bison is:

   $$ = NEW_FCALL($1, 0);

In Ripper, there needs to be different code, so a script preprocesses the whole parse.y, removes the text from /*%%% to /*% and removes the %*/, so the second code line is relevant:

   $$ = method_arg(dispatch1(fcall, $1), arg_new());

Have a look at ext/ripper/tools/preproc.rb to see how the preprocessing works in detail.

   Robin Stocker