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

ruby-changes:15592

From: nobu <ko1@a...>
Date: Mon, 26 Apr 2010 12:43:05 +0900 (JST)
Subject: [ruby-changes:15592] Ruby:r27498 (trunk): * parse.y (warn_balanced): warn according to last state.

nobu	2010-04-26 12:42:45 +0900 (Mon, 26 Apr 2010)

  New Revision: 27498

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

  Log:
    * parse.y (warn_balanced): warn according to last state.

  Modified files:
    trunk/ChangeLog
    trunk/parse.y

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27497)
+++ ChangeLog	(revision 27498)
@@ -1,3 +1,7 @@
+Mon Apr 26 12:42:43 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (warn_balanced): warn according to last state.
+
 Mon Apr 26 09:05:30 2010  NARUSE, Yui  <naruse@r...>
 
 	* ext/json: Update to JSON 1.4.1.
Index: parse.y
===================================================================
--- parse.y	(revision 27497)
+++ parse.y	(revision 27498)
@@ -61,6 +61,7 @@
     EXPR_BEG,			/* ignore newline, +/- is a sign. */
     EXPR_END,			/* newline significant, +/- is an operator. */
     EXPR_ENDARG,		/* ditto, and unbound braces. */
+    EXPR_ENDFN, 		/* ditto, and unbound braces. */
     EXPR_ARG,			/* newline significant, +/- is an operator. */
     EXPR_CMDARG,		/* newline significant, +/- is an operator. */
     EXPR_MID,			/* newline significant, +/- is an operator. */
@@ -1775,12 +1776,12 @@
 		| tFID
 		| op
 		    {
-			lex_state = EXPR_END;
+			lex_state = EXPR_ENDFN;
 			$$ = $1;
 		    }
 		| reswords
 		    {
-			lex_state = EXPR_END;
+			lex_state = EXPR_ENDFN;
 		    /*%%%*/
 			$$ = $<id>1;
 		    /*%
@@ -2964,7 +2965,7 @@
 		| k_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
 		    {
 			in_single++;
-			lex_state = EXPR_END; /* force for args */
+			lex_state = EXPR_ENDFN; /* force for args */
 			local_push(0);
 		    }
 		  f_arglist
@@ -6474,7 +6475,7 @@
 }
 
 #define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
-#define IS_END() (lex_state == EXPR_END || lex_state == EXPR_ENDARG)
+#define IS_END() (lex_state == EXPR_END || lex_state == EXPR_ENDARG || lex_state == EXPR_ENDFN)
 #define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_VALUE || lex_state == EXPR_CLASS)
 #define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c))
 
@@ -6486,7 +6487,7 @@
 #define ambiguous_operator(op, syn) dispatch2(operator_ambiguous, ripper_intern(op), rb_str_new_cstr(syn))
 #endif
 #define warn_balanced(op, syn) \
-    (lex_state != EXPR_DOT && lex_state != EXPR_FNAME && \
+    (last_state != EXPR_DOT && last_state != EXPR_FNAME && \
      space_seen && !ISSPACE(c) && \
      (ambiguous_operator(op, syn), 0))
 
@@ -6525,6 +6526,7 @@
     cmd_state = command_start;
     command_start = FALSE;
   retry:
+    last_state = lex_state;
     switch (c = nextc()) {
       case '\0':		/* NUL */
       case '\004':		/* ^D */
@@ -6730,6 +6732,7 @@
 	return '=';
 
       case '<':
+	last_state = lex_state;
 	c = nextc();
 	if (c == '<' &&
 	    lex_state != EXPR_DOT &&
@@ -6793,7 +6796,7 @@
 
       case '`':
 	if (lex_state == EXPR_FNAME) {
-	    lex_state = EXPR_END;
+	    lex_state = EXPR_ENDFN;
 	    return c;
 	}
 	if (lex_state == EXPR_DOT) {
@@ -7394,7 +7397,7 @@
 	    CMDARG_PUSH(0);
 	    return tLAMBEG;
 	}
-	if (IS_ARG() || lex_state == EXPR_END)
+	if (IS_ARG() || lex_state == EXPR_END || lex_state == EXPR_ENDFN)
 	    c = '{';          /* block (primary) */
 	else if (lex_state == EXPR_ENDARG)
 	    c = tLBRACE_ARG;  /* block (expr) */
@@ -7505,7 +7508,6 @@
 	return '%';
 
       case '$':
-	last_state = lex_state;
 	lex_state = EXPR_END;
 	newtok();
 	c = nextc();
@@ -7702,11 +7704,6 @@
 		}
 	    }
 
-	    if (lex_state == EXPR_FNAME) {
-		const char *p = lex_p, *pe = lex_pend;
-		while (p < pe && (*p == ' ' || *p == '\t')) p++;
-		if (p < pe && *p != '(') lex_p = p;
-	    }
 	    if ((lex_state == EXPR_BEG && !cmd_state) ||
 		IS_ARG()) {
 		if (peek(':') && !(lex_p + 1 < lex_pend && lex_p[1] == ':')) {
@@ -7762,6 +7759,9 @@
 		    lex_state = EXPR_ARG;
 		}
 	    }
+	    else if (lex_state == EXPR_FNAME) {
+		lex_state = EXPR_ENDFN;
+	    }
 	    else {
 		lex_state = EXPR_END;
 	    }

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

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