summaryrefslogtreecommitdiff
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 ()
tree6d7fb057c672aca651198938799560f65bc96459
parent5c725ba9fecc9775710aa05b5eaab1c5062ae165 (diff)
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
-rw-r--r--ChangeLog7
-rw-r--r--defs/keywords4
-rw-r--r--defs/lex.c.src4
-rw-r--r--lex.c.blt4
-rw-r--r--parse.y12
-rw-r--r--test/ruby/test_syntax.rb24
6 files changed, 44 insertions, 11 deletions
@@ -1,3 +1,10 @@
Wed Mar 16 21:39:39 2016 NARUSE, Yui <[email protected]>
* enc/trans/JIS: update Unicode's notice. [Bug #11844]
@@ -13,7 +13,7 @@ __LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END
__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END
BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END
END, {keyword_END, keyword_END}, EXPR_END
-alias, {keyword_alias, keyword_alias}, EXPR_FNAME
and, {keyword_and, keyword_and}, EXPR_VALUE
begin, {keyword_begin, keyword_begin}, EXPR_BEG
break, {keyword_break, keyword_break}, EXPR_MID
@@ -43,7 +43,7 @@ self, {keyword_self, keyword_self}, EXPR_END
super, {keyword_super, keyword_super}, EXPR_ARG
then, {keyword_then, keyword_then}, EXPR_BEG
true, {keyword_true, keyword_true}, EXPR_END
-undef, {keyword_undef, keyword_undef}, EXPR_FNAME
unless, {keyword_unless, modifier_unless}, EXPR_VALUE
until, {keyword_until, modifier_until}, EXPR_VALUE
when, {keyword_when, keyword_when}, EXPR_VALUE
@@ -13,7 +13,7 @@ __LINE__, {keyword__LINE__, keyword__LINE__}, EXPR_END
__FILE__, {keyword__FILE__, keyword__FILE__}, EXPR_END
BEGIN, {keyword_BEGIN, keyword_BEGIN}, EXPR_END
END, {keyword_END, keyword_END}, EXPR_END
-alias, {keyword_alias, keyword_alias}, EXPR_FNAME
and, {keyword_and, keyword_and}, EXPR_VALUE
begin, {keyword_begin, keyword_begin}, EXPR_BEG
break, {keyword_break, keyword_break}, EXPR_MID
@@ -43,7 +43,7 @@ self, {keyword_self, keyword_self}, EXPR_END
super, {keyword_super, keyword_super}, EXPR_ARG
then, {keyword_then, keyword_then}, EXPR_BEG
true, {keyword_true, keyword_true}, EXPR_END
-undef, {keyword_undef, keyword_undef}, EXPR_FNAME
unless, {keyword_unless, modifier_unless}, EXPR_VALUE
until, {keyword_until, modifier_until}, EXPR_VALUE
when, {keyword_when, keyword_when}, EXPR_VALUE
@@ -243,7 +243,7 @@ rb_reserved_word (str, len)
#line 30 "defs/keywords"
{(int)offsetof(struct stringpool_t, stringpool_str27), {keyword_for, keyword_for}, EXPR_VALUE},
#line 46 "defs/keywords"
- {(int)offsetof(struct stringpool_t, stringpool_str28), {keyword_undef, keyword_undef}, EXPR_FNAME},
#line 37 "defs/keywords"
{(int)offsetof(struct stringpool_t, stringpool_str29), {keyword_or, keyword_or}, EXPR_VALUE},
#line 32 "defs/keywords"
@@ -275,7 +275,7 @@ rb_reserved_word (str, len)
#line 15 "defs/keywords"
{(int)offsetof(struct stringpool_t, stringpool_str43), {keyword_END, keyword_END}, EXPR_END},
#line 16 "defs/keywords"
- {(int)offsetof(struct stringpool_t, stringpool_str44), {keyword_alias, keyword_alias}, EXPR_FNAME},
#line 14 "defs/keywords"
{(int)offsetof(struct stringpool_t, stringpool_str45), {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
#line 23 "defs/keywords"
@@ -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_MAX_STATE
};
/* examine combinations */
@@ -90,6 +91,7 @@ enum lex_state_e {
DEF_EXPR(CLASS),
DEF_EXPR(LABEL),
DEF_EXPR(LABELED),
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
{
/*%%%*/
$$ = NEW_ALIAS($2, $4);
@@ -1971,7 +1973,7 @@ undef_list : fitem
$$ = rb_ary_new3(1, $1);
%*/
}
- | undef_list ',' {SET_LEX_STATE(EXPR_FNAME);} 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);
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)) {
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",
};
static VALUE
@@ -790,6 +790,30 @@ eom
end
end
private
def not_label(x) @result = x; @not_label ||= nil end