ruby-changes:15524
From: nobu <ko1@a...>
Date: Wed, 21 Apr 2010 11:33:42 +0900 (JST)
Subject: [ruby-changes:15524] Ruby:r27427 (trunk): * parse.y (parser_yylex): abandoned EXPR_VCALL.
nobu 2010-04-21 11:31:40 +0900 (Wed, 21 Apr 2010) New Revision: 27427 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27427 Log: * parse.y (parser_yylex): abandoned EXPR_VCALL. Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_parse.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 27426) +++ ChangeLog (revision 27427) @@ -1,3 +1,7 @@ +Wed Apr 21 11:31:35 2010 Nobuyoshi Nakada <nobu@r...> + + * parse.y (parser_yylex): abandoned EXPR_VCALL. + Wed Apr 21 03:17:17 2010 NARUSE, Yui <naruse@r...> * io.c (io_getc): set read_encoding to resulted one character Index: parse.y =================================================================== --- parse.y (revision 27426) +++ parse.y (revision 27427) @@ -68,7 +68,6 @@ EXPR_DOT, /* right after `.' or `::', no reserved words. */ EXPR_CLASS, /* immediate after `class', no here document. */ EXPR_VALUE, /* alike EXPR_BEG but label is disallowed. */ - EXPR_VCALL, /* immediate after vcall */ EXPR_MAX_STATE }; @@ -6415,9 +6414,9 @@ } #define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG) -#define IS_END() (lex_state == EXPR_END || lex_state == EXPR_ENDARG || lex_state == EXPR_VCALL) +#define IS_END() (lex_state == EXPR_END || lex_state == EXPR_ENDARG) #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() || lex_state == EXPR_VCALL) && space_seen && !ISSPACE(c)) +#define IS_SPCARG(c) (IS_ARG() && space_seen && !ISSPACE(c)) static int parser_yylex(struct parser_params *parser) @@ -6662,7 +6661,8 @@ if (c == '<' && lex_state != EXPR_DOT && lex_state != EXPR_CLASS && - (!(IS_ARG() || IS_END()) || space_seen)) { + !IS_END() && + (!IS_ARG() || space_seen)) { int token = heredoc_identifier(); if (token) return token; } @@ -6737,11 +6737,11 @@ return tSTRING_BEG; case '?': - c = nextc(); - if (IS_END() && (!space_seen || ISSPACE(c))) { + if (IS_END()) { lex_state = EXPR_VALUE; return '?'; } + c = nextc(); if (c == -1) { compile_error(PARSER_ARG "incomplete character syntax"); return 0; @@ -7315,7 +7315,7 @@ CMDARG_PUSH(0); return tLAMBEG; } - if (IS_ARG() || lex_state == EXPR_END || lex_state == EXPR_VCALL) + if (IS_ARG() || lex_state == EXPR_END) c = '{'; /* block (primary) */ else if (lex_state == EXPR_ENDARG) c = tLBRACE_ARG; /* block (expr) */ @@ -7623,7 +7623,7 @@ } if ((lex_state == EXPR_BEG && !cmd_state) || - IS_ARG() || lex_state == EXPR_VCALL) { + IS_ARG()) { if (peek(':') && !(lex_p + 1 < lex_pend && lex_p[1] == ':')) { lex_state = EXPR_BEG; nextc(); @@ -7685,9 +7685,9 @@ ID ident = TOK_INTERN(!ENC_SINGLE(mb)); set_yylval_name(ident); - if (last_state != EXPR_DOT && last_state != EXPR_FNAME && is_local_id(ident)) { - lex_state = EXPR_VCALL; - } + if (last_state != EXPR_DOT && is_local_id(ident) && lvar_defined(ident)) { + lex_state = EXPR_END; + } } return result; } Index: test/ruby/test_parse.rb =================================================================== --- test/ruby/test_parse.rb (revision 27426) +++ test/ruby/test_parse.rb (revision 27427) @@ -823,28 +823,4 @@ c.instance_eval { remove_class_variable(:@var) } end end - - def result(arg = nil, &pro) - pro || arg - end - - def test_method_and_lvar - result = nil - bug3163 = '[ruby-core:29578]' - assert_equal(%[bug3163], (result %[bug3163]), bug3163) - assert_equal(/bug3163/x, (result /bug3163/x), bug3163) - pro = proc {} - assert_equal(pro, (result &pro), bug3163) - assert_equal(bug3163, (result *bug3163), bug3163) - f = g = nil - assert_raise(SyntaxError, bug3163) {eval("result ?f : g")} - assert_equal("123\n", eval("result <<FOO\n123\nFOO"), bug3163) - - bug3163_2 = '[ruby-core:29594]' - one = 1 - assert_equal(+1, (result +one), bug3163_2) - assert_equal(-1, (result -one), bug3163_2) - - assert_equal({:a => 1}, (result a: 1)) - end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/