ruby-changes:50581
From: nobu <ko1@a...>
Date: Mon, 12 Mar 2018 16:55:23 +0900 (JST)
Subject: [ruby-changes:50581] nobu:r62727 (trunk): ripper: fix escaped space
nobu 2018-03-12 16:55:17 +0900 (Mon, 12 Mar 2018) New Revision: 62727 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62727 Log: ripper: fix escaped space * parse.y: use tSP same as ripper instead of tSPACE. [ruby-core:86080] [Bug #14597] * ext/ripper/eventids2.c: tSP is defined in ripper.c now. Modified files: trunk/ext/ripper/eventids2.c trunk/parse.y trunk/test/ripper/test_scanner_events.rb Index: ext/ripper/eventids2.c =================================================================== --- ext/ripper/eventids2.c (revision 62726) +++ ext/ripper/eventids2.c (revision 62727) @@ -1,12 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c#L1 -#define tIGNORED_NL (tLAST_TOKEN + 1) -#define tCOMMENT (tLAST_TOKEN + 2) -#define tEMBDOC_BEG (tLAST_TOKEN + 3) -#define tEMBDOC (tLAST_TOKEN + 4) -#define tEMBDOC_END (tLAST_TOKEN + 5) -#define tSP (tLAST_TOKEN + 6) -#define tHEREDOC_BEG (tLAST_TOKEN + 7) -#define tHEREDOC_END (tLAST_TOKEN + 8) -#define k__END__ (tLAST_TOKEN + 9) +enum { + tIGNORED_NL = tLAST_TOKEN + 1, + tCOMMENT, + tEMBDOC_BEG, + tEMBDOC, + tEMBDOC_END, + tHEREDOC_BEG, + tHEREDOC_END, + k__END__ +}; typedef struct { ID ripper_id_backref; Index: test/ripper/test_scanner_events.rb =================================================================== --- test/ripper/test_scanner_events.rb (revision 62726) +++ test/ripper/test_scanner_events.rb (revision 62727) @@ -840,6 +840,11 @@ class TestRipper::ScannerEvents < Test:: https://github.com/ruby/ruby/blob/trunk/test/ripper/test_scanner_events.rb#L840 scan('sp', "%w( w )") assert_equal [], scan('sp', "p(/ /)") + + assert_equal ["\\\n"], + scan('sp', "\\\n") + assert_equal ['\ '], + scan('sp', '\ ') end # `nl' event always means End-Of-Statement. Index: parse.y =================================================================== --- parse.y (revision 62726) +++ parse.y (revision 62727) @@ -838,7 +838,7 @@ static void token_info_pop(struct parser https://github.com/ruby/ruby/blob/trunk/parse.y#L838 %token <id> '.' /* escaped chars, should be ignored otherwise */ %token <id> '\\' "backslash" -%token tSPACE "escaped space" +%token tSP "escaped space" %token <id> '\t' "escaped horizontal tab" %token <id> '\f' "escaped form feed" %token <id> '\r' "escaped carriage return" @@ -8106,7 +8106,7 @@ parser_yylex(struct parser_params *p) https://github.com/ruby/ruby/blob/trunk/parse.y#L8106 dispatch_scan_event(p, tSP); goto retry; /* skip \\n */ } - if (c == ' ') return tSPACE; + if (c == ' ') return tSP; if (ISSPACE(c)) return c; pushback(p, c); return '\\'; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/