diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | parse.y | 22 | ||||
-rw-r--r-- | test/ruby/test_parse.rb | 24 |
3 files changed, 15 insertions, 35 deletions
@@ -1,3 +1,7 @@ +Wed Apr 21 11:31:35 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_yylex): abandoned EXPR_VCALL. + Wed Apr 21 03:17:17 2010 NARUSE, Yui <naruse@ruby-lang.org> * io.c (io_getc): set read_encoding to resulted one character @@ -68,7 +68,6 @@ enum lex_state_e { 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 @@ parser_prepare(struct parser_params *parser) } #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 @@ parser_yylex(struct parser_params *parser) 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 @@ parser_yylex(struct parser_params *parser) 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 @@ parser_yylex(struct parser_params *parser) 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 @@ parser_yylex(struct parser_params *parser) } 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 @@ parser_yylex(struct parser_params *parser) 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; } diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index aa664ebd44..49ecfc56ed 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -823,28 +823,4 @@ x = __ENCODING__ 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 |