[前][次][番号順一覧][スレッド一覧]

ruby-changes:2475

From: ko1@a...
Date: 19 Nov 2007 16:10:23 +0900
Subject: [ruby-changes:2475] matz - Ruby:r13966 (trunk): * parse.y (parser_yylex): should clear parser->tokp as well.

matz	2007-11-19 16:10:09 +0900 (Mon, 19 Nov 2007)

  New Revision: 13966

  Modified files:
    trunk/ChangeLog
    trunk/ext/ripper/lib/ripper/lexer.rb
    trunk/file.c
    trunk/parse.y
    trunk/test/ripper/dummyparser.rb
    trunk/test/ripper/test_files.rb
    trunk/test/ripper/test_parser_events.rb

  Log:
    * parse.y (parser_yylex): should clear parser->tokp as well.
      [ruby-dev:32250]
    
    * parse.y: remove NEED_ASSOC that break test_parser_events.
    
    * parse.y (parser_yylex): should not decrement line numbers at the
      end of file.
    
    * file.c (rb_find_file_ext): search .rb files first through in the
      loadpath.

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ripper/dummyparser.rb?r1=13966&r2=13965
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/file.c?r1=13966&r2=13965
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=13966&r2=13965
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13966&r2=13965
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ripper/test_files.rb?r1=13966&r2=13965
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ripper/test_parser_events.rb?r1=13966&r2=13965
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/ripper/lib/ripper/lexer.rb?r1=13966&r2=13965

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13965)
+++ ChangeLog	(revision 13966)
@@ -48,6 +48,19 @@
 
 	* ext/win32ole/win32ole.c (ole_invoke): bug fix. [ruby-talk:279100]
 
+Sat Nov 17 23:21:15 2007  Yukihiro Matsumoto  <matz@r...>
+
+	* parse.y (parser_yylex): should clear parser->tokp as well.
+	  [ruby-dev:32250]
+
+	* parse.y: remove NEED_ASSOC that break test_parser_events.
+
+	* parse.y (parser_yylex): should not decrement line numbers at the
+	  end of file.
+
+	* file.c (rb_find_file_ext): search .rb files first through in the
+	  loadpath.
+
 Fri Nov 16 23:31:18 2007  Yukihiro Matsumoto  <matz@r...>
 
 	* bignum.c (rb_big_odd_p): new method added.  a patch from Tadashi
Index: parse.y
===================================================================
--- parse.y	(revision 13965)
+++ parse.y	(revision 13966)
@@ -565,15 +565,6 @@
 # define PARSER_ARG ruby_sourcefile, ruby_sourceline,
 #endif
 
-#ifdef RIPPER
-#define NEED_ASSOC(cons, car, cdr) do {			      \
-	if ((cons) == (car) || (cons) == (cdr) ||	      \
-	    TYPE(cons) != T_ARRAY || RARRAY_LEN(cons) != 2) { \
-	    (cons) = rb_assoc_new((car), (cdr));	      \
-	}						      \
-    } while (0)
-#endif
-
 /* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150,
    for instance).  This is too low for Ruby to parse some files, such as
    date/format.rb, therefore bump the value up to at least Bison's default. */
@@ -4413,7 +4404,6 @@
 			$$ = list_append(NEW_LIST($1), $3);
 		    /*%
 			$$ = dispatch2(assoc_new, $1, $3);
-			NEED_ASSOC($$, $1, $3);
 		    %*/
 		    }
 		| tLABEL arg_value
@@ -4422,7 +4412,6 @@
 			$$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
 		    /*%
 			$$ = dispatch2(assoc_new, $1, $2);
-			NEED_ASSOC($$, $1, $2);
 		    %*/
 		    }
 		;
@@ -6003,21 +5992,6 @@
     cmd_state = command_start;
     command_start = Qfalse;
   retry:
-#ifdef RIPPER
-    while ((c = nextc())) {
-        switch (c) {
-          case ' ': case '\t': case '\f': case '\r':
-          case '\13': /* '\v' */
-            space_seen++;
-            break;
-          default:
-            goto outofloop;
-        }
-    }
-  outofloop:
-    pushback(c);
-    ripper_dispatch_scan_event(parser, tSP);
-#endif
     switch (c = nextc()) {
       case '\0':		/* NUL */
       case '\004':		/* ^D */
@@ -6029,6 +6003,20 @@
       case ' ': case '\t': case '\f': case '\r':
       case '\13': /* '\v' */
 	space_seen++;
+#ifdef RIPPER
+	while ((c = nextc())) {
+	    switch (c) {
+	      case ' ': case '\t': case '\f': case '\r':
+	      case '\13': /* '\v' */
+		break;
+	      default:
+		goto outofloop;
+	    }
+	}
+      outofloop:
+	pushback(c);
+	ripper_dispatch_scan_event(parser, tSP);
+#endif
 	goto retry;
 
       case '#':		/* it's a comment */
@@ -6070,16 +6058,22 @@
 		space_seen++;
 		break;
 	      case '.': {
-		if ((c = nextc()) != '.') {
-		    pushback(c);
-		    pushback('.');
+		  if ((c = nextc()) != '.') {
+		      pushback(c);
+		      pushback('.');
 		    goto retry;
-		}
+		  }
 	      }
 	      default:
+		--ruby_sourceline;
+	      case -1:		/* EOF no decrement*/
 		lex_nextline = lex_lastline;
 		lex_p = lex_pend;
-		--ruby_sourceline;
+#ifdef RIPPER
+		if (c != -1) {
+		    parser->tokp = lex_p;
+		}
+#endif
 		goto normal_newline;
 	    }
 	}
Index: ext/ripper/lib/ripper/lexer.rb
===================================================================
--- ext/ripper/lib/ripper/lexer.rb	(revision 13965)
+++ ext/ripper/lib/ripper/lexer.rb	(revision 13966)
@@ -23,7 +23,7 @@
   #   require 'ripper'
   #   require 'pp'
   #
-  #   p Ripper.scan("def m(a) nil end")
+  #   p Ripper.lex("def m(a) nil end")
   #     #=> [[[1,  0], :on_kw,     "def"],
   #          [[1,  3], :on_sp,     " "  ],
   #          [[1,  4], :on_ident,  "m"  ],
Index: test/ripper/test_parser_events.rb
===================================================================
--- test/ripper/test_parser_events.rb	(revision 13965)
+++ test/ripper/test_parser_events.rb	(revision 13966)
@@ -495,4 +495,4 @@
 end
 
 rescue LoadError
-end
\ No newline at end of file
+end
Index: test/ripper/test_files.rb
===================================================================
--- test/ripper/test_files.rb	(revision 13965)
+++ test/ripper/test_files.rb	(revision 13966)
@@ -22,4 +22,4 @@
 
 rescue LoadError
 end
-  
\ No newline at end of file
+  
Index: test/ripper/dummyparser.rb
===================================================================
--- test/ripper/dummyparser.rb	(revision 13965)
+++ test/ripper/dummyparser.rb	(revision 13966)
@@ -30,7 +30,7 @@
   end
 
   def prepend(items)
-    @list[0,0] = items
+    @list.unshift items
   end
 
   def to_s
@@ -98,32 +98,44 @@
     args
   end
 
-  def on_arglist_new
+  def on_args_new
     NodeList.new
   end
 
-  def on_arglist_add(list, arg)
+  def on_args_add(list, arg)
     list.push(arg)
   end
 
-  def on_arglist_add_block(list, blk)
-    list.push('&' + blk.to_s)
+  def on_args_add_block(list, blk)
+    if blk
+      list.push('&' + blk.to_s)
+    else
+      list
+    end
   end
 
-  def on_arglist_add_star(list, arg)
+  def on_args_add_star(list, arg)
     list.push('*' + arg.to_s)
   end
 
-  def on_arglist_prepend(list, args)
+  def on_args_prepend(list, args)
     list.prepend args
     list
   end
 
   def on_method_add_arg(m, arg)
+    if arg == nil
+      arg = on_args_new
+    end
     m.children.push arg
     m
   end
 
+  def on_method_add_block(m, b)
+    on_args_add_block(m.children, b)
+    m
+  end
+
   def on_assoc_new(a, b)
     Node.new('assoc', a, b)
   end
@@ -390,7 +402,7 @@
     Node.new('sclass', a, b)
   end
 
-  def on_space(a)
+  def on_sp(a)
     Node.new('space', a)
   end
 
@@ -514,4 +526,46 @@
     Node.new('zsuper')
   end
 
+  def on_backref(a)
+    a
+  end
+  def on_comma(a)
+    a
+  end
+  def on_gvar(a)
+    a
+  end
+  def on_ident(a)
+    a
+  end
+  def on_int(a)
+    a
+  end
+  def on_kw(a)
+    a
+  end
+  def on_lbrace(a)
+    a
+  end
+  def on_rbrace(a)
+    a
+  end
+  def on_lbracket(a)
+    a
+  end
+  def on_rbracket(a)
+    a
+  end
+  def on_lparen(a)
+    a
+  end
+  def on_rparen(a)
+    a
+  end
+  def on_op(a)
+    a
+  end
+  def on_semicolon(a)
+    a
+  end
 end
Index: file.c
===================================================================
--- file.c	(revision 13965)
+++ file.c	(revision 13966)
@@ -4197,16 +4197,16 @@
     if (!rb_load_path) return 0;
 
     Check_Type(rb_load_path, T_ARRAY);
-    for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
-	VALUE str = RARRAY_PTR(rb_load_path)[i];
+    for (j=0; ext[j]; j++) {
+	fname = rb_str_dup(*filep);
+	rb_str_cat2(fname, ext[j]);
+	OBJ_FREEZE(fname);
+	for (i=0;i<RARRAY_LEN(rb_load_path);i++) {
+	    VALUE str = RARRAY_PTR(rb_load_path)[i];
 
-	FilePathValue(str);
-	if (RSTRING_LEN(str) == 0) continue;
-	path = RSTRING_PTR(str);
-	for (j=0; ext[j]; j++) {
-	    fname = rb_str_dup(*filep);
-	    rb_str_cat2(fname, ext[j]);
-	    OBJ_FREEZE(fname);
+	    FilePathValue(str);
+	    if (RSTRING_LEN(str) == 0) continue;
+	    path = RSTRING_PTR(str);
 	    found = dln_find_file(StringValueCStr(fname), path);
 	    if (found && file_load_ok(found)) {
 		*filep = rb_str_new2(found);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]