本文整理汇总了C++中tokenizer::getToken方法的典型用法代码示例。如果您正苦于以下问题:C++ tokenizer::getToken方法的具体用法?C++ tokenizer::getToken怎么用?C++ tokenizer::getToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tokenizer
的用法示例。
在下文中一共展示了tokenizer::getToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseStatement
/*#define TOPARSE_DEBUG
#include <QtDebug>*/
toSQLParse::statement toSQLParse::parseStatement(tokenizer &tokens, bool declare, bool lst)
{
statement ret(statement::Statement);
// toSyntaxAnalyzer &syntax = tokens.analyzer();
QString first;
QString realfirst;
bool nokey = false;
bool block = false;
for (QString token = tokens.getToken(true, true);
!token.isNull();
token = tokens.getToken(true, true))
{
QString upp = token.toUpper();
if (first.isNull() && !token.startsWith(("/*")) && !token.startsWith("--") && !token.startsWith("//"))
realfirst = first = upp;
#ifdef TOPARSE_DEBUG
printf("%s (%d)\n", (const char*)token.toUtf8(), tokens.line());
printf(" %s - %s\n", (const char*)first.toUtf8(), (const char*)realfirst.toUtf8());
#endif
// SQLITEMAN
if (upp == ("PROCEDURE") ||
upp == ("FUNCTION") ||
upp == ("PACKAGE"))
{
// qDebug() << "PROCEDURE";
block = true;
}
if (upp == ("SELF"))
{
// qDebug() << "SELF";
block = false;
}
if (upp == "BEGIN" && (first.isNull() || first == "BEGIN"))
{
// qDebug() << "plain BEGIN";
ret.subTokens().insert(ret.subTokens().end(), statement(statement::Keyword, token, tokens.line()));
nokey = false;
}
else if (first != ("END") && ((first == ("IF") && upp == ("THEN")) ||
upp == ("LOOP") ||
upp == ("DO") ||
(/*syntax.declareBlock()*/true && upp == ("DECLARE")) ||
(block && upp == ("AS")) ||
(block && upp == ("IS")) ||
((!declare || block) && upp == ("BEGIN"))))
{
// qDebug() << "first != (\"END\") ";
block = false;
statement blk(statement::Block);
ret.subTokens().insert(ret.subTokens().end(), statement(statement::Keyword, token, tokens.line()));
blk.subTokens().insert(blk.subTokens().end(), ret);
statement cur(statement::Statement);
bool dcl = (upp == ("DECLARE") || upp == ("IS") || upp == ("AS"));
do
{
cur = parseStatement(tokens, dcl, false);
if (cur.Type == statement::List)
{
QMessageBox::warning(QApplication::activeWindow(), "Sqliteman",
"toSQLparse: Unbalanced parenthesis (Too many ')')");
}
blk.subTokens().insert(blk.subTokens().end(), cur);
if (cur.subTokens().begin() != cur.subTokens().end() &&
(*(cur.subTokens().begin())).String.toUpper() == ("BEGIN"))
dcl = false;
}
while (cur.subTokens().begin() != cur.subTokens().end() &&
(*cur.subTokens().begin()).String.toUpper() != ("END"));
return blk;
}
else if (((first == "IF" && upp == "THEN") ||
(first == "WHEN" && upp == "THEN") ||
(first == "ELSIF" && upp == "THEN") ||
upp == ("BEGIN") ||
upp == ("EXCEPTION") ||
first == ("ELSE")) && !lst)
{
// qDebug() << "else if first==IF";
ret.subTokens().insert(ret.subTokens().end(), statement(statement::Keyword, token, tokens.line()));
return ret;
}
else if (first == ("ASSIGN") ||
first == ("SET") ||
first == ("PROMPT") ||
first == ("COLUMN") ||
first == ("SPOOL") ||
first == ("STORE") ||
first == ("REMARK") ||
first == ("REM"))
{
// qDebug() << "ASSIGN";
//.........这里部分代码省略.........