[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

parse.y (was Ripper and 1.8

Jonathan Maasland

8/22/2006 12:10:00 PM

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

2 Answers

ts

8/22/2006 12:18:00 PM

0

>>>>> "J" == Jonathan Maasland <nochoice@xs4all.nl> writes:

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

Look at the file

ruby/ext/ripper/tools/preproc.rb


Guy Decoux

Robin Stocker

8/22/2006 12:20:00 PM

0

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