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


C++ TNode::setData方法代码示例

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


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

示例1: stmt

void Parser::stmt(TNode* parent) {
	// stmt: call | while | if | assign
	if(nextToken.name == "call") {
		// call: "procedure" proc_name ";"
		line++;
		TNode* callNode = createASTNode("CALL_NODE", nextToken.name, parent, line, currentProc);
		controller->statementTable->insertStatement(callNode);
		match("call");



		string newProcedure = procedureName();
		callNode->setData(newProcedure);
		int procIndex = getProcedureIndex(newProcedure);

		if(callees.find(currentProc) != callees.end()) {
			callees[currentProc].insert(make_pair(line, newProcedure));

			stack<int> tempStack = stack<int>();
			while(containerStack.size() > 0) {
				int top = containerStack.top(); containerStack.pop();
				tempStack.push(top);
				callees[currentProc].insert(make_pair(top, newProcedure));
			}

			while(tempStack.size() > 0) {
				containerStack.push(tempStack.top());
				tempStack.pop();
			}
		} else {
			set<std::pair<int, string>> calls;
			calls.insert(std::make_pair(line, newProcedure));

			stack<int> tempStack = stack<int>();
			while(containerStack.size() > 0) {
				int top = containerStack.top(); containerStack.pop();
				tempStack.push(top);
				calls.insert(std::make_pair(top, newProcedure));
			}

			while(tempStack.size() > 0) {
				containerStack.push(tempStack.top());
				tempStack.pop();
			}

			callees.insert(std::pair<int, set<pair<int, string>>>(currentProc, calls));
		}

		controller->callsTable->insertCalls(currentProc, procIndex);
		callStatements.insert(pair<int, string>(line, newProcedure));
		match(";");

		populateProcAndContainers(procIndex, line);
		populateFollows(line, false, prev, callNode);
		populateParent(parent, line);

	} else if(nextToken.name == "while") {
		// while: "while" var_name "{" stmtLst "}"
		line++;
		TNode* whileNode = createASTNode("WHILE_NODE", nextToken.name, parent, line, currentProc);
		controller->statementTable->insertStatement(whileNode);
		match("while");

		populateFollows(line, true, prev, whileNode);
		populateParent(parent, line);
		containerStack.push(line);
		containerNodeStack.push(whileNode);
		populateProcAndContainers(currentProc, line);


		//TNode* whileVarNode = createASTNode("VAR_NODE", nextToken.name, whileNode, line, currentProc);
		whileNode->setData(nextToken.name);
		variableName();

		populateUses(line, currentProc);

		match("{");
		TNode* whileStmtLstNode = createASTNode("STMTLST_NODE", "", whileNode, line, currentProc);
		stmtLst(whileStmtLstNode);
		match("}");
		 
		previousStmt = containerStack.top(); containerStack.pop();
		prev = containerNodeStack.top(); containerNodeStack.pop();
		
	} else if(nextToken.name == "if") {
		// if: "if" var_name "then" "{" stmtLst "}" "else" "{" stmtLst "}"
		++line;
		TNode* ifNode = createASTNode("IF_NODE", nextToken.name, parent, line, currentProc);
		controller->statementTable->insertStatement(ifNode);
		match("if");

		populateFollows(line, true, prev, ifNode);
		populateParent(parent, line);
		containerStack.push(line);
		containerNodeStack.push(ifNode);
		populateProcAndContainers(currentProc, line);

		//TNode* ifVarNode = createASTNode("VAR_NODE", nextToken.name, ifNode, line, currentProc);
		ifNode->setData(nextToken.name);
		variableName();
//.........这里部分代码省略.........
开发者ID:khzaw,项目名称:xcalibur,代码行数:101,代码来源:Parser.cpp


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