本文整理汇总了C++中CModule::toDot方法的典型用法代码示例。如果您正苦于以下问题:C++ CModule::toDot方法的具体用法?C++ CModule::toDot怎么用?C++ CModule::toDot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CModule
的用法示例。
在下文中一共展示了CModule::toDot方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
int i = 1;
while (i < argc) {
// scanning, parsing & semantical analysis
CScanner *s = new CScanner(new ifstream(argv[i]));
CParser *p = new CParser(s);
cout << "parsing '" << argv[i] << "'..." << endl;
CAstNode *ast = p->Parse();
if (p->HasError()) {
const CToken *error = p->GetErrorToken();
cout << "parse error : at " << error->GetLineNumber() << ":"
<< error->GetCharPosition() << " : "
<< p->GetErrorMessage() << endl;
} else {
// AST to TAC conversion
cout << "converting to TAC..." << endl;
CModule *m = new CModule(ast);
// print TAC to console
cout << m << endl;
cout << endl;
// output TAC as .dot and generate a PDF file from it
ofstream out(string(argv[i]) + ".dot");
out << "digraph IR {" << endl
<< " graph [fontname=\"Times New Roman\",fontsize=10];" << endl
<< " node [fontname=\"Courier New\",fontsize=10];" << endl
<< " edge [fontname=\"Times New Roman\",fontsize=10];" << endl
<< endl;
m->toDot(out, 2);
const vector<CScope*> &proc = m->GetSubscopes();
for (size_t p=0; p<proc.size(); p++) {
proc[p]->toDot(out, 2);
}
out << "}" << endl;
out.flush();
ostringstream cmd;
cmd << "dot -Tpdf -o" << argv[i] << ".pdf " << argv[i] << ".dot";
cout << "run the following command to convert the .dot file into a PDF:" << endl
<< " " << cmd.str() <<
endl;
delete m;
}
cout << endl << endl;
i++;
}
cout << "Done." << endl;
return EXIT_SUCCESS;
}