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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-03-12 07:55:17 +00:00
parent 26eb7b3d8e
commit 7773cfa496
3 changed files with 17 additions and 11 deletions

View File

@ -1,12 +1,13 @@
#define tIGNORED_NL (tLAST_TOKEN + 1) enum {
#define tCOMMENT (tLAST_TOKEN + 2) tIGNORED_NL = tLAST_TOKEN + 1,
#define tEMBDOC_BEG (tLAST_TOKEN + 3) tCOMMENT,
#define tEMBDOC (tLAST_TOKEN + 4) tEMBDOC_BEG,
#define tEMBDOC_END (tLAST_TOKEN + 5) tEMBDOC,
#define tSP (tLAST_TOKEN + 6) tEMBDOC_END,
#define tHEREDOC_BEG (tLAST_TOKEN + 7) tHEREDOC_BEG,
#define tHEREDOC_END (tLAST_TOKEN + 8) tHEREDOC_END,
#define k__END__ (tLAST_TOKEN + 9) k__END__
};
typedef struct { typedef struct {
ID ripper_id_backref; ID ripper_id_backref;

View File

@ -838,7 +838,7 @@ static void token_info_pop(struct parser_params*, const char *token, const rb_co
%token <id> '.' %token <id> '.'
/* escaped chars, should be ignored otherwise */ /* escaped chars, should be ignored otherwise */
%token <id> '\\' "backslash" %token <id> '\\' "backslash"
%token tSPACE "escaped space" %token tSP "escaped space"
%token <id> '\t' "escaped horizontal tab" %token <id> '\t' "escaped horizontal tab"
%token <id> '\f' "escaped form feed" %token <id> '\f' "escaped form feed"
%token <id> '\r' "escaped carriage return" %token <id> '\r' "escaped carriage return"
@ -8106,7 +8106,7 @@ parser_yylex(struct parser_params *p)
dispatch_scan_event(p, tSP); dispatch_scan_event(p, tSP);
goto retry; /* skip \\n */ goto retry; /* skip \\n */
} }
if (c == ' ') return tSPACE; if (c == ' ') return tSP;
if (ISSPACE(c)) return c; if (ISSPACE(c)) return c;
pushback(p, c); pushback(p, c);
return '\\'; return '\\';

View File

@ -840,6 +840,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
scan('sp', "%w( w )") scan('sp', "%w( w )")
assert_equal [], assert_equal [],
scan('sp', "p(/ /)") scan('sp', "p(/ /)")
assert_equal ["\\\n"],
scan('sp', "\\\n")
assert_equal ['\ '],
scan('sp', '\ ')
end end
# `nl' event always means End-Of-Statement. # `nl' event always means End-Of-Statement.