本文整理汇总了C++中ParseNode::getToken方法的典型用法代码示例。如果您正苦于以下问题:C++ ParseNode::getToken方法的具体用法?C++ ParseNode::getToken怎么用?C++ ParseNode::getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParseNode
的用法示例。
在下文中一共展示了ParseNode::getToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addSymbols
// pre: the state 'lastState' is a newly created state that has only a lambda transition coming in to it.
// post: lastState is updated to a new state that has the property that only lambda transitions go to it.
void addSymbols(ParseNode::iterator_type begin, ParseNode::iterator_type end, FaSymbolTable &symTab, FaRuleIr &ruleIr, FaNfa *nfa, unsigned &lastState)
{
for(ParseNode::iterator_type i = begin; i != end; ++i)
{
assert((*i)->getToken() == RULE_rcsymbol);
unsigned symbolHeadToken = (*(*i)->begin())->getToken();
if(symbolHeadToken == RULE_rcitem)
{
ParseNode *item = *(*i)->begin();
assert(item->getToken() == RULE_rcitem);
ParseNode *item2 = *item->begin();
std::string item2Text = item2->getTokenText();
unsigned newState = ruleIr.addState(*nfa);
bool ok = ruleIr.addEdge(*nfa, lastState, newState, item2Text);
if(!ok)
{
std::string msg = "error adding NFA transition (check that keywords and tokens are defined before use)";
throw ParseSpecificError((*i)->getLine(), (*i)->getFile(), msg);
}
lastState = newState;
}
else
if(symbolHeadToken == '{' || symbolHeadToken == '[')
{
unsigned q0 = ruleIr.addState(*nfa);
ruleIr.addLambda(*nfa, lastState, q0);
lastState = q0;
ParseNode::iterator_type j = (*i)->begin();
ParseNode *alternate = *++j;
assert(alternate->getToken() == RULE_rcalternate);
addSymbols(alternate->begin(), alternate->end(), symTab, ruleIr, nfa, lastState);
if(symbolHeadToken == '{')
ruleIr.addLambda(*nfa, lastState, q0);
ruleIr.addLambda(*nfa, q0, lastState);
unsigned qf = ruleIr.addState(*nfa);
ruleIr.addLambda(*nfa, lastState, qf);
lastState = qf;
}
}
unsigned newState = ruleIr.addState(*nfa);
ruleIr.addLambda(*nfa, lastState, newState);
lastState = newState;
}