diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-12 07:55:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-12 07:55:17 +0000 |
commit | 7773cfa496fe04b4d4712beddfdcca3c052ee153 (patch) | |
tree | 39e22bb5e9bd034330c08e6114a6b5e104b54962 | |
parent | 26eb7b3d8e011fa31f5a7f4c8c95440d11488c82 (diff) | |
download | ruby-7773cfa496fe04b4d4712beddfdcca3c052ee153.tar.gz |
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
-rw-r--r-- | ext/ripper/eventids2.c | 19 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | test/ripper/test_scanner_events.rb | 5 |
3 files changed, 17 insertions, 11 deletions
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c index 04a40e0da7..334d9f557b 100644 --- a/ext/ripper/eventids2.c +++ b/ext/ripper/eventids2.c @@ -1,12 +1,13 @@ -#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; @@ -838,7 +838,7 @@ static void token_info_pop(struct parser_params*, const char *token, const rb_co %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) 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 '\\'; diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index 034748d805..c9fce34a77 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -840,6 +840,11 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase 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. |