* keywords, parse.y: separate EXPR_VALUE from EXPR_BEG.

fixed: [ruby-core:04310], [ruby-core:04368]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2005-02-08 13:39:47 +00:00
Родитель c1f29da23d
Коммит 891c4aa199
4 изменённых файлов: 40 добавлений и 50 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Tue Feb 8 22:38:28 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* keywords, parse.y: separate EXPR_VALUE from EXPR_BEG.
fixed: [ruby-core:04310], [ruby-core:04368]
Tue Feb 8 00:19:02 2005 Tanaka Akira <akr@m17n.org>
* lib/resolv.rb (Resolv::DNS::Name#subdomain_of?): new method.

Просмотреть файл

@ -8,27 +8,27 @@ __FILE__, {k__FILE__, k__FILE__}, EXPR_END
BEGIN, {klBEGIN, klBEGIN}, EXPR_END
END, {klEND, klEND}, EXPR_END
alias, {kALIAS, kALIAS}, EXPR_FNAME
and, {kAND, kAND}, EXPR_BEG
and, {kAND, kAND}, EXPR_VALUE
begin, {kBEGIN, kBEGIN}, EXPR_BEG
break, {kBREAK, kBREAK}, EXPR_MID
case, {kCASE, kCASE}, EXPR_BEG
case, {kCASE, kCASE}, EXPR_VALUE
class, {kCLASS, kCLASS}, EXPR_CLASS
def, {kDEF, kDEF}, EXPR_FNAME
defined?, {kDEFINED, kDEFINED}, EXPR_ARG
do, {kDO, kDO}, EXPR_BEG
else, {kELSE, kELSE}, EXPR_BEG
elsif, {kELSIF, kELSIF}, EXPR_BEG
elsif, {kELSIF, kELSIF}, EXPR_VALUE
end, {kEND, kEND}, EXPR_END
ensure, {kENSURE, kENSURE}, EXPR_BEG
false, {kFALSE, kFALSE}, EXPR_END
for, {kFOR, kFOR}, EXPR_BEG
if, {kIF, kIF_MOD}, EXPR_BEG
in, {kIN, kIN}, EXPR_BEG
module, {kMODULE, kMODULE}, EXPR_BEG
for, {kFOR, kFOR}, EXPR_VALUE
if, {kIF, kIF_MOD}, EXPR_VALUE
in, {kIN, kIN}, EXPR_VALUE
module, {kMODULE, kMODULE}, EXPR_VALUE
next, {kNEXT, kNEXT}, EXPR_MID
nil, {kNIL, kNIL}, EXPR_END
not, {kNOT, kNOT}, EXPR_BEG
or, {kOR, kOR}, EXPR_BEG
not, {kNOT, kNOT}, EXPR_VALUE
or, {kOR, kOR}, EXPR_VALUE
redo, {kREDO, kREDO}, EXPR_END
rescue, {kRESCUE, kRESCUE_MOD}, EXPR_MID
retry, {kRETRY, kRETRY}, EXPR_END
@ -38,10 +38,10 @@ super, {kSUPER, kSUPER}, EXPR_ARG
then, {kTHEN, kTHEN}, EXPR_BEG
true, {kTRUE, kTRUE}, EXPR_END
undef, {kUNDEF, kUNDEF}, EXPR_FNAME
unless, {kUNLESS, kUNLESS_MOD}, EXPR_BEG
until, {kUNTIL, kUNTIL_MOD}, EXPR_BEG
when, {kWHEN, kWHEN}, EXPR_BEG
while, {kWHILE, kWHILE_MOD}, EXPR_BEG
unless, {kUNLESS, kUNLESS_MOD}, EXPR_VALUE
until, {kUNTIL, kUNTIL_MOD}, EXPR_VALUE
when, {kWHEN, kWHEN}, EXPR_VALUE
while, {kWHILE, kWHILE_MOD}, EXPR_VALUE
yield, {kYIELD, kYIELD}, EXPR_ARG
%%
#endif

28
lex.c
Просмотреть файл

@ -1,5 +1,5 @@
/* C code produced by gperf version 2.7.2 */
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' /home/aamine/c/ruby/keywords */
/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' keywords */
struct kwtable {char *name; int id[2]; enum lex_state_e state;};
struct kwtable *rb_reserved_word _((const char *, unsigned int));
#ifndef RIPPER
@ -81,43 +81,43 @@ rb_reserved_word (str, len)
{""}, {""}, {""}, {""}, {""}, {""},
{"end", {kEND, kEND}, EXPR_END},
{"else", {kELSE, kELSE}, EXPR_BEG},
{"case", {kCASE, kCASE}, EXPR_BEG},
{"case", {kCASE, kCASE}, EXPR_VALUE},
{"ensure", {kENSURE, kENSURE}, EXPR_BEG},
{"module", {kMODULE, kMODULE}, EXPR_BEG},
{"elsif", {kELSIF, kELSIF}, EXPR_BEG},
{"module", {kMODULE, kMODULE}, EXPR_VALUE},
{"elsif", {kELSIF, kELSIF}, EXPR_VALUE},
{"def", {kDEF, kDEF}, EXPR_FNAME},
{"rescue", {kRESCUE, kRESCUE_MOD}, EXPR_MID},
{"not", {kNOT, kNOT}, EXPR_BEG},
{"not", {kNOT, kNOT}, EXPR_VALUE},
{"then", {kTHEN, kTHEN}, EXPR_BEG},
{"yield", {kYIELD, kYIELD}, EXPR_ARG},
{"for", {kFOR, kFOR}, EXPR_BEG},
{"for", {kFOR, kFOR}, EXPR_VALUE},
{"self", {kSELF, kSELF}, EXPR_END},
{"false", {kFALSE, kFALSE}, EXPR_END},
{"retry", {kRETRY, kRETRY}, EXPR_END},
{"return", {kRETURN, kRETURN}, EXPR_MID},
{"true", {kTRUE, kTRUE}, EXPR_END},
{"if", {kIF, kIF_MOD}, EXPR_BEG},
{"if", {kIF, kIF_MOD}, EXPR_VALUE},
{"defined?", {kDEFINED, kDEFINED}, EXPR_ARG},
{"super", {kSUPER, kSUPER}, EXPR_ARG},
{"undef", {kUNDEF, kUNDEF}, EXPR_FNAME},
{"break", {kBREAK, kBREAK}, EXPR_MID},
{"in", {kIN, kIN}, EXPR_BEG},
{"in", {kIN, kIN}, EXPR_VALUE},
{"do", {kDO, kDO}, EXPR_BEG},
{"nil", {kNIL, kNIL}, EXPR_END},
{"until", {kUNTIL, kUNTIL_MOD}, EXPR_BEG},
{"unless", {kUNLESS, kUNLESS_MOD}, EXPR_BEG},
{"or", {kOR, kOR}, EXPR_BEG},
{"until", {kUNTIL, kUNTIL_MOD}, EXPR_VALUE},
{"unless", {kUNLESS, kUNLESS_MOD}, EXPR_VALUE},
{"or", {kOR, kOR}, EXPR_VALUE},
{"next", {kNEXT, kNEXT}, EXPR_MID},
{"when", {kWHEN, kWHEN}, EXPR_BEG},
{"when", {kWHEN, kWHEN}, EXPR_VALUE},
{"redo", {kREDO, kREDO}, EXPR_END},
{"and", {kAND, kAND}, EXPR_BEG},
{"and", {kAND, kAND}, EXPR_VALUE},
{"begin", {kBEGIN, kBEGIN}, EXPR_BEG},
{"__LINE__", {k__LINE__, k__LINE__}, EXPR_END},
{"class", {kCLASS, kCLASS}, EXPR_CLASS},
{"__FILE__", {k__FILE__, k__FILE__}, EXPR_END},
{"END", {klEND, klEND}, EXPR_END},
{"BEGIN", {klBEGIN, klBEGIN}, EXPR_END},
{"while", {kWHILE, kWHILE_MOD}, EXPR_BEG},
{"while", {kWHILE, kWHILE_MOD}, EXPR_VALUE},
{""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
{""},
{"alias", {kALIAS, kALIAS}, EXPR_FNAME}

31
parse.y
Просмотреть файл

@ -63,7 +63,7 @@ enum lex_state_e {
EXPR_FNAME, /* ignore newline, no reserved words. */
EXPR_DOT, /* right after `.' or `::', no reserved words. */
EXPR_CLASS, /* immediate after `class', no here document. */
EXPR_TERNARY, /* alike EXPR_BEG but immediate after ternary op. */
EXPR_VALUE, /* alike EXPR_BEG but label is disallowed. */
};
# ifdef HAVE_LONG_LONG
@ -488,7 +488,7 @@ static void ripper_compile_error _((struct parser_params*, const char *fmt, ...)
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
%type <node> mrhs superclass block_call block_command
%type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg
%type <node> assoc_list assocs assoc kwargs undef_list backref string_dvar
%type <node> assoc_list assocs assoc undef_list backref string_dvar
%type <node> for_var block_var opt_block_var block_par
%type <node> brace_block cmd_brace_block do_block lhs none fitem
%type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node
@ -4066,10 +4066,6 @@ assoc_list : none
$$ = dispatch1(assoclist_from_args, $1);
%*/
}
| kwargs trailer
{
$$ = $1;
}
;
assocs : assoc
@ -4097,9 +4093,7 @@ assoc : arg_value tASSOC arg_value
$$ = dispatch2(assoc_new, $1, $3);
%*/
}
;
kwargs : tLABEL arg_value
| tLABEL arg_value
{
/*%%%*/
$$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
@ -4107,15 +4101,6 @@ kwargs : tLABEL arg_value
$$ = dispatch2(assoc_new, $1, $2);
%*/
}
| kwargs ',' tLABEL arg_value
{
/*%%%*/
$$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($3))), $4);
$$ = list_concat($1, $$);
/*%
rb_ary_push($$, dispatch2(assoc_new, $3, $4));
%*/
}
;
operation : tIDENTIFIER
@ -5235,7 +5220,7 @@ lvar_defined_gen(parser, id)
}
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_TERNARY || lex_state == EXPR_CLASS)
#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_VALUE || lex_state == EXPR_CLASS)
static int
parser_yylex(parser)
@ -5319,7 +5304,7 @@ parser_yylex(parser)
case EXPR_FNAME:
case EXPR_DOT:
case EXPR_CLASS:
case EXPR_TERNARY:
case EXPR_VALUE:
#ifdef RIPPER
if (!fallthru) {
ripper_dispatch_scan_event(parser, tIGNORED_NL);
@ -5523,7 +5508,7 @@ parser_yylex(parser)
case '?':
if (lex_state == EXPR_END || lex_state == EXPR_ENDARG) {
lex_state = EXPR_TERNARY;
lex_state = EXPR_VALUE;
return '?';
}
c = nextc();
@ -5561,7 +5546,7 @@ parser_yylex(parser)
}
ternary:
pushback(c);
lex_state = EXPR_TERNARY;
lex_state = EXPR_VALUE;
return '?';
}
else if (ismbchar(uc)) {
@ -6398,7 +6383,7 @@ parser_yylex(parser)
return kDO_BLOCK;
return kDO;
}
if (state == EXPR_BEG || state == EXPR_TERNARY)
if (state == EXPR_BEG || state == EXPR_VALUE)
return kw->id[0];
else {
if (kw->id[0] != kw->id[1])