From e5f2b421c0b5134a58a4cf45234f54c376fd1297 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 26 Jun 2006 14:15:49 +0000 Subject: [PATCH] * ext/socket/socket.c (sock_accept): revert to avoid ambiguity of argument evaluation order. [ruby-dev:28861] * ext/socket/socket.c (sock_accept_nonblock): ditto. * io.c (pipe_open): avoid closing uninitialized file descriptors. a patch from [ruby-dev:28600] * parse.y: replace terminal token names with more descriptive name, i.e. kEND to keyword_end. [ruby-list:42477] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 17 ++ ext/ripper/eventids2.c | 94 +++++----- ext/socket/socket.c | 18 +- io.c | 10 +- keywords | 80 ++++---- lex.c | 217 ++++++++++++++-------- parse.y | 412 +++++++++++++++++++++-------------------- 7 files changed, 475 insertions(+), 373 deletions(-) diff --git a/ChangeLog b/ChangeLog index d9581687a9..e0b3b231f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,18 @@ Mon Jun 26 18:37:44 2006 Hidetoshi NAGAI * ext/tk/tcltklib.c (ip_delete): fix SEGV when a slave-ip is deleted on callback. +Mon Jun 26 15:40:26 2006 Yukihiro Matsumoto + + * ext/socket/socket.c (sock_accept): revert to avoid ambiguity of + argument evaluation order. [ruby-dev:28861] + + * ext/socket/socket.c (sock_accept_nonblock): ditto. + +Mon Jun 26 10:47:42 2006 Yukihiro Matsumoto + + * io.c (pipe_open): avoid closing uninitialized file descriptors. + a patch from [ruby-dev:28600] + Sun Jun 25 23:02:12 2006 Nobuyoshi Nakada * Makefile.in, mkconfig.rb: catch-up for latest autoconf. @@ -19,6 +31,11 @@ Sun Jun 25 17:18:33 2006 Masaki Suketa * test/win32ole/test_word.rb: ditto. +Sat Jun 24 23:48:08 2006 Yukihiro Matsumoto + + * parse.y: replace terminal token names with more descriptive + name, i.e. kEND to keyword_end. [ruby-list:42477] + Sat Jun 24 23:37:41 2006 Tanaka Akira * eval.c (rb_eval): use rb_ary_new2 instead of rb_ary_new4 to avoid diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c index ba9c90269a..629040127b 100644 --- a/ext/ripper/eventids2.c +++ b/ext/ripper/eventids2.c @@ -137,53 +137,53 @@ static struct token_assoc { {';', &ripper_id_semicolon}, {'`', &ripper_id_backtick}, {'\n', &ripper_id_nl}, - {kALIAS, &ripper_id_kw}, - {kAND, &ripper_id_kw}, - {kBEGIN, &ripper_id_kw}, - {kBREAK, &ripper_id_kw}, - {kCASE, &ripper_id_kw}, - {kCLASS, &ripper_id_kw}, - {kDEF, &ripper_id_kw}, - {kDEFINED, &ripper_id_kw}, - {kDO, &ripper_id_kw}, - {kDO_BLOCK, &ripper_id_kw}, - {kDO_COND, &ripper_id_kw}, - {kELSE, &ripper_id_kw}, - {kELSIF, &ripper_id_kw}, - {kEND, &ripper_id_kw}, - {kENSURE, &ripper_id_kw}, - {kFALSE, &ripper_id_kw}, - {kFOR, &ripper_id_kw}, - {kIF, &ripper_id_kw}, - {kIF_MOD, &ripper_id_kw}, - {kIN, &ripper_id_kw}, - {kMODULE, &ripper_id_kw}, - {kNEXT, &ripper_id_kw}, - {kNIL, &ripper_id_kw}, - {kNOT, &ripper_id_kw}, - {kOR, &ripper_id_kw}, - {kREDO, &ripper_id_kw}, - {kRESCUE, &ripper_id_kw}, - {kRESCUE_MOD, &ripper_id_kw}, - {kRETRY, &ripper_id_kw}, - {kRETURN, &ripper_id_kw}, - {kSELF, &ripper_id_kw}, - {kSUPER, &ripper_id_kw}, - {kTHEN, &ripper_id_kw}, - {kTRUE, &ripper_id_kw}, - {kUNDEF, &ripper_id_kw}, - {kUNLESS, &ripper_id_kw}, - {kUNLESS_MOD, &ripper_id_kw}, - {kUNTIL, &ripper_id_kw}, - {kUNTIL_MOD, &ripper_id_kw}, - {kWHEN, &ripper_id_kw}, - {kWHILE, &ripper_id_kw}, - {kWHILE_MOD, &ripper_id_kw}, - {kYIELD, &ripper_id_kw}, - {k__FILE__, &ripper_id_kw}, - {k__LINE__, &ripper_id_kw}, - {klBEGIN, &ripper_id_kw}, - {klEND, &ripper_id_kw}, + {keyword_alias, &ripper_id_kw}, + {keyword_and, &ripper_id_kw}, + {keyword_begin, &ripper_id_kw}, + {keyword_break, &ripper_id_kw}, + {keyword_case, &ripper_id_kw}, + {keyword_class, &ripper_id_kw}, + {keyword_def, &ripper_id_kw}, + {keyword_defined, &ripper_id_kw}, + {keyword_do, &ripper_id_kw}, + {keyword_do_block, &ripper_id_kw}, + {keyword_do_cond, &ripper_id_kw}, + {keyword_else, &ripper_id_kw}, + {keyword_elsif, &ripper_id_kw}, + {keyword_end, &ripper_id_kw}, + {keyword_ensure, &ripper_id_kw}, + {keyword_false, &ripper_id_kw}, + {keyword_for, &ripper_id_kw}, + {keyword_if, &ripper_id_kw}, + {modifier_if, &ripper_id_kw}, + {keyword_in, &ripper_id_kw}, + {keyword_module, &ripper_id_kw}, + {keyword_next, &ripper_id_kw}, + {keyword_nil, &ripper_id_kw}, + {keyword_not, &ripper_id_kw}, + {keyword_or, &ripper_id_kw}, + {keyword_redo, &ripper_id_kw}, + {keyword_rescue, &ripper_id_kw}, + {modifier_rescue, &ripper_id_kw}, + {keyword_retry, &ripper_id_kw}, + {keyword_return, &ripper_id_kw}, + {keyword_self, &ripper_id_kw}, + {keyword_super, &ripper_id_kw}, + {keyword_then, &ripper_id_kw}, + {keyword_true, &ripper_id_kw}, + {keyword_undef, &ripper_id_kw}, + {keyword_unless, &ripper_id_kw}, + {modifier_unless, &ripper_id_kw}, + {keyword_until, &ripper_id_kw}, + {modifier_until, &ripper_id_kw}, + {keyword_when, &ripper_id_kw}, + {keyword_while, &ripper_id_kw}, + {modifier_while, &ripper_id_kw}, + {keyword_yield, &ripper_id_kw}, + {keyword__FILE__, &ripper_id_kw}, + {keyword__LINE__, &ripper_id_kw}, + {keyword_BEGIN, &ripper_id_kw}, + {keyword_END, &ripper_id_kw}, {tAMPER, &ripper_id_op}, {tANDOP, &ripper_id_op}, {tAREF, &ripper_id_op}, diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 233bb0a644..3c91ec472a 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -2815,15 +2815,18 @@ sock_recvfrom_nonblock(int argc, VALUE *argv, VALUE sock) } static VALUE -sock_accept(VALUE sock) +sock_accept(sock) + VALUE sock; { OpenFile *fptr; + VALUE sock2; char buf[1024]; socklen_t len = sizeof buf; GetOpenFile(sock, fptr); - return rb_assoc_new(s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)buf, &len), - rb_str_new(buf, len)); + sock2 = s_accept(rb_cSocket,fptr->fd,(struct sockaddr*)buf,&len); + + return rb_assoc_new(sock2, rb_str_new(buf, len)); } /* @@ -2875,16 +2878,17 @@ sock_accept(VALUE sock) * * Socket#accept */ static VALUE -sock_accept_nonblock(VALUE sock) +sock_accept_nonblock(sock) + VALUE sock; { OpenFile *fptr; + VALUE sock2; char buf[1024]; socklen_t len = sizeof buf; GetOpenFile(sock, fptr); - return rb_assoc_new(s_accept_nonblock(rb_cSocket, fptr, - (struct sockaddr *)buf, &len), - rb_str_new(buf, len)); + sock2 = s_accept_nonblock(rb_cSocket, fptr, (struct sockaddr *)buf, &len); + return rb_assoc_new(sock2, rb_str_new(buf, len)); } /* diff --git a/io.c b/io.c index e8007819b2..8927fad927 100644 --- a/io.c +++ b/io.c @@ -3029,8 +3029,14 @@ pipe_open(int argc, VALUE *argv, const char *mode) /* parent */ if (pid == -1) { int e = errno; - close(arg.pair[0]); - close(arg.pair[1]); + if ((modef & FMODE_READABLE)) { + close(arg.pair[0]); + close(arg.pair[1]); + } + if ((modef & FMODE_WRITABLE)) { + close(arg.pair[0]); + close(arg.pair[1]); + } errno = e; rb_sys_fail(cmd); } diff --git a/keywords b/keywords index d357f88df1..f306d8dd94 100644 --- a/keywords +++ b/keywords @@ -3,45 +3,45 @@ const struct kwtable *rb_reserved_word _((const char *, unsigned int)); #ifndef RIPPER %% -__LINE__, {k__LINE__, k__LINE__}, EXPR_END -__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_VALUE -begin, {kBEGIN, kBEGIN}, EXPR_BEG -break, {kBREAK, kBREAK}, EXPR_MID -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_VALUE -end, {kEND, kEND}, EXPR_END -ensure, {kENSURE, kENSURE}, EXPR_BEG -false, {kFALSE, kFALSE}, EXPR_END -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_VALUE -or, {kOR, kOR}, EXPR_VALUE -redo, {kREDO, kREDO}, EXPR_END -rescue, {kRESCUE, kRESCUE_MOD}, EXPR_MID -retry, {kRETRY, kRETRY}, EXPR_END -return, {kRETURN, kRETURN}, EXPR_MID -self, {kSELF, kSELF}, EXPR_END -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_VALUE -until, {kUNTIL, kUNTIL_MOD}, EXPR_VALUE -when, {kWHEN, kWHEN}, EXPR_VALUE -while, {kWHILE, kWHILE_MOD}, EXPR_VALUE -yield, {kYIELD, kYIELD}, EXPR_ARG +__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 +case, {keyword_case, keyword_case}, EXPR_VALUE +class, {keyword_class, keyword_class}, EXPR_CLASS +def, {keyword_def, keyword_def}, EXPR_FNAME +defined?, {keyword_defined, keyword_defined}, EXPR_ARG +do, {keyword_do, keyword_do}, EXPR_BEG +else, {keyword_else, keyword_else}, EXPR_BEG +elsif, {keyword_elsif, keyword_elsif}, EXPR_VALUE +end, {keyword_end, keyword_end}, EXPR_END +ensure, {keyword_ensure, keyword_ensure}, EXPR_BEG +false, {keyword_false, keyword_false}, EXPR_END +for, {keyword_for, keyword_for}, EXPR_VALUE +if, {keyword_if, modifier_if}, EXPR_VALUE +in, {keyword_in, keyword_in}, EXPR_VALUE +module, {keyword_module, keyword_module}, EXPR_VALUE +next, {keyword_next, keyword_next}, EXPR_MID +nil, {keyword_nil, keyword_nil}, EXPR_END +not, {keyword_not, keyword_not}, EXPR_VALUE +or, {keyword_or, keyword_or}, EXPR_VALUE +redo, {keyword_redo, keyword_redo}, EXPR_END +rescue, {keyword_rescue, modifier_rescue}, EXPR_MID +retry, {keyword_retry, keyword_retry}, EXPR_END +return, {keyword_return, keyword_return}, EXPR_MID +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 +while, {keyword_while, modifier_while}, EXPR_VALUE +yield, {keyword_yield, keyword_yield}, EXPR_ARG %% #endif diff --git a/lex.c b/lex.c index db81b252d6..5412455357 100644 --- a/lex.c +++ b/lex.c @@ -1,16 +1,44 @@ -/* C code produced by gperf version 2.7.2 */ +/* C code produced by gperf version 3.0.1 */ /* Command-line: gperf -C -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' keywords */ + +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) +/* The character set is not based on ISO-646. */ +error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#endif + +#line 1 "keywords" struct kwtable {char *name; int id[2]; enum lex_state_e state;}; -const struct kwtable *rb_reserved_word(const char *, unsigned int); +const struct kwtable *rb_reserved_word _((const char *, unsigned int)); #ifndef RIPPER -; #define TOTAL_KEYWORDS 40 #define MIN_WORD_LENGTH 2 #define MAX_WORD_LENGTH 8 #define MIN_HASH_VALUE 6 -#define MAX_HASH_VALUE 55 -/* maximum key range = 50, duplicates = 0 */ +#define MAX_HASH_VALUE 50 +/* maximum key range = 45, duplicates = 0 */ #ifdef __GNUC__ __inline @@ -26,40 +54,40 @@ hash (str, len) { static const unsigned char asso_values[] = { - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 11, 56, 56, 36, 56, 1, 37, - 31, 1, 56, 56, 56, 56, 29, 56, 1, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 1, 56, 32, 1, 2, - 1, 1, 4, 23, 56, 17, 56, 20, 9, 2, - 9, 26, 14, 56, 5, 1, 1, 16, 56, 21, - 20, 9, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, - 56, 56, 56, 56, 56, 56 + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 23, 51, 51, 13, 51, 1, 1, + 11, 12, 51, 51, 51, 51, 10, 51, 12, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 11, 51, 13, 1, 26, + 4, 1, 8, 28, 51, 23, 51, 1, 1, 27, + 5, 19, 21, 51, 8, 3, 3, 11, 51, 21, + 24, 16, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 51, 51, 51, 51, 51, 51 }; register int hval = len; switch (hval) { default: - case 3: hval += asso_values[(unsigned char)str[2]]; + /*FALLTHROUGH*/ case 2: case 1: hval += asso_values[(unsigned char)str[0]]; @@ -79,48 +107,89 @@ rb_reserved_word (str, len) static const struct kwtable wordlist[] = { {""}, {""}, {""}, {""}, {""}, {""}, - {"end", {kEND, kEND}, EXPR_END}, - {"else", {kELSE, kELSE}, EXPR_BEG}, - {"case", {kCASE, kCASE}, EXPR_VALUE}, - {"ensure", {kENSURE, kENSURE}, 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_VALUE}, - {"then", {kTHEN, kTHEN}, EXPR_BEG}, - {"yield", {kYIELD, kYIELD}, EXPR_ARG}, - {"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_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_VALUE}, - {"do", {kDO, kDO}, EXPR_BEG}, - {"nil", {kNIL, kNIL}, EXPR_END}, - {"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_VALUE}, - {"redo", {kREDO, kREDO}, EXPR_END}, - {"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_VALUE}, - {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, +#line 9 "keywords" + {"END", {keyword_END, keyword_END}, EXPR_END}, {""}, - {"alias", {kALIAS, kALIAS}, EXPR_FNAME} +#line 13 "keywords" + {"break", {keyword_break, keyword_break}, EXPR_MID}, +#line 19 "keywords" + {"else", {keyword_else, keyword_else}, EXPR_BEG}, +#line 29 "keywords" + {"nil", {keyword_nil, keyword_nil}, EXPR_END}, +#line 22 "keywords" + {"ensure", {keyword_ensure, keyword_ensure}, EXPR_BEG}, +#line 21 "keywords" + {"end", {keyword_end, keyword_end}, EXPR_END}, +#line 38 "keywords" + {"then", {keyword_then, keyword_then}, EXPR_BEG}, +#line 30 "keywords" + {"not", {keyword_not, keyword_not}, EXPR_VALUE}, +#line 23 "keywords" + {"false", {keyword_false, keyword_false}, EXPR_END}, +#line 36 "keywords" + {"self", {keyword_self, keyword_self}, EXPR_END}, +#line 20 "keywords" + {"elsif", {keyword_elsif, keyword_elsif}, EXPR_VALUE}, +#line 33 "keywords" + {"rescue", {keyword_rescue, modifier_rescue}, EXPR_MID}, +#line 39 "keywords" + {"true", {keyword_true, keyword_true}, EXPR_END}, +#line 42 "keywords" + {"until", {keyword_until, modifier_until}, EXPR_VALUE}, +#line 41 "keywords" + {"unless", {keyword_unless, modifier_unless}, EXPR_VALUE}, +#line 35 "keywords" + {"return", {keyword_return, keyword_return}, EXPR_MID}, +#line 16 "keywords" + {"def", {keyword_def, keyword_def}, EXPR_FNAME}, +#line 11 "keywords" + {"and", {keyword_and, keyword_and}, EXPR_VALUE}, +#line 18 "keywords" + {"do", {keyword_do, keyword_do}, EXPR_BEG}, +#line 45 "keywords" + {"yield", {keyword_yield, keyword_yield}, EXPR_ARG}, +#line 24 "keywords" + {"for", {keyword_for, keyword_for}, EXPR_VALUE}, +#line 40 "keywords" + {"undef", {keyword_undef, keyword_undef}, EXPR_FNAME}, +#line 31 "keywords" + {"or", {keyword_or, keyword_or}, EXPR_VALUE}, +#line 26 "keywords" + {"in", {keyword_in, keyword_in}, EXPR_VALUE}, +#line 43 "keywords" + {"when", {keyword_when, keyword_when}, EXPR_VALUE}, +#line 34 "keywords" + {"retry", {keyword_retry, keyword_retry}, EXPR_END}, +#line 25 "keywords" + {"if", {keyword_if, modifier_if}, EXPR_VALUE}, +#line 14 "keywords" + {"case", {keyword_case, keyword_case}, EXPR_VALUE}, +#line 32 "keywords" + {"redo", {keyword_redo, keyword_redo}, EXPR_END}, +#line 28 "keywords" + {"next", {keyword_next, keyword_next}, EXPR_MID}, +#line 37 "keywords" + {"super", {keyword_super, keyword_super}, EXPR_ARG}, +#line 27 "keywords" + {"module", {keyword_module, keyword_module}, EXPR_VALUE}, +#line 12 "keywords" + {"begin", {keyword_begin, keyword_begin}, EXPR_BEG}, +#line 6 "keywords" + {"__LINE__", {keyword__LINE__, keyword__LINE__}, EXPR_END}, +#line 7 "keywords" + {"__FILE__", {keyword__FILE__, keyword__FILE__}, EXPR_END}, +#line 8 "keywords" + {"BEGIN", {keyword_BEGIN, keyword_BEGIN}, EXPR_END}, +#line 17 "keywords" + {"defined?", {keyword_defined, keyword_defined}, EXPR_ARG}, +#line 10 "keywords" + {"alias", {keyword_alias, keyword_alias}, EXPR_FNAME}, + {""}, {""}, +#line 15 "keywords" + {"class", {keyword_class, keyword_class}, EXPR_CLASS}, + {""}, {""}, +#line 44 "keywords" + {"while", {keyword_while, modifier_while}, EXPR_VALUE} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) @@ -137,4 +206,6 @@ rb_reserved_word (str, len) } return 0; } +#line 46 "keywords" + #endif diff --git a/parse.y b/parse.y index d7541a521c..c098fd82b3 100644 --- a/parse.y +++ b/parse.y @@ -471,54 +471,54 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...); /*% %token %*/ - kCLASS - kMODULE - kDEF - kUNDEF - kBEGIN - kRESCUE - kENSURE - kEND - kIF - kUNLESS - kTHEN - kELSIF - kELSE - kCASE - kWHEN - kWHILE - kUNTIL - kFOR - kBREAK - kNEXT - kREDO - kRETRY - kIN - kDO - kDO_COND - kDO_BLOCK - kDO_LAMBDA - kRETURN - kYIELD - kSUPER - kSELF - kNIL - kTRUE - kFALSE - kAND - kOR - kNOT - kIF_MOD - kUNLESS_MOD - kWHILE_MOD - kUNTIL_MOD - kRESCUE_MOD - kALIAS - kDEFINED - klBEGIN - klEND - k__LINE__ - k__FILE__ + keyword_class + keyword_module + keyword_def + keyword_undef + keyword_begin + keyword_rescue + keyword_ensure + keyword_end + keyword_if + keyword_unless + keyword_then + keyword_elsif + keyword_else + keyword_case + keyword_when + keyword_while + keyword_until + keyword_for + keyword_break + keyword_next + keyword_redo + keyword_retry + keyword_in + keyword_do + keyword_do_cond + keyword_do_block + keyword_do_LAMBDA + keyword_return + keyword_yield + keyword_super + keyword_self + keyword_nil + keyword_true + keyword_false + keyword_and + keyword_or + keyword_not + modifier_if + modifier_unless + modifier_while + modifier_until + modifier_rescue + keyword_alias + keyword_defined + keyword_BEGIN + keyword_END + keyword__LINE__ + keyword__FILE__ %token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL %token tINTEGER tFLOAT tSTRING_CONTENT tCHAR @@ -587,12 +587,12 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...); %nonassoc tLOWEST %nonassoc tLBRACE_ARG -%nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD -%left kOR kAND -%right kNOT -%nonassoc kDEFINED +%nonassoc modifier_if modifier_unless modifier_while modifier_until +%left keyword_or keyword_and +%right keyword_not +%nonassoc keyword_defined %right '=' tOP_ASGN -%left kRESCUE_MOD +%left modifier_rescue %right '?' ':' %nonassoc tDOT2 tDOT3 %left tOROP @@ -721,7 +721,7 @@ stmts : none } ; -stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem +stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem { /*%%%*/ $$ = NEW_ALIAS($2, $4); @@ -729,7 +729,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(alias, $2, $4); %*/ } - | kALIAS tGVAR tGVAR + | keyword_alias tGVAR tGVAR { /*%%%*/ $$ = NEW_VALIAS($2, $3); @@ -737,7 +737,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(var_alias, $2, $3); %*/ } - | kALIAS tGVAR tBACK_REF + | keyword_alias tGVAR tBACK_REF { /*%%%*/ char buf[3]; @@ -748,7 +748,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(var_alias, $2, $3); %*/ } - | kALIAS tGVAR tNTH_REF + | keyword_alias tGVAR tNTH_REF { /*%%%*/ yyerror("can't make alias for the number variables"); @@ -758,7 +758,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch1(alias_error, $$); %*/ } - | kUNDEF undef_list + | keyword_undef undef_list { /*%%%*/ $$ = $2; @@ -766,7 +766,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch1(undef, $2); %*/ } - | stmt kIF_MOD expr_value + | stmt modifier_if expr_value { /*%%%*/ $$ = NEW_IF(cond($3), $1, 0); @@ -779,7 +779,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(if_mod, $3, $1); %*/ } - | stmt kUNLESS_MOD expr_value + | stmt modifier_unless expr_value { /*%%%*/ $$ = NEW_UNLESS(cond($3), $1, 0); @@ -792,7 +792,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(unless_mod, $3, $1); %*/ } - | stmt kWHILE_MOD expr_value + | stmt modifier_while expr_value { /*%%%*/ if ($1 && nd_type($1) == NODE_BEGIN) { @@ -808,7 +808,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(while_mod, $3, $1); %*/ } - | stmt kUNTIL_MOD expr_value + | stmt modifier_until expr_value { /*%%%*/ if ($1 && nd_type($1) == NODE_BEGIN) { @@ -824,7 +824,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(until_mod, $3, $1); %*/ } - | stmt kRESCUE_MOD stmt + | stmt modifier_rescue stmt { /*%%%*/ $$ = NEW_RESCUE($1, NEW_RESBODY(0,$3,0), 0); @@ -832,7 +832,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch2(rescue_mod, $3, $1); %*/ } - | klBEGIN + | keyword_BEGIN { /*%%%*/ if (in_def || in_single) { @@ -856,7 +856,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem $$ = dispatch1(BEGIN, $4); %*/ } - | klEND '{' compstmt '}' + | keyword_END '{' compstmt '}' { if (in_def || in_single) { rb_warn0("END in method; use at_exit"); @@ -1025,7 +1025,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem ; expr : command_call - | expr kAND expr + | expr keyword_and expr { /*%%%*/ $$ = logop(NODE_AND, $1, $3); @@ -1033,7 +1033,7 @@ expr : command_call $$ = dispatch3(binary, $1, ripper_intern("and"), $3); %*/ } - | expr kOR expr + | expr keyword_or expr { /*%%%*/ $$ = logop(NODE_OR, $1, $3); @@ -1041,7 +1041,7 @@ expr : command_call $$ = dispatch3(binary, $1, ripper_intern("or"), $3); %*/ } - | kNOT expr + | keyword_not expr { /*%%%*/ $$ = NEW_NOT(cond($2)); @@ -1073,7 +1073,7 @@ expr_value : expr command_call : command | block_command - | kRETURN call_args + | keyword_return call_args { /*%%%*/ $$ = NEW_RETURN(ret_args($2)); @@ -1081,7 +1081,7 @@ command_call : command $$ = dispatch1(return, $2); %*/ } - | kBREAK call_args + | keyword_break call_args { /*%%%*/ $$ = NEW_BREAK(ret_args($2)); @@ -1089,7 +1089,7 @@ command_call : command $$ = dispatch1(break, $2); %*/ } - | kNEXT call_args + | keyword_next call_args { /*%%%*/ $$ = NEW_NEXT(ret_args($2)); @@ -1204,7 +1204,7 @@ command : operation command_args %prec tLOWEST $$ = dispatch2(iter_block, $$, $5); %*/ } - | kSUPER command_args + | keyword_super command_args { /*%%%*/ $$ = NEW_SUPER($2); @@ -1213,7 +1213,7 @@ command : operation command_args %prec tLOWEST $$ = dispatch1(super, $2); %*/ } - | kYIELD command_args + | keyword_yield command_args { /*%%%*/ $$ = new_yield($2); @@ -1649,13 +1649,17 @@ op : '|' { ifndef_ripper($$ = '|'); } | '`' { ifndef_ripper($$ = '`'); } ; -reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND - | kALIAS | kAND | kBEGIN | kBREAK | kCASE | kCLASS | kDEF - | kDEFINED | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE - | kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT - | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER - | kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD - | kIF | kUNLESS | kWHILE | kUNTIL +reswords : keyword__LINE__ | keyword__FILE__ | keyword_BEGIN | keyword_END + | keyword_alias | keyword_and | keyword_begin + | keyword_break | keyword_case | keyword_class | keyword_def + | keyword_defined | keyword_do | keyword_else | keyword_elsif + | keyword_end | keyword_ensure | keyword_false + | keyword_for | keyword_in | keyword_module | keyword_next + | keyword_nil | keyword_not | keyword_or | keyword_redo + | keyword_rescue | keyword_retry | keyword_return | keyword_self + | keyword_super | keyword_then | keyword_true | keyword_undef + | keyword_when | keyword_yield | keyword_if | keyword_unless + | keyword_while | keyword_until ; arg : lhs '=' arg @@ -1666,7 +1670,7 @@ arg : lhs '=' arg $$ = dispatch2(assign, $1, $3); %*/ } - | lhs '=' arg kRESCUE_MOD arg + | lhs '=' arg modifier_rescue arg { /*%%%*/ $$ = node_assign($1, NEW_RESCUE($3, NEW_RESBODY(0,$5,0), 0)); @@ -2080,7 +2084,7 @@ arg : lhs '=' arg $$ = dispatch3(binary, $1, ripper_intern("||"), $3); %*/ } - | kDEFINED opt_nl {in_defined = 1;} arg + | keyword_defined opt_nl {in_defined = 1;} arg { /*%%%*/ in_defined = 0; @@ -2376,7 +2380,7 @@ primary : literal $$ = method_arg(dispatch1(fcall, $1), arg_new()); %*/ } - | kBEGIN + | keyword_begin { /*%%%*/ $1 = ruby_sourceline; @@ -2384,7 +2388,7 @@ primary : literal %*/ } bodystmt - kEND + keyword_end { /*%%%*/ if ($3 == NULL) { @@ -2456,7 +2460,7 @@ primary : literal $$ = dispatch1(hash, escape_Qundef($2)); %*/ } - | kRETURN + | keyword_return { /*%%%*/ $$ = NEW_RETURN(0); @@ -2464,7 +2468,7 @@ primary : literal $$ = dispatch0(return0); %*/ } - | kYIELD '(' call_args rparen + | keyword_yield '(' call_args rparen { /*%%%*/ $$ = new_yield($3); @@ -2472,7 +2476,7 @@ primary : literal $$ = dispatch1(yield, dispatch1(paren, $3)); %*/ } - | kYIELD '(' rparen + | keyword_yield '(' rparen { /*%%%*/ $$ = NEW_YIELD(0, Qfalse); @@ -2480,7 +2484,7 @@ primary : literal $$ = dispatch1(yield, dispatch1(paren, arg_new())); %*/ } - | kYIELD + | keyword_yield { /*%%%*/ $$ = NEW_YIELD(0, Qfalse); @@ -2488,7 +2492,7 @@ primary : literal $$ = dispatch0(yield0); %*/ } - | kDEFINED opt_nl '(' {in_defined = 1;} expr rparen + | keyword_defined opt_nl '(' {in_defined = 1;} expr rparen { /*%%%*/ in_defined = 0; @@ -2525,10 +2529,10 @@ primary : literal { $$ = $2; } - | kIF expr_value then + | keyword_if expr_value then compstmt if_tail - kEND + keyword_end { /*%%%*/ $$ = NEW_IF(cond($2), $4, $5); @@ -2542,10 +2546,10 @@ primary : literal $$ = dispatch3(if, $2, $4, escape_Qundef($5)); %*/ } - | kUNLESS expr_value then + | keyword_unless expr_value then compstmt opt_else - kEND + keyword_end { /*%%%*/ $$ = NEW_UNLESS(cond($2), $4, $5); @@ -2559,9 +2563,9 @@ primary : literal $$ = dispatch3(unless, $2, $4, escape_Qundef($5)); %*/ } - | kWHILE {COND_PUSH(1);} expr_value do {COND_POP();} + | keyword_while {COND_PUSH(1);} expr_value do {COND_POP();} compstmt - kEND + keyword_end { /*%%%*/ $$ = NEW_WHILE(cond($3), $6, 1); @@ -2573,9 +2577,9 @@ primary : literal $$ = dispatch2(while, $3, $6); %*/ } - | kUNTIL {COND_PUSH(1);} expr_value do {COND_POP();} + | keyword_until {COND_PUSH(1);} expr_value do {COND_POP();} compstmt - kEND + keyword_end { /*%%%*/ $$ = NEW_UNTIL(cond($3), $6, 1); @@ -2587,9 +2591,9 @@ primary : literal $$ = dispatch2(until, $3, $6); %*/ } - | kCASE expr_value opt_terms + | keyword_case expr_value opt_terms case_body - kEND + keyword_end { /*%%%*/ $$ = NEW_CASE($2, $4); @@ -2598,7 +2602,7 @@ primary : literal $$ = dispatch2(case, $2, $4); %*/ } - | kCASE expr_value opt_terms kELSE compstmt kEND + | keyword_case expr_value opt_terms keyword_else compstmt keyword_end { /*%%%*/ $$ = block_append($2, $5); @@ -2606,7 +2610,7 @@ primary : literal $$ = dispatch2(case, $2, dispatch1(else, $5)); %*/ } - | kCASE opt_terms case_body kEND + | keyword_case opt_terms case_body keyword_end { /*%%%*/ $$ = $3; @@ -2614,7 +2618,7 @@ primary : literal $$ = dispatch2(case, Qnil, $3); %*/ } - | kCASE opt_terms kELSE compstmt kEND + | keyword_case opt_terms keyword_else compstmt keyword_end { /*%%%*/ $$ = $4; @@ -2622,9 +2626,9 @@ primary : literal $$ = dispatch2(case, Qnil, dispatch1(else, $4)); %*/ } - | kFOR for_var kIN {COND_PUSH(1);} expr_value do {COND_POP();} + | keyword_for for_var keyword_in {COND_PUSH(1);} expr_value do {COND_POP();} compstmt - kEND + keyword_end { /*%%%*/ $$ = NEW_FOR($2, $5, $8); @@ -2633,7 +2637,7 @@ primary : literal $$ = dispatch3(for, $2, $5, $8); %*/ } - | kCLASS cpath superclass + | keyword_class cpath superclass { /*%%%*/ if (in_def || in_single) @@ -2648,7 +2652,7 @@ primary : literal %*/ } bodystmt - kEND + keyword_end { /*%%%*/ $$ = NEW_CLASS($2, $5, $3); @@ -2660,7 +2664,7 @@ primary : literal class_nest--; %*/ } - | kCLASS tLSHFT expr + | keyword_class tLSHFT expr { /*%%%*/ $$ = in_def; @@ -2683,7 +2687,7 @@ primary : literal %*/ } bodystmt - kEND + keyword_end { /*%%%*/ $$ = NEW_SCLASS($3, $7); @@ -2699,7 +2703,7 @@ primary : literal in_single = $6; %*/ } - | kMODULE cpath + | keyword_module cpath { /*%%%*/ if (in_def || in_single) @@ -2714,7 +2718,7 @@ primary : literal %*/ } bodystmt - kEND + keyword_end { /*%%%*/ $$ = NEW_MODULE($2, $4); @@ -2726,7 +2730,7 @@ primary : literal class_nest--; %*/ } - | kDEF fname + | keyword_def fname { /*%%%*/ $$ = cur_mid; @@ -2741,7 +2745,7 @@ primary : literal } f_arglist bodystmt - kEND + keyword_end { /*%%%*/ NODE *body = remove_begin($5); @@ -2757,7 +2761,7 @@ primary : literal cur_mid = $3; %*/ } - | kDEF singleton dot_or_colon {lex_state = EXPR_FNAME;} fname + | keyword_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname { /*%%%*/ in_single++; @@ -2770,7 +2774,7 @@ primary : literal } f_arglist bodystmt - kEND + keyword_end { /*%%%*/ NODE *body = remove_begin($8); @@ -2784,7 +2788,7 @@ primary : literal in_single--; %*/ } - | kBREAK + | keyword_break { /*%%%*/ $$ = NEW_BREAK(0); @@ -2792,7 +2796,7 @@ primary : literal $$ = dispatch1(break, arg_new()); %*/ } - | kNEXT + | keyword_next { /*%%%*/ $$ = NEW_NEXT(0); @@ -2800,7 +2804,7 @@ primary : literal $$ = dispatch1(next, arg_new()); %*/ } - | kREDO + | keyword_redo { /*%%%*/ $$ = NEW_REDO(); @@ -2808,7 +2812,7 @@ primary : literal $$ = dispatch0(redo); %*/ } - | kRETRY + | keyword_retry { /*%%%*/ $$ = NEW_RETRY(); @@ -2834,8 +2838,8 @@ then : term /*%c { $$ = Qnil; } %*/ - | kTHEN - | term kTHEN + | keyword_then + | term keyword_then /*%c%*/ /*%c { $$ = $2; } @@ -2847,11 +2851,11 @@ do : term /*%c { $$ = Qnil; } %*/ - | kDO_COND + | keyword_do_cond ; if_tail : opt_else - | kELSIF expr_value then + | keyword_elsif expr_value then compstmt if_tail { @@ -2865,7 +2869,7 @@ if_tail : opt_else ; opt_else : none - | kELSE compstmt + | keyword_else compstmt { /*%%%*/ $$ = $2; @@ -3168,13 +3172,13 @@ lambda_body : tLAMBEG compstmt '}' { $$ = $2; } - | kDO_LAMBDA compstmt kEND + | keyword_do_LAMBDA compstmt keyword_end { $$ = $2; } ; -do_block : kDO_BLOCK +do_block : keyword_do_block { /*%%%*/ $$ = dyna_push(); @@ -3188,7 +3192,7 @@ do_block : kDO_BLOCK /*% %*/ } compstmt - kEND + keyword_end { /*%%%*/ $3->nd_body = block_append($3->nd_body, @@ -3292,7 +3296,7 @@ method_call : operation paren_args $$ = method_optarg($$, $3); %*/ } - | kSUPER paren_args + | keyword_super paren_args { /*%%%*/ $$ = NEW_SUPER($2); @@ -3300,7 +3304,7 @@ method_call : operation paren_args $$ = dispatch1(super, $2); %*/ } - | kSUPER + | keyword_super { /*%%%*/ $$ = NEW_ZSUPER(); @@ -3348,7 +3352,7 @@ brace_block : '{' $$ = dispatch2(brace_block, escape_Qundef($3), $5); %*/ } - | kDO + | keyword_do { /*%%%*/ $$ = dyna_push(); @@ -3362,7 +3366,7 @@ brace_block : '{' /*% %*/ } - compstmt kEND + compstmt keyword_end { /*%%%*/ $3->nd_body = block_append($3->nd_body, @@ -3376,7 +3380,7 @@ brace_block : '{' } ; -case_body : kWHEN args then +case_body : keyword_when args then compstmt cases { @@ -3392,7 +3396,7 @@ cases : opt_else | case_body ; -opt_rescue : kRESCUE exc_list exc_var then +opt_rescue : keyword_rescue exc_list exc_var then compstmt opt_rescue { @@ -3433,7 +3437,7 @@ exc_var : tASSOC lhs | none ; -opt_ensure : kENSURE compstmt +opt_ensure : keyword_ensure compstmt { /*%%%*/ $$ = $2; @@ -3824,12 +3828,12 @@ variable : tIDENTIFIER | tGVAR | tCONSTANT | tCVAR - | kNIL {ifndef_ripper($$ = kNIL);} - | kSELF {ifndef_ripper($$ = kSELF);} - | kTRUE {ifndef_ripper($$ = kTRUE);} - | kFALSE {ifndef_ripper($$ = kFALSE);} - | k__FILE__ {ifndef_ripper($$ = k__FILE__);} - | k__LINE__ {ifndef_ripper($$ = k__LINE__);} + | keyword_nil {ifndef_ripper($$ = keyword_nil);} + | keyword_self {ifndef_ripper($$ = keyword_self);} + | keyword_true {ifndef_ripper($$ = keyword_true);} + | keyword_false {ifndef_ripper($$ = keyword_false);} + | keyword__FILE__ {ifndef_ripper($$ = keyword__FILE__);} + | keyword__LINE__ {ifndef_ripper($$ = keyword__LINE__);} ; var_ref : variable @@ -6735,18 +6739,18 @@ parser_yylex(struct parser_params *parser) set_yylval_id(rb_intern(kw->name)); return kw->id[0]; } - if (kw->id[0] == kDO) { + if (kw->id[0] == keyword_do) { if (lpar_beg && lpar_beg == paren_nest) { lpar_beg = 0; --paren_nest; - return kDO_LAMBDA; + return keyword_do_LAMBDA; } - if (COND_P()) return kDO_COND; + if (COND_P()) return keyword_do_cond; if (CMDARG_P() && state != EXPR_CMDARG) - return kDO_BLOCK; + return keyword_do_block; if (state == EXPR_ENDARG || state == EXPR_BEG) - return kDO_BLOCK; - return kDO; + return keyword_do_block; + return keyword_do; } if (state == EXPR_BEG || state == EXPR_VALUE) return kw->id[0]; @@ -7112,22 +7116,22 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2) static NODE* gettable_gen(struct parser_params *parser, ID id) { - if (id == kSELF) { + if (id == keyword_self) { return NEW_SELF(); } - else if (id == kNIL) { + else if (id == keyword_nil) { return NEW_NIL(); } - else if (id == kTRUE) { + else if (id == keyword_true) { return NEW_TRUE(); } - else if (id == kFALSE) { + else if (id == keyword_false) { return NEW_FALSE(); } - else if (id == k__FILE__) { + else if (id == keyword__FILE__) { return NEW_STR(rb_str_new2(ruby_sourcefile)); } - else if (id == k__LINE__) { + else if (id == keyword__LINE__) { return NEW_LIT(INT2FIX(ruby_sourceline)); } else if (is_local_id(id)) { @@ -7157,22 +7161,22 @@ static NODE* assignable_gen(struct parser_params *parser, ID id, NODE *val) { value_expr(val); - if (id == kSELF) { + if (id == keyword_self) { yyerror("Can't change the value of self"); } - else if (id == kNIL) { + else if (id == keyword_nil) { yyerror("Can't assign to nil"); } - else if (id == kTRUE) { + else if (id == keyword_true) { yyerror("Can't assign to true"); } - else if (id == kFALSE) { + else if (id == keyword_false) { yyerror("Can't assign to false"); } - else if (id == k__FILE__) { + else if (id == keyword__FILE__) { yyerror("Can't assign to __FILE__"); } - else if (id == k__LINE__) { + else if (id == keyword__LINE__) { yyerror("Can't assign to __LINE__"); } else if (is_local_id(id)) { @@ -8844,53 +8848,53 @@ static struct kw_assoc { ID id; const char *name; } keyword_to_name[] = { - {kCLASS, "class"}, - {kMODULE, "module"}, - {kDEF, "def"}, - {kUNDEF, "undef"}, - {kBEGIN, "begin"}, - {kRESCUE, "rescue"}, - {kENSURE, "ensure"}, - {kEND, "end"}, - {kIF, "if"}, - {kUNLESS, "unless"}, - {kTHEN, "then"}, - {kELSIF, "elsif"}, - {kELSE, "else"}, - {kCASE, "case"}, - {kWHEN, "when"}, - {kWHILE, "while"}, - {kUNTIL, "until"}, - {kFOR, "for"}, - {kBREAK, "break"}, - {kNEXT, "next"}, - {kREDO, "redo"}, - {kRETRY, "retry"}, - {kIN, "in"}, - {kDO, "do"}, - {kDO_COND, "do"}, - {kDO_BLOCK, "do"}, - {kRETURN, "return"}, - {kYIELD, "yield"}, - {kSUPER, "super"}, - {kSELF, "self"}, - {kNIL, "nil"}, - {kTRUE, "true"}, - {kFALSE, "false"}, - {kAND, "and"}, - {kOR, "or"}, - {kNOT, "not"}, - {kIF_MOD, "if"}, - {kUNLESS_MOD, "unless"}, - {kWHILE_MOD, "while"}, - {kUNTIL_MOD, "until"}, - {kRESCUE_MOD, "rescue"}, - {kALIAS, "alias"}, - {kDEFINED, "defined"}, - {klBEGIN, "BEGIN"}, - {klEND, "END"}, - {k__LINE__, "__LINE__"}, - {k__FILE__, "__FILE__"}, + {keyword_class, "class"}, + {keyword_module, "module"}, + {keyword_def, "def"}, + {keyword_undef, "undef"}, + {keyword_begin, "begin"}, + {keyword_rescue, "rescue"}, + {keyword_ensure, "ensure"}, + {keyword_end, "end"}, + {keyword_if, "if"}, + {keyword_unless, "unless"}, + {keyword_then, "then"}, + {keyword_elsif, "elsif"}, + {keyword_else, "else"}, + {keyword_case, "case"}, + {keyword_when, "when"}, + {keyword_while, "while"}, + {keyword_until, "until"}, + {keyword_for, "for"}, + {keyword_break, "break"}, + {keyword_next, "next"}, + {keyword_redo, "redo"}, + {keyword_retry, "retry"}, + {keyword_in, "in"}, + {keyword_do, "do"}, + {keyword_do_cond, "do"}, + {keyword_do_block, "do"}, + {keyword_return, "return"}, + {keyword_yield, "yield"}, + {keyword_super, "super"}, + {keyword_self, "self"}, + {keyword_nil, "nil"}, + {keyword_true, "true"}, + {keyword_false, "false"}, + {keyword_and, "and"}, + {keyword_or, "or"}, + {keyword_not, "not"}, + {modifier_if, "if"}, + {modifier_unless, "unless"}, + {modifier_while, "while"}, + {modifier_until, "until"}, + {modifier_rescue, "rescue"}, + {keyword_alias, "alias"}, + {keyword_defined, "defined?"}, + {keyword_BEGIN, "BEGIN"}, + {keyword_END, "END"}, + {keyword__LINE__, "__LINE__"}, + {keyword__FILE__, "__FILE__"}, {0, NULL} };