本文整理汇总了C++中CFG::first方法的典型用法代码示例。如果您正苦于以下问题:C++ CFG::first方法的具体用法?C++ CFG::first怎么用?C++ CFG::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFG
的用法示例。
在下文中一共展示了CFG::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(TestCFG, Copy) {
cfg << "<S> ::= <S>s|<B><C><D>";
cfg << "<A> ::= <S><A>a|";
cfg << "<B> ::= <C>c";
cfg << "<C> ::= <B>b|<S>s|<A>";
cfg << "<D> ::= <D>d|<D><B>|";
CFG copy = cfg;
ASSERT_EQ(set({"c"}), copy.first("<S>"));
ASSERT_EQ(set({"c"}), copy.first("<A>"));
ASSERT_EQ(set({"c"}), copy.first("<B>"));
ASSERT_EQ(set({"c"}), copy.first("<C>"));
ASSERT_EQ(set({"c", "d"}), copy.first("<D>"));
ASSERT_FALSE(copy.nullable("<S>"));
ASSERT_TRUE(copy.nullable("<A>"));
ASSERT_FALSE(copy.nullable("<B>"));
ASSERT_TRUE(copy.nullable("<C>"));
ASSERT_TRUE(copy.nullable("<D>"));
auto test = CFG::create(DidacticNotation());
test << "S -> S s | B C D";
test << "A -> S A a | ";
test << "B -> C c";
test << "C -> B b | S s | A";
test << "D -> D d | D B | ";
CFG testCopy = test;
ASSERT_EQ(set({"c"}), testCopy.first("S"));
ASSERT_EQ(set({"c"}), testCopy.first("A"));
ASSERT_EQ(set({"c"}), testCopy.first("B"));
ASSERT_EQ(set({"c"}), testCopy.first("C"));
ASSERT_EQ(set({"c", "d"}), testCopy.first("D"));
ASSERT_FALSE(testCopy.nullable("S"));
ASSERT_TRUE(testCopy.nullable("A"));
ASSERT_FALSE(testCopy.nullable("B"));
ASSERT_TRUE(testCopy.nullable("C"));
ASSERT_TRUE(testCopy.nullable("D"));
}