mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 20:05:31 +00:00
Fix #195
This commit is contained in:
parent
2478bd57ab
commit
23436e1fcc
5
peglib.h
5
peglib.h
@ -3132,7 +3132,10 @@ private:
|
|||||||
tok(oom(seq(npd(chr(']')), g["Range"]))), chr(']'),
|
tok(oom(seq(npd(chr(']')), g["Range"]))), chr(']'),
|
||||||
g["Spacing"]);
|
g["Spacing"]);
|
||||||
|
|
||||||
g["Range"] <= cho(seq(g["Char"], chr('-'), g["Char"]), g["Char"]);
|
// NOTE: This is different from The original Brian Ford's paper, and this
|
||||||
|
// modification allows us to specify `[+-]` as a valid char class.
|
||||||
|
g["Range"] <= cho(seq(g["Char"], chr('-'), npd(chr(']')), g["Char"]), g["Char"]);
|
||||||
|
|
||||||
g["Char"] <=
|
g["Char"] <=
|
||||||
cho(seq(chr('\\'), cls("nrt'\"[]\\^")),
|
cho(seq(chr('\\'), cls("nrt'\"[]\\^")),
|
||||||
seq(chr('\\'), cls("0-3"), cls("0-7"), cls("0-7")),
|
seq(chr('\\'), cls("0-3"), cls("0-7"), cls("0-7")),
|
||||||
|
@ -159,7 +159,7 @@ TEST(LeftRecursiveTest, PEG_Class) {
|
|||||||
EXPECT_TRUE(exact(g, "Class", "[az]"));
|
EXPECT_TRUE(exact(g, "Class", "[az]"));
|
||||||
EXPECT_TRUE(exact(g, "Class", "[a-zA-Z-]"));
|
EXPECT_TRUE(exact(g, "Class", "[a-zA-Z-]"));
|
||||||
EXPECT_TRUE(exact(g, "Class", "[a-zA-Z-0-9]"));
|
EXPECT_TRUE(exact(g, "Class", "[a-zA-Z-0-9]"));
|
||||||
EXPECT_FALSE(exact(g, "Class", "[a-]"));
|
EXPECT_TRUE(exact(g, "Class", "[a-]"));
|
||||||
EXPECT_TRUE(exact(g, "Class", "[-a]"));
|
EXPECT_TRUE(exact(g, "Class", "[-a]"));
|
||||||
EXPECT_FALSE(exact(g, "Class", "["));
|
EXPECT_FALSE(exact(g, "Class", "["));
|
||||||
EXPECT_FALSE(exact(g, "Class", "[a"));
|
EXPECT_FALSE(exact(g, "Class", "[a"));
|
||||||
@ -168,7 +168,7 @@ TEST(LeftRecursiveTest, PEG_Class) {
|
|||||||
EXPECT_TRUE(exact(g, "Class", u8"[あ-ん]"));
|
EXPECT_TRUE(exact(g, "Class", u8"[あ-ん]"));
|
||||||
EXPECT_FALSE(exact(g, "Class", u8"あ-ん"));
|
EXPECT_FALSE(exact(g, "Class", u8"あ-ん"));
|
||||||
EXPECT_TRUE(exact(g, "Class", "[-+]"));
|
EXPECT_TRUE(exact(g, "Class", "[-+]"));
|
||||||
EXPECT_FALSE(exact(g, "Class", "[+-]"));
|
EXPECT_TRUE(exact(g, "Class", "[+-]"));
|
||||||
EXPECT_TRUE(exact(g, "Class", "[\\^]"));
|
EXPECT_TRUE(exact(g, "Class", "[\\^]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ TEST(LeftRecursiveTest, PEG_Negated_Class) {
|
|||||||
EXPECT_TRUE(exact(g, "NegatedClass", "[^az]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^az]"));
|
||||||
EXPECT_TRUE(exact(g, "NegatedClass", "[^a-zA-Z-]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^a-zA-Z-]"));
|
||||||
EXPECT_TRUE(exact(g, "NegatedClass", "[^a-zA-Z-0-9]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^a-zA-Z-0-9]"));
|
||||||
EXPECT_FALSE(exact(g, "NegatedClass", "[^a-]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^a-]"));
|
||||||
EXPECT_TRUE(exact(g, "NegatedClass", "[^-a]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^-a]"));
|
||||||
EXPECT_FALSE(exact(g, "NegatedClass", "[^"));
|
EXPECT_FALSE(exact(g, "NegatedClass", "[^"));
|
||||||
EXPECT_FALSE(exact(g, "NegatedClass", "[^a"));
|
EXPECT_FALSE(exact(g, "NegatedClass", "[^a"));
|
||||||
@ -189,7 +189,7 @@ TEST(LeftRecursiveTest, PEG_Negated_Class) {
|
|||||||
EXPECT_TRUE(exact(g, "NegatedClass", u8"[^あ-ん]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", u8"[^あ-ん]"));
|
||||||
EXPECT_FALSE(exact(g, "NegatedClass", u8"^あ-ん"));
|
EXPECT_FALSE(exact(g, "NegatedClass", u8"^あ-ん"));
|
||||||
EXPECT_TRUE(exact(g, "NegatedClass", "[^-+]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^-+]"));
|
||||||
EXPECT_FALSE(exact(g, "NegatedClass", "[^+-]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^+-]"));
|
||||||
EXPECT_TRUE(exact(g, "NegatedClass", "[^^]"));
|
EXPECT_TRUE(exact(g, "NegatedClass", "[^^]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user