diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-06-01 06:47:32 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-06-01 06:47:32 +0000 |
commit | 353650e6b486482a256250611d73b668f3fa8dbc (patch) | |
tree | 9189cade96efd9e1796dcb21b5b65983e1fe4233 /parse.y | |
parent | df2c6aef1e202ff263090009f782324dd74b5417 (diff) |
* parse.y (yylex): fixed 'print CGI::bar() {}, "\n"' syntax
breakage, adding new lex_state status. sigh. [new]
* file.c (rb_file_s_unlink): should not allow if $SAFE >= 2.
* range.c (Init_Range): define "to_ary".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -52,6 +52,7 @@ static enum lex_state { EXPR_END, /* newline significant, +/- is a operator. */ EXPR_ARG, /* newline significant, +/- is a operator. */ EXPR_CMDARG, /* newline significant, +/- is a operator. */ + EXPR_ENDARG, /* newline significant, +/- is a operator. */ EXPR_MID, /* newline significant, +/- is a operator. */ EXPR_FNAME, /* ignore newline, no reserved words. */ EXPR_DOT, /* right after `.' or `::', no reserved words. */ @@ -1089,13 +1090,13 @@ command_args : { } open_args : call_args - | tLPAREN_ARG ')' + | tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')' { rb_warning("%s (...) interpreted as method call", rb_id2name(last_id)); $$ = 0; } - | tLPAREN_ARG call_args2 ')' + | tLPAREN_ARG call_args2 {lex_state = EXPR_ENDARG;} ')' { rb_warning("%s (...) interpreted as method call", rb_id2name(last_id)); @@ -1185,7 +1186,7 @@ primary : literal } fixpos($$, $2); } - | tLPAREN_ARG expr ')' + | tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} ')' { rb_warning("%s (...) interpreted as command call", rb_id2name(last_id)); $$ = $2; @@ -3008,7 +3009,9 @@ yylex() case '<': c = nextc(); if (c == '<' && - lex_state != EXPR_END && lex_state != EXPR_CLASS && + lex_state != EXPR_END && + lex_state != EXPR_ENDARG + && lex_state != EXPR_CLASS && (!IS_ARG() || space_seen)) { int c2 = nextc(); int indent = 0; @@ -3067,7 +3070,7 @@ yylex() return parse_qstring(c,0); case '?': - if (lex_state == EXPR_END) { + if (lex_state == EXPR_END || lex_state == EXPR_ENDARG) { lex_state = EXPR_BEG; return '?'; } @@ -3390,7 +3393,7 @@ yylex() return tCOLON2; } pushback(c); - if (lex_state == EXPR_END || ISSPACE(c)) { + if (lex_state == EXPR_END || lex_state == EXPR_ENDARG || ISSPACE(c)) { lex_state = EXPR_BEG; return ':'; } @@ -3484,10 +3487,10 @@ yylex() case '{': if (!IS_ARG()) { - if (lex_state != EXPR_END) - c = tLBRACE; - if (space_seen && CMDARG_P()) + if (space_seen && lex_state == EXPR_ENDARG) c = tLBRACE_ARG; + if (lex_state != EXPR_END && lex_state != EXPR_ENDARG) + c = tLBRACE; } COND_PUSH(0); CMDARG_PUSH(0); |