diff options
| author | Nobuyoshi Nakada <[email protected]> | 2016-12-01 14:37:59 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <[email protected]> | 2016-12-01 16:48:43 +0900 |
| commit | 0f08914ac0d433545a4224ee1c3f8d3eb8d51e68 (patch) | |
| tree | 1b950421591cbd447d61f498c6028fa443b19c38 | |
| parent | fed40b44b8ec56c977b85be65ff460dcf713dc3c (diff) | |
| download | mruby-0f08914ac0d433545a4224ee1c3f8d3eb8d51e68.tar.gz mruby-0f08914ac0d433545a4224ee1c3f8d3eb8d51e68.zip | |
Support multiple elements \u syntax
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 14 | ||||
| -rw-r--r-- | test/t/unicode.rb | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 65b89bed3..f0c45b85b 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -3995,6 +3995,20 @@ parse_string(parser_state *p) tokadd(p, '\\'); tokadd(p, c); } + else if (c == 'u' && peek(p, '{')) { + /* \u{xxxx xxxx xxxx} form */ + nextc(p); + while (1) { + do c = nextc(p); while (ISSPACE(c)); + if (c == '}') break; + pushback(p, c); + c = read_escape_unicode(p, 8); + if (c < 0) break; + tokadd(p, -c); + } + if (hinf) + hinf->line_head = FALSE; + } else { pushback(p, c); tokadd(p, read_escape(p)); diff --git a/test/t/unicode.rb b/test/t/unicode.rb index b8c54ca66..8622ae08a 100644 --- a/test/t/unicode.rb +++ b/test/t/unicode.rb @@ -33,3 +33,7 @@ assert('braced \u notation test') do assert_equal("\xF0\x90\x80\x80", "\u{10000}") assert_equal("\xF4\x8F\xBF\xBF", "\u{10FFFF}") end + +assert('braced multiple \u notation test') do + assert_equal("ABC", "\u{41 42 43}") +end |
