本文整理汇总了C++中ASTNode::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::Accept方法的具体用法?C++ ASTNode::Accept怎么用?C++ ASTNode::Accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::Accept方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestLogic
void ParserFileTestTest::TestLogic(void) {
ParserAPI test;
TIME(test.ParseFile(FILE_PATH));
if (test.HasError()) {
__list_parsing_errors(test);
ASSERT(!test.HasError()); // certain failure here, to stop the test
}
ASTNode* root = test.GetAST();
ASSERT(root != 0x00);
FileOutputStream _fout("treeVisualisation.txt", FileOutputStream::Mode::Truncate());
FileOutputStream _foutxml("treeVisualisation.xml", FileOutputStream::Mode::Truncate());
BufferedOutputStream fout(_fout);
BufferedOutputStream foutxml(_foutxml);
ASTTreeVisualisationVisitor visitor(fout);
ASTMITTreeVisualizerXMLProducerVisitor mitvis(foutxml);
TIME(root->Accept(&visitor))
TIME(root->Accept(&mitvis))
test.DeleteListAndAST();
}
示例2: TestLogic
void RunFileTest::TestLogic(void) {
ASTNode* root;
ParserAPI test;
test.ParseFile(FILE_PATH);
if (test.HasError()) {
logger->Notice("Parsing errors for file " FILE_PATH);
__list_parsing_errors(test);
// Try another file
logger->Notice("trying \"./sin_tun_test.sin\"");
ParserAPI test0;
test0.ParseFile("sin_run_test.sin");
if (test0.HasError()) {
logger->Notice("Parsing errors for file ./sin_run_test.sin");
__list_parsing_errors(test0);
ASSERT(!test0.HasError()); // certain failure here, to stop the test
}
else {
logger->Notice("fallback sin_run_test.sin passed");
root = test0.GetAST();
}
}
else
root = test.GetAST();
ASSERT(root != 0x00);
FileOutputStream _foutxml("RunTreeVisualisation.xml", FileOutputStream::Mode::Truncate());
FileOutputStream _fouttxt("RunTreeVisualisation.txt", FileOutputStream::Mode::Truncate());
FileOutputStream _ctrltxt("RunTreeCtrlVisualisation.txt", FileOutputStream::Mode::Truncate());
FileOutputStream _metatxt("ShiftToMetaEvaluatorASTVisitor.txt", FileOutputStream::Mode::Truncate());
BufferedOutputStream foutxml(_foutxml);
BufferedOutputStream fouttxt(_fouttxt);
BufferedOutputStream ctrltxt(_ctrltxt);
BufferedOutputStream metatxt(_metatxt);
ASTTreeCtrlVisitor ctrlvis(ctrltxt);
ASTTreeVisualisationVisitor visitor(fouttxt);
//ASTTreeVisualisationVisitor metaVisualVisitor(metatxt);
//ASTMITTreeVisualizerXMLProducerVisitor mitvis(foutxml);
//ASTCloneVisitor cloneVisitor;
//ASTUnparseTreeVisitor uparseVisitor;
//
root->Accept(&visitor);
root->Accept(&ctrlvis);
//root->Accept(&mitvis);
//root->Accept(&uparseVisitor);
//root->Accept(&cloneVisitor);
//String unpasedString1 = uparseVisitor.UnparsedString();
//uparseVisitor.CleanUnparsedString();
//cloneVisitor.Root()->Accept(&uparseVisitor);
//String unpasedString2 = uparseVisitor.UnparsedString();
//
//SINASSERT(unpasedString1 == unpasedString2);
//
//static_cast<OutputStream&>(STDOUT) << "\n\n" << unpasedString2 << "\n\n\n";
foutxml.flush();
fouttxt.flush();
ctrltxt.flush();
//ASTNode & lastKid = static_cast<ASTNode &>(*root->rbegin());
//cloneVisitor.Resset();
//lastKid.Accept(&cloneVisitor);
//uparseVisitor.CleanUnparsedString();
//ASTNode * cloneRoot = cloneVisitor.Root();
//cloneRoot->Accept(&uparseVisitor);
//static_cast<OutputStream&>(STDOUT) << "\n\n" << uparseVisitor.UnparsedString() << "\n\n\n";
//cloneVisitor.DeleteListAndAST();
VM::VirtualState vs;
vs.SetPrintHandler(&__print_handler);
Library::Library lib;
Library::Functions::print print;
Library::Functions::println println;
Library::Functions::arguments arguments;
Library::Functions::totalarguments totalarguments;
Library::Functions::tostring tostring;
Library::Functions::strtonum strtonum;
Library::Functions::typeof typeof;
Library::Functions::fileopen fileopen;
Library::Functions::fileread fileread;
lib.InstallFunction(&print );
lib.InstallFunction(&println );
lib.InstallFunction(&arguments );
lib.InstallFunction(&totalarguments );
lib.InstallFunction(&tostring );
lib.InstallFunction(&strtonum );
lib.InstallFunction(&typeof );
lib.InstallFunction(&fileopen );
lib.InstallFunction(&fileread );
//.........这里部分代码省略.........
示例3: VisitNextASTNode
void ASTCodeGenVisitor::VisitNextASTNode(ASTNode* s) {
ASTNode* next = s->GetNextASTNode();
if (next) {
next->Accept(*this);
}
}