Skip to content

Commit

Permalink
Support multiple elements \u syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Dec 1, 2016
1 parent fed40b4 commit 0f08914
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions mrbgems/mruby-compiler/core/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 4 additions & 0 deletions test/t/unicode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@
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

0 comments on commit 0f08914

Please sign in to comment.