[pseudo] Fix the wrong rule ids in ForestTest.

This commit is contained in:
Haojian Wu 2022-03-26 00:04:41 +01:00
parent 41e69fb245
commit 16eaa5240e
1 changed files with 7 additions and 7 deletions

View File

@ -90,8 +90,8 @@ TEST_F(ForestTest, DumpBasic) {
TEST_F(ForestTest, DumpAmbiguousAndRefs) {
build(R"cpp(
_ := type
type := class-type # rule 1
type := enum-type # rule 2
type := class-type # rule 3
type := enum-type # rule 4
class-type := shared-type
enum-type := shared-type
shared-type := IDENTIFIER)cpp");
@ -106,21 +106,21 @@ TEST_F(ForestTest, DumpAmbiguousAndRefs) {
symbol("shared-type"), ruleFor("shared-type"), {Terminals.begin()});
const auto *ClassType = &Arena.createSequence(
symbol("class-type"), ruleFor("class-type"), {SharedType});
const auto *Enumtype = &Arena.createSequence(
const auto *EnumType = &Arena.createSequence(
symbol("enum-type"), ruleFor("enum-type"), {SharedType});
const auto *Alternative1 =
&Arena.createSequence(symbol("type"), /*RuleID=*/1, {ClassType});
&Arena.createSequence(symbol("type"), /*RuleID=*/3, {ClassType});
const auto *Alternative2 =
&Arena.createSequence(symbol("type"), /*RuleID=*/2, {Enumtype});
&Arena.createSequence(symbol("type"), /*RuleID=*/4, {EnumType});
const auto *Type =
&Arena.createAmbiguous(symbol("type"), {Alternative1, Alternative2});
EXPECT_EQ(Type->dumpRecursive(*G),
"[ 0, end) type := <ambiguous>\n"
"[ 0, end) ├─class-type := shared-type\n"
"[ 0, end) ├─type := class-type\n"
"[ 0, end) │ └─class-type := shared-type\n"
"[ 0, end) │ └─shared-type := IDENTIFIER #1\n"
"[ 0, end) │ └─IDENTIFIER := tok[0]\n"
"[ 0, end) └─enum-type := shared-type\n"
"[ 0, end) └─type := enum-type\n"
"[ 0, end) └─enum-type := shared-type\n"
"[ 0, end) └─shared-type := IDENTIFIER =#1\n"
"[ 0, end) └─IDENTIFIER := tok[0]\n");