summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-16 14:10:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-16 14:10:27 +0000
commitcb65717b458a65ed88f48af9ef0690939212f79b (patch)
tree6d7fb057c672aca651198938799560f65bc96459 /parse.y
parent5c725ba9fecc9775710aa05b5eaab1c5062ae165 (diff)
downloadruby-cb65717b458a65ed88f48af9ef0690939212f79b.tar.gz
parse.y: symbol literals for alias/undef
* defs/keywords (alias, undef): symbol literals are allowed. * parse.y (parse_percent): should parse symbol literals for alias and undef. [ruby-dev:47681] [Bug #8851] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y12
1 files changed, 7 insertions, 5 deletions
diff --git a/parse.y b/parse.y
index cb90c4617e..dbdcb95127 100644
--- a/parse.y
+++ b/parse.y
@@ -73,6 +73,7 @@ enum lex_state_bits {
EXPR_CLASS_bit, /* immediate after `class', no here document. */
EXPR_LABEL_bit, /* flag bit, label is allowed. */
EXPR_LABELED_bit, /* flag bit, just after a label. */
+ EXPR_FITEM_bit, /* symbol literal as FNAME. */
EXPR_MAX_STATE
};
/* examine combinations */
@@ -90,6 +91,7 @@ enum lex_state_e {
DEF_EXPR(CLASS),
DEF_EXPR(LABEL),
DEF_EXPR(LABELED),
+ DEF_EXPR(FITEM),
EXPR_VALUE = EXPR_BEG,
EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
@@ -1135,7 +1137,7 @@ stmt_or_begin : stmt
%*/
}
-stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME);} fitem
+stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
$$ = NEW_ALIAS($2, $4);
@@ -1971,7 +1973,7 @@ undef_list : fitem
$$ = rb_ary_new3(1, $1);
%*/
}
- | undef_list ',' {SET_LEX_STATE(EXPR_FNAME);} fitem
+ | undef_list ',' {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
{
/*%%%*/
$$ = block_append($1, NEW_UNDEF($4));
@@ -7781,7 +7783,7 @@ parse_percent(struct parser_params *parser, const int space_seen, const enum lex
case 's':
lex_strterm = NEW_STRTERM(str_ssym, term, paren);
- SET_LEX_STATE(EXPR_FNAME);
+ SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);
return tSYMBEG;
default:
@@ -7794,7 +7796,7 @@ parse_percent(struct parser_params *parser, const int space_seen, const enum lex
SET_LEX_STATE(EXPR_BEG);
return tOP_ASGN;
}
- if (IS_SPCARG(c)) {
+ if (IS_SPCARG(c) || (IS_lex_state(EXPR_FITEM) && c == 's')) {
goto quotation;
}
SET_LEX_STATE(IS_AFTER_OPERATOR() ? EXPR_ARG : EXPR_BEG);
@@ -9213,7 +9215,7 @@ id_is_var_gen(struct parser_params *parser, ID id)
static const char lex_state_names[][13] = {
"EXPR_BEG", "EXPR_END", "EXPR_ENDARG", "EXPR_ENDFN", "EXPR_ARG",
"EXPR_CMDARG", "EXPR_MID", "EXPR_FNAME", "EXPR_DOT", "EXPR_CLASS",
- "EXPR_LABEL", "EXPR_LABELED",
+ "EXPR_LABEL", "EXPR_LABELED","EXPR_FITEM",
};
static VALUE