Forum: Ruby-core trunk's parse.c fails to compile

Posted by Laurent Sansonetti (Guest)
on 2007-11-13 15:28
(Received via mailing list)
Hi,

I wasn't able to compile trunk using the latest revision, on my
environment, Mac OS X 10.5 with GNU Bison 2.3. The problem was parse.c
not being able to compile:

gcc -g -O2  -fno-common -pipe -fno-common  -I.
-I.ext/include/i686-darwin9.0.0 -I./include -I.  -DRUBY_EXPORT  -c
parse.c
parse.c:9317:28: error: macro "yyerror" passed 2 arguments, but takes 
just 1
parse.c: In function 'ruby_yyparse':
parse.c:9317: error: 'yyerror' undeclared (first use in this function)
parse.c:9317: error: (Each undeclared identifier is reported only once
parse.c:9317: error: for each function it appears in.)
parse.c:9321:42: error: macro "yyerror" passed 2 arguments, but takes 
just 1
parse.c:9439:43: error: macro "yyerror" passed 2 arguments, but takes 
just 1
make: *** [parse.o] Error 1

At a glance it seems like a problem in tool/ytab.sed, which doesn't
replaced the `yyerror (parser' lines with parser_yyerror instead. Some
lines that were generated by bison but not replaced by the sed script:

     [...]
     yyerror (parser, yymsg);
     [...]
     yyerror (parser, YY_("syntax error"));
     [...]

I was able to change ytab.sed to make trunk build. I am not sure if
the current regex is expected (\< ?), but I don't know very much sed's
regex syntax.

Laurent

Index: tool/ytab.sed
===================================================================
--- tool/ytab.sed  (revision 13909)
+++ tool/ytab.sed  (working copy)
@@ -5,6 +5,6 @@
 a\
 #endif
 }
-s/\<\(yyerror[   ]*([   ]*parser,\)/parser_\1/
+s/^[   ]*\(yyerror[   ]*([   ]*parser,\)/parser_\1/
 s!^ *extern char \*getenv();!/* & */!
 s/^\(#.*\)".*\.tab\.c"/\1"parse.c"/
Posted by Charles Oliver Nutter (Guest)
on 2007-11-13 22:05
(Received via mailing list)
Laurent Sansonetti wrote:
> Hi,
> 
> I wasn't able to compile trunk using the latest revision, on my
> environment, Mac OS X 10.5 with GNU Bison 2.3. The problem was parse.c
> not being able to compile:

Ditto for me, but different error:

bison  -o y.tab.c parse.y
parse.y:589: unrecognized: %parse_param
parse.y:589:    Skipping to next %
make: *** [parse.c] Error 1

- Charlie
Posted by Laurent Sansonetti (Guest)
on 2007-11-13 22:16
(Received via mailing list)
On Nov 13, 2007 10:05 PM, Charles Oliver Nutter <charles.nutter@sun.com> 
wrote:
> parse.y:589: unrecognized: %parse_param
> parse.y:589:    Skipping to next %
> make: *** [parse.c] Error 1
>

I got the same problem on 10.4 Tiger, which includes bison 1.28.
Leopard has bison 2.3 and parse.y is successfully handled. The
compilation problem happens next though.

Maybe the new parse.y changes aren't compatible with old bison versions.

Laurent
Posted by murphy (Guest)
on 2007-11-14 23:01
(Received via mailing list)
Charles Oliver Nutter wrote:
> make: *** [parse.c] Error 1
same here on Tiger. after installing Bison 2.3, it worked perfectly -
and the 3 errors in test_syntax.rb were gone, too!

but we can't expect all people to install bison 2.3 first, can we?
[murphy]
Posted by David Flanagan (Guest)
on 2007-11-14 23:22
(Received via mailing list)
Charles Oliver Nutter wrote:
> parse.y:589: unrecognized: %parse_param
> parse.y:589:    Skipping to next %
> make: *** [parse.c] Error 1
> 
> - Charlie
> 

And I get yet another error:

gcc -g -O2  -I. -I.ext/include/i686-linux -I./include -I.  -DRUBY_EXPORT
-D_GNU_SOURCE=1  -c parse.c
parse.c: In function ‘yydestruct’:
parse.c:4114: error: ‘parser’ undeclared (first use in this function)
parse.c:4114: error: (Each undeclared identifier is reported only once
parse.c:4114: error: for each function it appears in.)
make: *** [parse.o] Error 1

This is on Fedora Core 4 with gcc version 4.0.2 20051125

$ bison --version
bison (GNU Bison) 2.0
$ uname -a
Linux think 2.6.12-1.1398_FC4 #1 Fri Jul 15 00:52:32 EDT 2005 i686 i686
i386 GNU/Linux

My temporary workaround is to change #define YYDEBUG from 1 to 0 at the
very top of parse.y

  David
Posted by Nobuyoshi Nakada (nobu)
on 2007-11-15 01:52
(Received via mailing list)
Hi,

At Thu, 15 Nov 2007 07:21:37 +0900,
David Flanagan wrote in [ruby-core:13525]:
> $ bison --version
> bison (GNU Bison) 2.0
> $ uname -a
> Linux think 2.6.12-1.1398_FC4 #1 Fri Jul 15 00:52:32 EDT 2005 i686 i686 
> i386 GNU/Linux

Bison 2.0 and 2.1 have other problems too, whitch makes broken
code.  I strongly recommend to upgrade it.
Posted by Vincent Isambart (Guest)
on 2007-11-15 09:15
(Received via mailing list)
> but we can't expect all people to install bison 2.3 first, can we?
Well, if I'm not mistaken bison is only required to build from SVN
(the file generated with bison is included in the tar.gz release
files) so it's not that big a problem.
Posted by murphy (Guest)
on 2007-11-15 09:19
(Received via mailing list)
Vincent Isambart wrote:
> Well, if I'm not mistaken bison is only required to build from SVN
> (the file generated with bison is included in the tar.gz release
> files) so it's not that big a problem.
that makes sense. I didn't know that, thank you.

then we should add a note into the README or somewhere that Bison 2.2+
is needed...
[murphy]
Posted by yang hawk (Guest)
on 2007-11-19 03:53
(Received via mailing list)
Laurent Sansonetti wrote:
> Hi,
>
> I wasn't able to compile trunk using the latest revision, on my
> environment, Mac OS X 10.5 with GNU Bison 2.3. The problem was parse.c
> not being able to compile:

I use YACC instead of Bison, and i get an different error:

../yacc-1.9.1/yacc parse.y
../yacc-1.9.1/yacc: e - line 584 of "parse.y", syntax error
%pure_parser
^

Can we use YACC to build ruby-1.9?
Posted by Nobuyoshi Nakada (nobu)
on 2007-11-19 05:28
(Received via mailing list)
Hi,

At Mon, 19 Nov 2007 11:52:34 +0900,
yang hawk wrote in [ruby-core:13695]:
> I use YACC instead of Bison, and i get an different error:
> 
> ../yacc-1.9.1/yacc parse.y
> ../yacc-1.9.1/yacc: e - line 584 of "parse.y", syntax error
> %pure_parser
> ^

Since 3 years ago.

> Can we use YACC to build ruby-1.9?

No, bison is required for ripper.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.