ruby-changes:2417
From: ko1@a...
Date: 13 Nov 2007 21:41:59 +0900
Subject: [ruby-changes:2417] nobu - Ruby:r13908 (trunk): * common.mk (parse.c), ext/ripper/depend (ripper.c): process after
nobu 2007-11-13 21:41:41 +0900 (Tue, 13 Nov 2007) New Revision: 13908 Added files: trunk/tool/ytab.sed Modified files: trunk/ChangeLog trunk/Makefile.in trunk/bcc32/Makefile.sub trunk/common.mk trunk/ext/ripper/depend trunk/parse.y trunk/ruby.c trunk/win32/Makefile.sub trunk/wince/Makefile.sub Log: * common.mk (parse.c), ext/ripper/depend (ripper.c): process after bison with sed. [ruby-dev:32204] * ruby.c (proc_options): use yydebug in cmdline_options. * ruby.c (process_options): set yydebug flag of parser. * parse.y (yydebug): moved into struct parser_params. * parse.y (rb_parser_get_yydebug, rb_parser_set_yydebug): parser generic methods. * */Makefile.sub (parse.c): moved to common.mk. * tool/ytab.sed: comment out yydebug definition, and substitute yyerror with parser_yyerror. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/wince/Makefile.sub?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/ripper/depend?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/Makefile.in?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/win32/Makefile.sub?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bcc32/Makefile.sub?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/tool/ytab.sed?revision=13908&view=markup http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/tool/ytab.sed?r1=13908&r2=13907 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/common.mk?r1=13908&r2=13907 Index: ChangeLog =================================================================== --- ChangeLog (revision 13907) +++ ChangeLog (revision 13908) @@ -1,3 +1,22 @@ +Tue Nov 13 21:41:39 2007 Nobuyoshi Nakada <nobu@r...> + + * common.mk (parse.c), ext/ripper/depend (ripper.c): process after + bison with sed. [ruby-dev:32204] + + * ruby.c (proc_options): use yydebug in cmdline_options. + + * ruby.c (process_options): set yydebug flag of parser. + + * parse.y (yydebug): moved into struct parser_params. + + * parse.y (rb_parser_get_yydebug, rb_parser_set_yydebug): parser + generic methods. + + * */Makefile.sub (parse.c): moved to common.mk. + + * tool/ytab.sed: comment out yydebug definition, and substitute + yyerror with parser_yyerror. + Tue Nov 13 16:33:07 2007 Nobuyoshi Nakada <nobu@r...> * numeric.c (flodivmod): work around for inifinity. Index: common.mk =================================================================== --- common.mk (revision 13907) +++ common.mk (revision 13908) @@ -351,6 +351,11 @@ {$(VPATH)}parse.c: parse.y +{$(VPATH)}.y.c: + $(YACC) $(YFLAGS) -o y.tab.c $< + sed -f $(srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@ + @$(RM) y.tab.c + acosh.$(OBJEXT): {$(VPATH)}acosh.c alloca.$(OBJEXT): {$(VPATH)}alloca.c crypt.$(OBJEXT): {$(VPATH)}crypt.c @@ -628,10 +633,10 @@ incs: $(INSNS) node_name.inc -node_name.inc: {$(VPATH)}node.h +{$(VPATH)}node_name.inc: {$(VPATH)}node.h $(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@ -prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb +{$(VPATH)}prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(BASERUBY) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $@ ext_prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $(RBCONFIG) Index: win32/Makefile.sub =================================================================== --- win32/Makefile.sub (revision 13907) +++ win32/Makefile.sub (revision 13908) @@ -578,11 +578,6 @@ lex.c: {$(srcdir)}lex.c.blt copy $(?:/=\) $@ -{$(srcdir)}.y.c: - $(YACC) $(YFLAGS) $(<:\=/) - sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@ - @del y.tab.c - $(OBJS): {$(hdrdir)/ruby}win32.h dir.$(OBJEXT) win32.$(OBJEXT): {$(srcdir)}win32/dir.h Index: parse.y =================================================================== --- parse.y (revision 13907) +++ parse.y (revision 13908) @@ -240,6 +240,8 @@ rb_encoding *enc; rb_encoding *utf8; + int parser_yydebug; + #ifndef RIPPER /* Ruby core only */ char *parser_ruby_sourcefile; /* current source file */ @@ -282,9 +284,7 @@ static int parser_yyerror(struct parser_params*, const char*); #define yyerror(msg) parser_yyerror(parser, msg) -#define YYPARSE_PARAM parser_v -#define YYLEX_PARAM parser_v -#define parser ((struct parser_params*)parser_v) +#define YYLEX_PARAM parser #define ruby_eval_tree (parser->parser_eval_tree) #define ruby_eval_tree_begin (parser->parser_eval_tree_begin) @@ -317,6 +317,7 @@ #define ruby__end__seen (parser->parser_ruby__end__seen) #define ruby_sourceline (parser->parser_ruby_sourceline) #define ruby_sourcefile (parser->parser_ruby_sourcefile) +#define yydebug (parser->parser_yydebug) #ifdef RIPPER #else #define ruby_debug_lines (parser->debug_lines) @@ -326,7 +327,6 @@ #ifndef RIPPER #define yyparse ruby_yyparse -#define yydebug ruby_yydebug static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE); #define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, type, a1, a2, a3) @@ -489,7 +489,6 @@ #define dispatch5(n,a,b,c,d,e) ripper_dispatch5(parser, TOKEN_PASTE(ripper_id_, n), a, b, c, d, e) #define yyparse ripper_yyparse -#define yydebug ripper_yydebug static VALUE ripper_intern(const char*); static VALUE ripper_id2sym(ID); @@ -587,6 +586,7 @@ %} %pure_parser +%parse-param {struct parser_params *parser} %union { VALUE val; @@ -9141,6 +9141,9 @@ xfree(p); } +VALUE rb_parser_get_yydebug(VALUE); +VALUE rb_parser_set_yydebug(VALUE, VALUE); + #ifndef RIPPER static struct parser_params * parser_new(void) @@ -9192,6 +9195,37 @@ return rb_enc_from_encoding(parser->enc); } +/* + * call-seq: + * ripper.yydebug -> true or false + * + * Get yydebug. + */ +VALUE +rb_parser_get_yydebug(VALUE self) +{ + struct parser_params *parser; + + Data_Get_Struct(self, struct parser_params, parser); + return yydebug ? Qtrue : Qfalse; +} + +/* + * call-seq: + * ripper.yydebug = flag + * + * Set yydebug. + */ +VALUE +rb_parser_set_yydebug(VALUE self, VALUE flag) +{ + struct parser_params *parser; + + Data_Get_Struct(self, struct parser_params, parser); + yydebug = RTEST(flag); + return flag; +} + #ifdef YYMALLOC #define HEAPCNT(n, size) ((n) * (size) / sizeof(YYSTYPE)) #define NEWHEAP() rb_node_newnode(NODE_ALLOCA, 0, (VALUE)parser->heap, 0) @@ -9554,31 +9588,6 @@ return Qnil; } -/* - * call-seq: - * Ripper.yydebug -> true or false - * - * Get yydebug. - */ -static VALUE -ripper_s_get_yydebug(VALUE self) -{ - return ripper_yydebug ? Qtrue : Qfalse; -} - -/* - * call-seq: - * Ripper.yydebug = flag - * - * Set yydebug. - */ -static VALUE -ripper_s_set_yydebug(VALUE self, VALUE flag) -{ - ripper_yydebug = RTEST(flag); - return flag; -} - extern VALUE rb_thread_pass(void); struct ripper_args { @@ -9704,8 +9713,6 @@ Ripper = rb_define_class("Ripper", rb_cObject); rb_define_const(Ripper, "Version", rb_str_new2(RIPPER_VERSION)); - rb_define_singleton_method(Ripper, "yydebug", ripper_s_get_yydebug, 0); - rb_define_singleton_method(Ripper, "yydebug=", ripper_s_set_yydebug, 1); rb_define_alloc_func(Ripper, ripper_s_allocate); rb_define_method(Ripper, "initialize", ripper_initialize, -1); rb_define_method(Ripper, "parse", ripper_parse, 0); @@ -9713,6 +9720,8 @@ rb_define_method(Ripper, "lineno", ripper_lineno, 0); rb_define_method(Ripper, "end_seen?", rb_parser_end_seen_p, 0); rb_define_method(Ripper, "encoding", rb_parser_encoding, 0); + rb_define_method(Ripper, "yydebug", rb_parser_get_yydebug, 0); + rb_define_method(Ripper, "yydebug=", rb_parser_set_yydebug, 1); #ifdef RIPPER_DEBUG rb_define_method(rb_mKernel, "assert_Qundef", ripper_assert_Qundef, 2); rb_define_method(rb_mKernel, "rawVALUE", ripper_value, 1); Index: Makefile.in =================================================================== --- Makefile.in (revision 13907) +++ Makefile.in (revision 13908) @@ -177,9 +177,6 @@ cp $@ $(srcdir)/lex.c.blt; \ fi -.y.c: - $(YACC) $(YFLAGS) -o $@ $< - .c.@OBJEXT@: $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c $< Index: ext/ripper/depend =================================================================== --- ext/ripper/depend (revision 13907) +++ ext/ripper/depend (revision 13908) @@ -8,7 +8,9 @@ ripper.o: ripper.c lex.c eventids1.c eventids2.c eventids2table.c .y.c: - $(BISON) -t -v -o$@ $< + $(BISON) -t -v -oy.tab.c $< + sed -f $(top_srcdir)/tool/ytab.sed -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@ + @$(RM) y.tab.c all: check static: check Index: bcc32/Makefile.sub =================================================================== --- bcc32/Makefile.sub (revision 13907) +++ bcc32/Makefile.sub (revision 13908) @@ -209,11 +209,6 @@ .rc.res: $(RC) $(RFLAGS) -I. -I$(<D). $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:/=\) -.y.c: - $(YACC) $(YFLAGS) $(<:\=/) - sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $(@F) - @del y.tab.c - all: $(srcdir)/bcc32/Makefile.sub $(srcdir)/common.mk ruby: $(PROGRAM) Index: ruby.c =================================================================== --- ruby.c (revision 13907) +++ ruby.c (revision 13908) @@ -61,7 +61,8 @@ /* TODO: move to VM */ VALUE ruby_debug = Qfalse; VALUE ruby_verbose = Qfalse; -extern int ruby_yydebug; +VALUE rb_parser_get_yydebug(VALUE); +VALUE rb_parser_set_yydebug(VALUE, VALUE); char *ruby_inplace_mode = 0; @@ -593,7 +594,7 @@ goto reswitch; case 'y': - ruby_yydebug = 1; + opt->yydebug = 1; s++; goto reswitch; @@ -838,7 +839,7 @@ ruby_verbose = Qtrue; } else if (strcmp("yydebug", s) == 0) - ruby_yydebug = 1; + opt->yydebug = 1; else if (strcmp("help", s) == 0) { usage(origarg.argv[0]); rb_exit(EXIT_SUCCESS); @@ -993,6 +994,7 @@ ruby_init_loadpath(); ruby_init_gems(opt); parser = rb_parser_new(); + if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue); if (opt->e_script) { if (opt->enc_index >= 0) rb_enc_associate_index(opt->e_script, opt->enc_index); Index: wince/Makefile.sub =================================================================== --- wince/Makefile.sub (revision 13907) +++ wince/Makefile.sub (revision 13908) @@ -530,11 +530,6 @@ lex.c: {$(srcdir)}lex.c.blt copy $(?:/=\) $@ -{$(srcdir)}.y.c: - $(YACC) $(YFLAGS) $(<:\=/) - sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@ - @del y.tab.c - !include $(srcdir)/common.mk $(OBJS): {$(srcdir)}win32/win32.h Index: tool/ytab.sed =================================================================== --- tool/ytab.sed (revision 0) +++ tool/ytab.sed (revision 13908) @@ -0,0 +1,10 @@ +#!/bin/sed -f +/^int yydebug;/{ +i\ +#ifndef yydebug +a\ +#endif +} +s/\<\(yyerror[ ]*([ ]*parser,\)/parser_\1/ +s!^ *extern char \*getenv();!/* & */! +s/^\(#.*\)".*\.tab\.c"/\1"parse.c"/ Property changes on: tool/ytab.sed ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml