diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-12 05:16:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-12 05:16:03 +0000 |
commit | 88edab89f4a0cabc9e10f2b8c8cf81cc3eda68c9 (patch) | |
tree | c689e807c1e03741433c75e4969b9042fb2dc6f9 | |
parent | a2ba489e2eff648b98054b1252e45a3c0643ab8e (diff) | |
download | ruby-88edab89f4a0cabc9e10f2b8c8cf81cc3eda68c9.tar.gz |
parse.y: simplify
* parse.y (parser_yylex): reduce RIPPER ifdefs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | parse.y | 43 |
1 files changed, 17 insertions, 26 deletions
@@ -5232,6 +5232,8 @@ ripper_yylval_id(ID x) #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(struct parser_params *parser, int t) 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 parser_params *parser, int t) 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 *parser) 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 *parser) 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 *parser) 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); |