本文整理汇总了C++中Lexer::NextToken方法的典型用法代码示例。如果您正苦于以下问题:C++ Lexer::NextToken方法的具体用法?C++ Lexer::NextToken怎么用?C++ Lexer::NextToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lexer
的用法示例。
在下文中一共展示了Lexer::NextToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
/*
* Update // Read by parser
* <table>
* SET
* [<column>, <column>, ...]
* WHERE <expression>
*
* <column> := <columnName> = <expression>
* <table> := identifier
*/
void Update::Parse(Lexer& lex)
{
Token t;
t = lex.NextToken(TokenType::Identifier);
SetFrom(t.strData);
// <column>s
t = lex.NextToken("set", TokenType::Keyword);
ReadColumns(lex);
// Don't allow UPDATE without WHERE clause
//if (lex.endOfStream())
// return;
t = lex.NextToken("where", TokenType::Keyword);
//if (t.type == TokenType::Keyword && t.strData == "where")
//{
SetWhere(ExpressionPredicate(lex, IOperation::GetStandardOperations()));
//}
//else
//{
// lex.PutBackToken(t);
//}
}
示例2: ReadColumns
void Update::ReadColumns(Lexer& lex)
{
Token t;
do
{
// <columnName>
t = lex.NextToken(TokenType::Identifier);
string name = t.strData;
t = lex.NextToken("=", TokenType::Operator);
// Expression
// Read the expression
ExpressionParser p(&lex, IOperation::GetStandardOperations());
Expression* expr = p.Parse();
columns[name] = expr;
t = lex.NextToken();
}
while (t.type == TokenType::Separator);
lex.PutBackToken(t);
}
示例3: Parse
/*
* CREATE TABLE <name> (
* <columnDefinitions>
* )
*
* <name> == <columnName> == identifier
* <columnDefinitions> := <columnName> <columnType> [, <columnDefinitions>]
* <columnType> := byte | int | uint | char(<length>)
* <length> == int
*/
void CreateTable::Parse(Lexer& lex)
{
Token t;
// <name>
t = lex.NextToken(TokenType::Identifier, false);
name = t.strData;
// (
lex.NextToken("(", TokenType::Parenthesis);
string tableName;
// While not )
do
{
Field f = parseField(lex);
AddField(f);
// , or )
t = lex.NextToken();
}
while (t.type == TokenType::Separator);
if (t.type != TokenType::Parenthesis || t.strData != ")")
throw InvalidTokenException(t);
}
示例4: parseField
Field CreateTable::parseField(Lexer& lex)
{
Field res;
res.size = 0;
Token t;
// <columnName>
t = lex.NextToken(TokenType::Identifier, false);
if (t.strData.size() >= STORM_SQL_FIELD_NAME_SIZE)
throw NameTooLong();
strcpy(res.name, t.strData.c_str());
// <columnType>
t = lex.NextToken(TokenType::Keyword);
if (t.strData == "byte")
res.type = Field::FieldType::byte;
else if (t.strData == "int")
res.type = Field::FieldType::int32;
else if (t.strData == "uint")
res.type = Field::FieldType::uint32;
else if (t.strData == "char")
{
res.type = Field::FieldType::fixedchar;
// (<length>)
lex.NextToken("(", TokenType::Parenthesis);
t = lex.NextToken(TokenType::IntValue);
lex.NextToken(")", TokenType::Parenthesis);
res.size = t.longIntData;
}
else
throw InvalidTokenException(t);
return res;
}
示例5: Parse
/*
* DROP TABLE <name>
*/
void DropTable::Parse(Lexer& lex)
{
Token t = lex.NextToken(TokenType::Identifier, false);
SetName(t.strData);
}