本文整理汇总了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();
//.........这里部分代码省略.........