当前位置: 首页>>代码示例>>C++>>正文


C++ PNode::addChild方法代码示例

本文整理汇总了C++中PNode::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ PNode::addChild方法的具体用法?C++ PNode::addChild怎么用?C++ PNode::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PNode的用法示例。


在下文中一共展示了PNode::addChild方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reduceExp

PNode* SLRParser::reduceExp(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Exp";

	//Simple-exp
	auto q_simpleexp = parsing_stack.top().node;
	//res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	if(parsing_stack.top().cell.row.id == "Comparison-op")
	{
		//Comparison-op
		auto q_comparisonop = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();
		//Simple-exp
		auto q_simpleexp2 = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();

		res->addChild(q_simpleexp2);
		res->addChild(q_comparisonop);
		res->addChild(q_simpleexp);
	}else{
		res->addChild(q_simpleexp);
	}
	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:30,代码来源:SLRParser.cpp

示例2: reduceRepeatstmt

PNode* SLRParser::reduceRepeatstmt(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Repeatstmt";

	//Exp
	auto q_exp = parsing_stack.top().node;
	//res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	//UNTIL
	reduceMatch(parsing_stack);
	//res->addChild(reduceMatch(parsing_stack));
	//StSeq
	auto q_stseq = parsing_stack.top().node;
	//res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	//REPEAT
	reduceMatch(parsing_stack);
	//res->addChild(reduceMatch(parsing_stack));

	res->addChild(q_stseq);
	res->addChild(q_exp);

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:27,代码来源:SLRParser.cpp

示例3: reduceTerm

PNode* SLRParser::reduceTerm(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Term";

	//Factor
	auto q_factor = parsing_stack.top().node;
	//res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	if(parsing_stack.top().cell.row.id == "Mulop")
	{
		//Mulop
		auto q_mulop = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();
		//Term
		auto q_term = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();

		res->addChild(q_term);
		res->addChild(q_mulop);
		res->addChild(q_factor);
	}else
	{
		res->addChild(q_factor);
	}

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:32,代码来源:SLRParser.cpp

示例4: reduceFactor

PNode* SLRParser::reduceFactor(std::stack<stackElement>& parsing_stack)
{
	stackElement e= parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Factor";

	if(e.cell.row.id == "OPEN_PAREN")
	{
		//OPEN_PAREN
		//res->addChild(reduceMatch(parsing_stack));
		auto q_openparen = reduceMatch(parsing_stack);
		//Exp
		res->addChild(parsing_stack.top().node);
		parsing_stack.pop();
		//CLOSE_PAREN
		//res->addChild(reduceMatch(parsing_stack));
		auto q_closeparen = reduceMatch(parsing_stack);
	}else if(e.cell.row.id == "NUMBER")
	{
		//NUMBER
		res->addChild(reduceMatch(parsing_stack));
	}else if(e.cell.row.id == "ID")
	{
		//ID
		res->addChild(reduceID(parsing_stack));
	}
	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:29,代码来源:SLRParser.cpp

示例5: reduceIFstmt

PNode* SLRParser::reduceIFstmt(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "IFstmt";

	//END
	reduceMatch(parsing_stack);
	//res->addChild(reduceMatch(parsing_stack));
	//StSeq
	auto q_stseq1 = parsing_stack.top().node;
	//res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	if(parsing_stack.top().cell.row.id == "THEN")
	{
		//THEN
		reduceMatch(parsing_stack);
		//res->addChild(reduceMatch(parsing_stack));
		//Exp
		auto q_exp = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();
		//IF
		reduceMatch(parsing_stack);
		//res->addChild(reduceMatch(parsing_stack));

		res->addChild(q_exp);
		res->addChild(q_stseq1);
	}else if(parsing_stack.top().cell.row.id == "ELSE")
	{
		//ELSE
		reduceMatch(parsing_stack);
		//res->addChild(reduceMatch(parsing_stack));
		//StSeq
		auto q_stseq2 = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();
		//THEN
		reduceMatch(parsing_stack);
		//res->addChild(reduceMatch(parsing_stack));
		//Exp
		auto q_exp = parsing_stack.top().node;
		//res->addChild(parsing_stack.top().node);
		parsing_stack.pop();
		//IF
		reduceMatch(parsing_stack);
		//res->addChild(reduceMatch(parsing_stack));

		res->addChild(q_exp);
		res->addChild(q_stseq2);
		res->addChild(q_stseq1);
	}

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:56,代码来源:SLRParser.cpp

示例6: reduceStatement

PNode* SLRParser::reduceStatement(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "";
	res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:10,代码来源:SLRParser.cpp

示例7: reduceReadstmt

PNode* SLRParser::reduceReadstmt(std::stack<stackElement>& parsing_stack)
{
	PNode* id = reduceID(parsing_stack);
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "read-stmt";
	res->addChild(id);
	parsing_stack.pop();
	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:10,代码来源:SLRParser.cpp

示例8: reduceComparison

PNode* SLRParser::reduceComparison(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Comparison-op";

	//LESS_THAN || EQUAL
	res->addChild(reduceMatch(parsing_stack));

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:12,代码来源:SLRParser.cpp

示例9: reduceAddop

PNode* SLRParser::reduceAddop(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Addop";

	//ADD_OP || MINUS_OP
	res->addChild(reduceMatch(parsing_stack));

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:12,代码来源:SLRParser.cpp

示例10: reduceAssignstmt

PNode* SLRParser::reduceAssignstmt(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Assignstmt";

	//Exp
	auto q_exp = parsing_stack.top().node;
	//res->addChild(parsing_stack.top().node);
	parsing_stack.pop();
	//ASSIGNMENT_OP
	reduceMatch(parsing_stack);
	//res->addChild(reduceMatch(parsing_stack));
	//ID
	auto q_id = reduceID(parsing_stack);
	//res->addChild(reduceID(parsing_stack));

	res->addChild(q_id);
	res->addChild(q_exp);

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:23,代码来源:SLRParser.cpp

示例11: reduceStSeq

PNode* SLRParser::reduceStSeq(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "StSeq";
	//statement
	auto q_stmt = parsing_stack.top().node;
	parsing_stack.pop();
	if(parsing_stack.top().cell.row.id == "SEMICOLON"){
		//semicolon
		//res->addChild(reduceMatch(parsing_stack));
		auto q_semicolon = reduceMatch(parsing_stack);
		//stseq
		auto q_stseq = parsing_stack.top().node;
		parsing_stack.pop();

		res->addChild(q_stseq);
		res->addChild(q_stmt);
	}else{
		res->addChild(q_stmt);
	}
	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:24,代码来源:SLRParser.cpp

示例12: reduceWritestmt

PNode* SLRParser::reduceWritestmt(std::stack<stackElement>& parsing_stack)
{
	stackElement e = parsing_stack.top();
	PNode* res = Services::memory->alloc<PNode>();
	new (res) PNode();
	res->Tag = "Writestmt";

	//Exp
	res->addChild(parsing_stack.top().node);
	parsing_stack.pop();

	//WRITE
	reduceMatch(parsing_stack);
	//res->addChild(reduceMatch(parsing_stack));

	return res;
}
开发者ID:MoustaphaSaad,项目名称:Compiler-Tools,代码行数:17,代码来源:SLRParser.cpp


注:本文中的PNode::addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。