本文整理汇总了C++中Grammar::buildRuleMap方法的典型用法代码示例。如果您正苦于以下问题:C++ Grammar::buildRuleMap方法的具体用法?C++ Grammar::buildRuleMap怎么用?C++ Grammar::buildRuleMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grammar
的用法示例。
在下文中一共展示了Grammar::buildRuleMap方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
QCoreApplication app (argc, argv);
bool generate_dot = false;
bool generate_report = false;
bool no_lines = false;
bool debug_info = true;
bool troll_copyright = false;
QString file_name = 0;
QStringList args = app.arguments ();
args.removeFirst ();
foreach (QString arg, args)
{
if (arg == QLatin1String ("-h") || arg == QLatin1String ("--help"))
help_me ();
else if (arg == QLatin1String ("-v") || arg == QLatin1String ("--verbose"))
generate_report = true;
else if (arg == QLatin1String ("--dot"))
generate_dot = true;
else if (arg == QLatin1String ("--no-lines"))
no_lines = true;
else if (arg == QLatin1String ("--no-debug"))
debug_info = false;
else if (arg == QLatin1String ("--troll"))
troll_copyright = true;
else if (file_name.isEmpty ())
file_name = arg;
else
qerr << "*** Warning. Ignore argument `" << arg << "'" << endl;
}
if (file_name.isEmpty ())
{
help_me ();
exit (EXIT_SUCCESS);
}
Grammar grammar;
Recognizer p (&grammar, no_lines);
if (! p.parse (file_name))
exit (EXIT_FAILURE);
if (grammar.rules.isEmpty ())
{
qerr << "*** Fatal. No rules!" << endl;
exit (EXIT_FAILURE);
}
else if (grammar.start == grammar.names.end ())
{
qerr << "*** Fatal. No start symbol!" << endl;
exit (EXIT_FAILURE);
}
grammar.buildExtendedGrammar ();
grammar.buildRuleMap ();
Automaton aut (&grammar);
aut.build ();
CppGenerator gen (p, grammar, aut, generate_report);
gen.setDebugInfo (debug_info);
gen.setTrollCopyright (troll_copyright);
gen ();
if (generate_dot)
{
DotGraph genDotFile (qout);
genDotFile (&aut);
}
else if (generate_report)
{
ParseTable genParseTable (qout);
genParseTable(&aut);
}
return EXIT_SUCCESS;
}