Skip to content

Commit 21d2d11

Browse files
authored
Merge pull request #38 from alexcrichton/underscore
Lex underscore in unicode escapes
2 parents ea71984 + 8d10934 commit 21d2d11

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

src/stable.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -722,28 +722,12 @@ fn backslash_u<I>(chars: &mut I) -> bool
722722
{
723723
next_ch!(chars @ '{');
724724
next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F');
725-
let b = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '}');
726-
if b == '}' {
727-
return true
728-
}
729-
let c = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '}');
730-
if c == '}' {
731-
return true
732-
}
733-
let d = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '}');
734-
if d == '}' {
735-
return true
736-
}
737-
let e = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '}');
738-
if e == '}' {
739-
return true
740-
}
741-
let f = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '}');
742-
if f == '}' {
743-
return true
725+
loop {
726+
let c = next_ch!(chars @ '0'...'9' | 'a'...'f' | 'A'...'F' | '_' | '}');
727+
if c == '}' {
728+
return true;
729+
}
744730
}
745-
next_ch!(chars @ '}');
746-
true
747731
}
748732

749733
fn float(input: &str) -> PResult<()> {

tests/test.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ fn roundtrip() {
4747
");
4848
roundtrip("'a");
4949
roundtrip("'static");
50+
roundtrip("'\\u{10__FFFF}'");
51+
roundtrip("\"\\u{10_F0FF__}foo\\u{1_0_0_0__}\"");
5052
}
5153

5254
#[test]

0 commit comments

Comments
 (0)