本文整理汇总了C++中Translator::getToken方法的典型用法代码示例。如果您正苦于以下问题:C++ Translator::getToken方法的具体用法?C++ Translator::getToken怎么用?C++ Translator::getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translator
的用法示例。
在下文中一共展示了Translator::getToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inputTranslate
// INPUT command translate function
TokenStatus inputTranslate(Translator &translator, Token *commandToken,
Token *&token)
{
TokenStatus status;
int indexBegin;
bool done;
Token *inputToken;
if (commandToken->isCode(Input_Code))
{
token = translator.table().newToken(InputBegin_Code);
}
else // InputPrompt_Code
{
token = NULL;
status = translator.getExpression(token, String_DataType);
if (status != Done_TokenStatus)
{
if (status == Parser_TokenStatus
&& token->isDataType(None_DataType))
{
status = ExpSemiOrComma_TokenStatus;
}
delete commandToken;
return status;
}
translator.doneStackDrop();
if (token->isCode(Comma_Code))
{
token->addSubCode(Option_SubCode);
}
else if (!token->isCode(SemiColon_Code))
{
delete commandToken;
return ExpOpSemiOrComma_TokenStatus;
}
token->setCode(InputBeginStr_Code);
}
// save index where to insert input parse codes and append input begin
indexBegin = translator.outputCount();
translator.outputAppend(token);
// loop to read input variables
do
{
// get variable reference
token = NULL;
if ((status = translator.getOperand(token, Any_DataType,
Translator::Variable_Reference)) != Good_TokenStatus)
{
break;
}
// get and check next token
if ((status = translator.getToken(token)) != Good_TokenStatus)
{
status = ExpCommaSemiOrEnd_TokenStatus;
break;
}
if (token->isCode(Comma_Code))
{
done = false;
inputToken = token;
}
else if (token->isCode(SemiColon_Code))
{
commandToken->addSubCode(Option_SubCode);
done = true;
inputToken = token;
// get and check next token
if ((status = translator.getToken(token)) != Good_TokenStatus)
{
status = ExpEndStmt_TokenStatus;
break;
}
}
else // possible end-of-statement (checked below)
{
done = true;
inputToken = new Token;
}
// change token to appropriate assign code and append to output
translator.table().setToken(inputToken, InputAssign_Code);
status = translator.processFinalOperand(inputToken);
if (status != Good_TokenStatus)
{
break;
}
// create and insert input parse code at beginning
// (inserted in reverse order for each input variable)
translator.outputInsert(indexBegin, translator.table()
.newToken(translator.table()
.secondAssociatedCode(inputToken->code())));
}
while (!done);
//.........这里部分代码省略.........
示例2: letTranslate
// LET command translate function
TokenStatus letTranslate(Translator &translator, Token *commandToken,
Token *&token)
{
TokenStatus status;
int column;
bool hidden;
DataType dataType;
bool done;
TokenStack letStack;
bool haveSubStr = false;
if (commandToken == NULL)
{
column = token->column();
hidden = true;
}
else // delete unneeded command token and get another token
{
column = commandToken->column();
delete commandToken;
hidden = false;
}
dataType = Any_DataType;
do
{
if ((status = translator.getOperand(token, dataType,
Translator::All_Reference)) != Good_TokenStatus)
{
if (token->column() > column)
{
return status;
}
// next token determines error
Token *nextToken;
if ((status = translator.getToken(nextToken)) != Good_TokenStatus)
{
status = ExpCmd_TokenStatus;
}
if (nextToken->isCode(Comma_Code) || nextToken->isCode(Eq_Code))
{
status = ExpAssignItem_TokenStatus;
}
else
{
status = ExpCmd_TokenStatus;
}
delete nextToken;
return status;
}
// get and check next token for comma or equal
status = translator.getToken(token);
if (token->isCode(Comma_Code))
{
done = false;
}
else if (token->isCode(Eq_Code))
{
done = true;
}
else // invalid token or parser error
{
if (translator.table().hasFlag(translator.doneStackTopToken(),
SubStr_Flag))
{
delete translator.doneStackPop();
}
return ExpEqualOrComma_TokenStatus;
}
// check if this is a sub-string assignment
if (translator.table().hasFlag(translator.doneStackTopToken(),
SubStr_Flag))
{
// delete comma/equal token, use sub-string function token
delete token;
// get sub-string function token from rpn item on top of stack
// (delete rpn item since it was not appended to output)
RpnItem *rpnItem = translator.doneStackPop();
token = rpnItem->token();
rpnItem->setToken(NULL); // prevent delete of token
delete rpnItem;
// change to assign sub-string code (first associated code)
translator.table().setToken(token,
translator.table().associatedCode(token->code()));
haveSubStr = true;
}
else // use comma/equal token
{
// change token to appropriate assign code
translator.table().setToken(token, Assign_Code);
status = translator.processDoneStackTop(token);
if (status != Good_TokenStatus)
{
return status;
}
//.........这里部分代码省略.........