1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
if (typeof parseRegExp === 'undefined')
quit();
load(libdir + "regexp_parse.js");
// LeadSurrogate TrailSurrogate
test("\\uD83D\\uDC38", all_flags,
Atom("\uD83D\uDC38"));
test("X\\uD83D\\uDC38Y", no_unicode_flags,
Atom("X\uD83D\uDC38Y"));
test("X\\uD83D\\uDC38Y", unicode_flags,
Text([
Atom("X"),
Atom("\uD83D\uDC38"),
Atom("Y")
]));
// LeadSurrogate
test_mix("\\uD83D", no_unicode_flags,
Atom("\uD83D"));
test("\\uD83D", unicode_flags,
Alternative([
Atom("\uD83D"),
NegativeLookahead(CharacterClass([["\uDC00", "\uDFFF"]]))
]));
test("X\\uD83DY", unicode_flags,
Alternative([
Atom("X"),
Alternative([
Atom("\uD83D"),
NegativeLookahead(CharacterClass([["\uDC00", "\uDFFF"]]))
]),
Atom("Y")
]));
// TrailSurrogate
test_mix("\\uDC38", no_unicode_flags,
Atom("\uDC38"));
test("\\uDC38", unicode_flags,
Alternative([
Assertion("NOT_AFTER_LEAD_SURROGATE"),
Atom("\uDC38"),
]));
test("X\\uDC38Y", unicode_flags,
Alternative([
Atom("X"),
Alternative([
Assertion("NOT_AFTER_LEAD_SURROGATE"),
Atom("\uDC38"),
]),
Atom("Y")
]));
// NonSurrogate / Hex4Digits
test_mix("\\u0000", all_flags,
Atom("\u0000"));
test_mix("\\uFFFF", all_flags,
Atom("\uFFFF"));
// braced HexDigits
test_mix("\\u{0000}", unicode_flags,
Atom("\u0000"));
test_mix("\\u{FFFF}", unicode_flags,
Atom("\uFFFF"));
test("\\u{1F438}", unicode_flags,
Atom("\uD83D\uDC38"));
test("X\\u{1F438}Y", unicode_flags,
Text([
Atom("X"),
Atom("\uD83D\uDC38"),
Atom("Y")
]));
test("\\u{D83D}", unicode_flags,
Alternative([
Atom("\uD83D"),
NegativeLookahead(CharacterClass([["\uDC00", "\uDFFF"]]))
]));
test("X\\u{D83D}Y", unicode_flags,
Alternative([
Atom("X"),
Alternative([
Atom("\uD83D"),
NegativeLookahead(CharacterClass([["\uDC00", "\uDFFF"]]))
]),
Atom("Y")
]));
test("\\u{DC38}", unicode_flags,
Alternative([
Assertion("NOT_AFTER_LEAD_SURROGATE"),
Atom("\uDC38"),
]));
test("X\\u{DC38}Y", unicode_flags,
Alternative([
Atom("X"),
Alternative([
Assertion("NOT_AFTER_LEAD_SURROGATE"),
Atom("\uDC38"),
]),
Atom("Y")
]));
|