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

ruby-changes:15486

From: nobu <ko1@a...>
Date: Sun, 18 Apr 2010 12:32:22 +0900 (JST)
Subject: [ruby-changes:15486] Ruby:r27387 (trunk): * parse.y (string_content): preserve cond_stack and cmdarg_stack.

nobu	2010-04-18 12:32:06 +0900 (Sun, 18 Apr 2010)

  New Revision: 27387

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27387

  Log:
    * parse.y (string_content): preserve cond_stack and cmdarg_stack.
      [ruby-core:29579]

  Modified files:
    trunk/ChangeLog
    trunk/bootstraptest/test_syntax.rb
    trunk/parse.y

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27386)
+++ ChangeLog	(revision 27387)
@@ -1,3 +1,8 @@
+Sun Apr 18 12:32:03 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (string_content): preserve cond_stack and cmdarg_stack.
+	  [ruby-core:29579]
+
 Sun Apr 18 05:50:58 2010  Aaron Patterson <aaron@t...>
 
 	* ext/psych/lib/psych/visitors/yaml_tree.rb: defaulting binary string
Index: bootstraptest/test_syntax.rb
===================================================================
--- bootstraptest/test_syntax.rb	(revision 27386)
+++ bootstraptest/test_syntax.rb	(revision 27387)
@@ -884,3 +884,9 @@
     e
   }
 }, '[ruby-dev:39861]'
+
+bug1240 = '[ruby-core:22637]'
+assert_valid_syntax('x y { "#{}".z { } }', bug1240)
+assert_valid_syntax('x y { "#{}".z do end }', bug1240)
+
+assert_valid_syntax('y "#{a 1}" do end', '[ruby-core:29579]')
Index: parse.y
===================================================================
--- parse.y	(revision 27386)
+++ parse.y	(revision 27387)
@@ -4030,18 +4030,26 @@
 		    }
 		| tSTRING_DBEG
 		    {
+			$<num>1 = cond_stack;
+			$<num>$ = cmdarg_stack;
+			cond_stack = 0;
+			cmdarg_stack = 0;
+		    }
+		    {
 			$<node>$ = lex_strterm;
 			lex_strterm = 0;
 			lex_state = EXPR_BEG;
 		    }
 		  compstmt '}'
 		    {
-			lex_strterm = $<node>2;
+			cond_stack = $<num>1;
+			cmdarg_stack = $<num>2;
+			lex_strterm = $<node>3;
 		    /*%%%*/
-			if ($3) $3->flags &= ~NODE_FL_NEWLINE;
-			$$ = new_evstr($3);
+			if ($4) $4->flags &= ~NODE_FL_NEWLINE;
+			$$ = new_evstr($4);
 		    /*%
-			$$ = dispatch1(string_embexpr, $3);
+			$$ = dispatch1(string_embexpr, $4);
 		    %*/
 		    }
 		;
@@ -5869,8 +5877,6 @@
 	    pushback(c);
 	    return tSTRING_DVAR;
 	  case '{':
-	    COND_PUSH(0);
-	    CMDARG_PUSH(0);
 	    return tSTRING_DBEG;
 	}
 	tokadd('#');
@@ -6068,8 +6074,6 @@
 		pushback(c);
 		return tSTRING_DVAR;
 	      case '{':
-		COND_PUSH(0);
-		CMDARG_PUSH(0);
 		return tSTRING_DBEG;
 	    }
 	    tokadd('#');

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

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