本文整理汇总了C++中Grammar::rules方法的典型用法代码示例。如果您正苦于以下问题:C++ Grammar::rules方法的具体用法?C++ Grammar::rules怎么用?C++ Grammar::rules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grammar
的用法示例。
在下文中一共展示了Grammar::rules方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: functionTags
//===========================================================================
void functionTags(Grammar & rules, Element & rule, bool reset, bool mark) {
if (reset || mark) {
size_t maxId = 0;
for (auto && elem : rules.rules()) {
if (reset)
const_cast<Element &>(elem).flags &= ~Element::fFunction;
maxId = max((size_t)elem.id, maxId);
}
if (mark) {
vector<bool> used(maxId, false);
addFunctionTags(rules, rule, used);
}
}
}
示例2: copyRules
//===========================================================================
bool copyRules(
Grammar & out,
Grammar const & src,
string_view rootname,
bool failIfExists
) {
auto root = src.element(rootname);
if (!root) {
logMsgError() << "Rule not found, " << rootname;
return false;
}
auto & rules = const_cast<set<Element> &>(out.rules());
auto ib = rules.insert(*root);
if (!ib.second) {
if (failIfExists) {
logMsgError() << "Rule already exists, " << rootname;
return false;
}
return true;
}
auto & elem = *ib.first;
if ((elem.flags & Element::fFunction)
&& (elem.flags & Element::fCharEvents)
) {
logMsgError() << "Rule with both Function and Char, " << elem.value;
return false;
}
if ((elem.flags & Element::fStartEvents) == Element::fStartEvents) {
logMsgError() << "Rule with both Start and Start+, " << elem.value;
return false;
}
if ((elem.flags & Element::fEndEvents) == Element::fEndEvents) {
logMsgError() << "Rule with both End and End+, " << elem.value;
return false;
}
if ((elem.flags & Element::fCharEvents) == Element::fCharEvents) {
logMsgError() << "Rule with both Char and Char+, " << elem.value;
return false;
}
return copyRequiredDeps(out, src, elem);
}
示例3: normalize
//===========================================================================
void normalize(Grammar & rules) {
rules.clearEvents();
for (auto && rule : rules.rules()) {
normalize(const_cast<Element &>(rule), nullptr, rules);
}
}
示例4: merge
//===========================================================================
void merge(Grammar & rules) {
for (auto && rule : rules.rules()) {
merge(const_cast<Element &>(rule), rules);
}
}