ruby-changes:40466
From: nobu <ko1@a...>
Date: Thu, 12 Nov 2015 14:16:22 +0900 (JST)
Subject: [ruby-changes:40466] nobu:r52547 (trunk): parse.y: simplify
nobu 2015-11-12 14:16:03 +0900 (Thu, 12 Nov 2015) New Revision: 52547 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52547 Log: parse.y: simplify * parse.y (parser_yylex): reduce RIPPER ifdefs. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 52546) +++ parse.y (revision 52547) @@ -5232,6 +5232,8 @@ ripper_yylval_id(ID x) https://github.com/ruby/ruby/blob/trunk/parse.y#L5232 #ifndef RIPPER #define ripper_flush(p) (void)(p) +#define dispatch_scan_event(t) ((void)0) +#define dispatch_delayed_token(t) ((void)0) #else #define ripper_flush(p) ((p)->tokp = (p)->lex.pcur) @@ -5274,6 +5276,7 @@ ripper_dispatch_ignored_scan_event(struc https://github.com/ruby/ruby/blob/trunk/parse.y#L5276 if (!ripper_has_scan_event(parser)) return; (void)ripper_scan_event_val(parser, t); } +#define dispatch_scan_event(t) ripper_dispatch_ignored_scan_event(parser, t) static void ripper_dispatch_delayed_token(struct parser_params *parser, int t) @@ -5288,6 +5291,7 @@ ripper_dispatch_delayed_token(struct par https://github.com/ruby/ruby/blob/trunk/parse.y#L5291 ruby_sourceline = saved_line; parser->tokp = saved_tokp; } +#define dispatch_delayed_token(t) ripper_dispatch_delayed_token(parser, t) #endif /* RIPPER */ #include "ruby/regex.h" @@ -8031,15 +8035,10 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8035 space_seen = 1; break; case '.': { -#ifdef RIPPER - ripper_dispatch_delayed_token(parser, tIGNORED_NL); -#endif - if ((c = nextc()) != '.') { + dispatch_delayed_token(tIGNORED_NL); + if (!peek('.')) { pushback(c); - pushback('.'); -#ifdef RIPPER - ripper_dispatch_scan_event(parser, tSP); -#endif + dispatch_scan_event(tSP); goto retry; } } @@ -8127,35 +8126,29 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8126 if (was_bol()) { /* skip embedded rd document */ if (strncmp(lex_p, "begin", 5) == 0 && ISSPACE(lex_p[5])) { -#ifdef RIPPER - int first_p = TRUE; + int first_p = TRUE; - lex_goto_eol(parser); - ripper_dispatch_scan_event(parser, tEMBDOC_BEG); -#endif + lex_goto_eol(parser); + dispatch_scan_event(tEMBDOC_BEG); for (;;) { lex_goto_eol(parser); -#ifdef RIPPER - if (!first_p) { - ripper_dispatch_scan_event(parser, tEMBDOC); - } - first_p = FALSE; -#endif + if (!first_p) { + dispatch_scan_event(tEMBDOC); + } + first_p = FALSE; c = nextc(); if (c == -1) { compile_error(PARSER_ARG "embedded document meets end of file"); return 0; } if (c != '=') continue; - if (strncmp(lex_p, "end", 3) == 0 && + if (c == '=' && strncmp(lex_p, "end", 3) == 0 && (lex_p + 3 == lex_pend || ISSPACE(lex_p[3]))) { break; } } lex_goto_eol(parser); -#ifdef RIPPER - ripper_dispatch_scan_event(parser, tEMBDOC_END); -#endif + dispatch_scan_event(tEMBDOC_END); goto retry; } } @@ -8559,9 +8552,7 @@ parser_yylex(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8552 c = nextc(); if (c == '\n') { space_seen = 1; -#ifdef RIPPER - ripper_dispatch_scan_event(parser, tSP); -#endif + dispatch_scan_event(tSP); goto retry; /* skip \\n */ } pushback(c); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/