diff options
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/parser')
34 files changed, 302 insertions, 228 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitealtertable.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitealtertable.cpp index 6c840e7..49763a5 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitealtertable.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitealtertable.cpp @@ -102,7 +102,7 @@ void SqliteAlterTable::initName(const QString &name1, const QString &name2) TokenList SqliteAlterTable::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("ALTER").withSpace().withKeyword("TABLE").withSpace(); if (!database.isNull()) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteanalyze.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteanalyze.cpp index d4e5778..30396c1 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteanalyze.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteanalyze.cpp @@ -69,7 +69,7 @@ QList<SqliteStatement::FullObject> SqliteAnalyze::getFullObjectsInStatement() TokenList SqliteAnalyze::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("ANALYZE").withSpace(); if (!database.isNull()) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteattach.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteattach.cpp index 7d0b8a5..359396b 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteattach.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteattach.cpp @@ -47,7 +47,7 @@ SqliteStatement* SqliteAttach::clone() TokenList SqliteAttach::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("ATTACH").withSpace(); if (databaseKw) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitebegintrans.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitebegintrans.cpp index dcd9740..00ec9ac 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitebegintrans.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitebegintrans.cpp @@ -52,7 +52,7 @@ QString SqliteBeginTrans::typeToString(SqliteBeginTrans::Type type) TokenList SqliteBeginTrans::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("BEGIN"); if (type != Type::null) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecommittrans.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecommittrans.cpp index 97be8a9..2b1b707 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecommittrans.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecommittrans.cpp @@ -29,7 +29,7 @@ SqliteStatement* SqliteCommitTrans::clone() TokenList SqliteCommitTrans::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); if (endKw) builder.withKeyword("END"); else diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecopy.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecopy.cpp index 009f836..0d9ed9f 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecopy.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecopy.cpp @@ -73,7 +73,7 @@ QList<SqliteStatement::FullObject> SqliteCopy::getFullObjectsInStatement() TokenList SqliteCopy::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("COPY").withSpace(); if (onConflict != SqliteConflictAlgo::null) builder.withKeyword("OR").withSpace().withKeyword(sqliteConflictAlgo(onConflict)).withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateindex.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateindex.cpp index 36f7aa9..16cec8f 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateindex.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateindex.cpp @@ -149,6 +149,7 @@ QList<SqliteStatement::FullObject> SqliteCreateIndex::getFullObjectsInStatement( TokenList SqliteCreateIndex::rebuildTokensFromContents() { StatementTokenBuilder builder; + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("CREATE").withSpace(); if (uniqueKw) builder.withKeyword("UNIQUE").withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetable.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetable.cpp index e31e512..454c0e3 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetable.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetable.cpp @@ -208,7 +208,7 @@ QList<SqliteStatement::FullObject> SqliteCreateTable::getFullObjectsInStatement( TokenList SqliteCreateTable::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("CREATE"); if (tempKw) builder.withSpace().withKeyword("TEMP"); @@ -706,7 +706,6 @@ TokenList SqliteCreateTable::Column::rebuildTokensFromContents() TokenList SqliteCreateTable::Column::Constraint::rebuildTokensFromContents() { StatementTokenBuilder builder; - if (!name.isNull()) builder.withKeyword("CONSTRAINT").withSpace().withOther(name, dialect).withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetrigger.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetrigger.cpp index 3b7b0ea..8f67aea 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetrigger.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatetrigger.cpp @@ -322,7 +322,7 @@ SqliteCreateTrigger::Event::Type SqliteCreateTrigger::Event::stringToType(const TokenList SqliteCreateTrigger::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("CREATE").withSpace(); if (tempKw) builder.withKeyword("TEMP").withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateview.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateview.cpp index 6b11c3c..d1a8961 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateview.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreateview.cpp @@ -98,7 +98,7 @@ QList<SqliteStatement::FullObject> SqliteCreateView::getFullObjectsInStatement() TokenList SqliteCreateView::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("CREATE").withSpace(); if (tempKw) builder.withKeyword("TEMP").withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatevirtualtable.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatevirtualtable.cpp index bc38dc9..1d98c8d 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatevirtualtable.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecreatevirtualtable.cpp @@ -91,7 +91,7 @@ void SqliteCreateVirtualTable::initName(const QString &name1, const QString &nam TokenList SqliteCreateVirtualTable::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("CREATE").withSpace().withKeyword("VIRTUAL").withSpace().withKeyword("TABLE"); if (ifNotExistsKw) builder.withKeyword("IF").withSpace().withKeyword("NOT").withSpace().withKeyword("EXISTS").withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedelete.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedelete.cpp index 60e5878..6026de3 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedelete.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedelete.cpp @@ -113,7 +113,7 @@ void SqliteDelete::init(const QString &name1, const QString &name2, SqliteExpr * TokenList SqliteDelete::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); if (with) builder.withStatement(with); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedetach.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedetach.cpp index 1f874d3..e5b59e3 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedetach.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedetach.cpp @@ -36,7 +36,7 @@ SqliteStatement*SqliteDetach::clone() TokenList SqliteDetach::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("DETACH").withSpace(); if (databaseKw) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropindex.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropindex.cpp index df924fe..2e39312 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropindex.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropindex.cpp @@ -63,7 +63,7 @@ QList<SqliteStatement::FullObject> SqliteDropIndex::getFullObjectsInStatement() TokenList SqliteDropIndex::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("DROP").withSpace().withKeyword("INDEX").withSpace(); if (ifExistsKw) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptable.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptable.cpp index 9c4aa37..c4fc02d 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptable.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptable.cpp @@ -71,7 +71,7 @@ QList<SqliteStatement::FullObject> SqliteDropTable::getFullObjectsInStatement() TokenList SqliteDropTable::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("DROP").withSpace().withKeyword("TABLE").withSpace(); if (ifExistsKw) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptrigger.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptrigger.cpp index 471d558..8921af3 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptrigger.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedroptrigger.cpp @@ -64,7 +64,7 @@ QList<SqliteStatement::FullObject> SqliteDropTrigger::getFullObjectsInStatement( TokenList SqliteDropTrigger::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("DROP").withSpace().withKeyword("TRIGGER").withSpace(); if (ifExistsKw) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropview.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropview.cpp index 06d70db..b992e98 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropview.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitedropview.cpp @@ -70,7 +70,7 @@ QList<SqliteStatement::FullObject> SqliteDropView::getFullObjectsInStatement() TokenList SqliteDropView::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("DROP").withSpace().withKeyword("VIEW").withSpace(); if (ifExistsKw) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteinsert.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteinsert.cpp index 6c26e8d..cb85377 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteinsert.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteinsert.cpp @@ -167,7 +167,7 @@ void SqliteInsert::initMode(bool replace, SqliteConflictAlgo onConflict) TokenList SqliteInsert::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); if (with) builder.withStatement(with); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitepragma.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitepragma.cpp index 0e4f056..4660e4f 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitepragma.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitepragma.cpp @@ -90,7 +90,7 @@ void SqlitePragma::initName(const QString &name1, const QString &name2) TokenList SqlitePragma::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("PRAGMA").withSpace(); if (!database.isNull()) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.cpp index 19c3c40..02eff1d 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.cpp @@ -1,4 +1,5 @@ #include "sqlitequery.h" +#include "parser/statementtokenbuilder.h" SqliteQuery::SqliteQuery() { @@ -49,3 +50,15 @@ bool SqliteQuery::isReadOnly() } return readOnly; } + +TokenList SqliteQuery::rebuildTokensFromContents() +{ + StatementTokenBuilder builder; + if (explain) + { + builder.withKeyword("EXPLAIN").withSpace(); + if (queryPlan) + builder.withKeyword("QUERY").withSpace().withKeyword("PLAN").withSpace(); + } + return builder.build(); +} diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.h b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.h index 1667dc9..787ccb9 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.h +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitequery.h @@ -20,6 +20,9 @@ class API_EXPORT SqliteQuery : public SqliteStatement bool explain = false; bool queryPlan = false; + + protected: + TokenList rebuildTokensFromContents(); }; /** diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitereindex.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitereindex.cpp index 7584a37..6f863f9 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitereindex.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitereindex.cpp @@ -71,7 +71,7 @@ QList<SqliteStatement::FullObject> SqliteReindex::getFullObjectsInStatement() TokenList SqliteReindex::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("REINDEX"); if (!database.isNull()) builder.withOther(database, dialect).withOperator("."); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterelease.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterelease.cpp index 8510524..f71d61c 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterelease.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterelease.cpp @@ -28,7 +28,7 @@ SqliteStatement*SqliteRelease::clone() TokenList SqliteRelease::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("RELEASE").withSpace(); if (savepointKw) builder.withKeyword("SAVEPOINT").withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterollback.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterollback.cpp index a13fd4c..01284b4 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterollback.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliterollback.cpp @@ -38,7 +38,7 @@ SqliteStatement*SqliteRollback::clone() TokenList SqliteRollback::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("ROLLBACK").withSpace(); if (transactionKw) builder.withKeyword("TRANSACTION").withSpace(); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitesavepoint.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitesavepoint.cpp index 9003086..1ac50cd 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitesavepoint.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitesavepoint.cpp @@ -27,6 +27,7 @@ SqliteStatement*SqliteSavepoint::clone() TokenList SqliteSavepoint::rebuildTokensFromContents() { StatementTokenBuilder builder; + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("SAVEPOINT").withSpace().withOther(name, dialect).withOperator(";"); return builder.build(); } diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteselect.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteselect.cpp index 5452795..f1b1929 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteselect.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteselect.cpp @@ -759,6 +759,7 @@ TokenList SqliteSelect::Core::rebuildTokensFromContents() TokenList SqliteSelect::rebuildTokensFromContents() { StatementTokenBuilder builder; + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); if (with) builder.withStatement(with); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteupdate.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteupdate.cpp index 88ac28b..df892fb 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteupdate.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqliteupdate.cpp @@ -168,7 +168,7 @@ QList<SqliteStatement::FullObject> SqliteUpdate::getFullObjectsInStatement() TokenList SqliteUpdate::rebuildTokensFromContents() { StatementTokenBuilder builder; - + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); if (with) builder.withStatement(with); diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitevacuum.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitevacuum.cpp index ab7d00e..96ff7a4 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitevacuum.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitevacuum.cpp @@ -51,6 +51,7 @@ QList<SqliteStatement::FullObject> SqliteVacuum::getFullObjectsInStatement() TokenList SqliteVacuum::rebuildTokensFromContents() { StatementTokenBuilder builder; + builder.withTokens(SqliteQuery::rebuildTokensFromContents()); builder.withKeyword("VACUUM").withOperator(";"); return builder.build(); } diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.cpp index e9444e5..7f8ad7a 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.cpp @@ -164,6 +164,36 @@ const QList<ParserError *> &ParserContext::getErrors() return errors; } +QVariant *ParserContext::handleNumberToken(const QString &tokenValue) +{ + recentNumberIsCandidateForMaxNegative = false; + if (tokenValue.startsWith("0x", Qt::CaseInsensitive)) + { + bool ok; + qint64 i64 = tokenValue.toLongLong(&ok, 16); + if (!ok) + { + quint64 ui64 = tokenValue.toULongLong(&ok, 16); + i64 = static_cast<qint64>(ui64); + } + return new QVariant(i64); + } + else if (tokenValue == "9223372036854775808") // max negative longlong value, but without a sign + { + recentNumberIsCandidateForMaxNegative = true; + return new QVariant(static_cast<qint64>(0L)); + } + else + { + return new QVariant(QVariant(tokenValue).toLongLong()); + } +} + +bool ParserContext::isCandidateForMaxNegativeNumber() const +{ + return recentNumberIsCandidateForMaxNegative; +} + void ParserContext::cleanUp() { foreach (ParserError* err, errors) diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.h b/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.h index d52c021..64ce3a3 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.h +++ b/SQLiteStudio3/coreSQLiteStudio/parser/parsercontext.h @@ -187,6 +187,9 @@ class ParserContext */ const QList<ParserError*>& getErrors(); + QVariant* handleNumberToken(const QString& tokenValue); + bool isCandidateForMaxNegativeNumber() const; + /** * @brief Flag indicating if the Lemon parser should setup token collections. * @@ -284,6 +287,18 @@ class ParserContext * Defined by errorBeforeNextToken() and minorErrorBeforeNextToken(). */ QString nextTokenError; + + /** + * @brief Indicates that the number value is 1 over the max longlong value. + * + * Then the positive number is over max longlong by 1, then this is a candidate + * for max negative longlong value, but this is to be identified in the next parser reduce level. + * + * Because of that this flag is set to false by default each time the number is parsed and is set afterwards + * to true each timethe value is 1 over max longlong. This way if the 'term' rule includes 'minus' token, + * then it will be properly converted to max negative longlong. + */ + bool recentNumberIsCandidateForMaxNegative = false; }; #endif // PARSERCONTEXT_H diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.cpp index 5b65904..ffc1fab 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.cpp @@ -3832,7 +3832,7 @@ static void yy_reduce( case 250: /* exprx ::= expr not_opt IN nm dbnm */ { yygotominor.yy192 = new SqliteExpr(); - yygotominor.yy192->initIn(yymsp[-4].minor.yy192, yymsp[-3].minor.yy291, *(yymsp[-1].minor.yy319), *(yymsp[0].minor.yy319)); + yygotominor.yy192->initIn(yymsp[-4].minor.yy192, *(yymsp[-3].minor.yy291), *(yymsp[-1].minor.yy319), *(yymsp[0].minor.yy319)); delete yymsp[-3].minor.yy291; delete yymsp[-1].minor.yy319; objectForTokens = yygotominor.yy192; diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.y b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.y index d6ee4f7..472725e 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.y +++ b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite2_parse.y @@ -1513,7 +1513,7 @@ exprx(X) ::= expr(E) not_opt(N) IN LP exprx(X) ::= expr(E) not_opt(N) IN nm(N1) dbnm(N2). [IN] { X = new SqliteExpr(); - X->initIn(E, N, *(N1), *(N2)); + X->initIn(E, *(N), *(N1), *(N2)); delete N; delete N1; objectForTokens = X; diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.cpp b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.cpp index 646c533..fa8a9d1 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.cpp @@ -51,6 +51,7 @@ #include "parser/ast/sqlitewith.h" #include <QObject> #include <QDebug> +#include <limits.h> #define assert(X) Q_ASSERT(X) #define UNUSED_PARAMETER(X) (void)(X) @@ -242,7 +243,7 @@ static const YYMINORTYPE yyzerominor = { 0 }; ** shifting non-terminals after a reduce. ** yy_default[] Default action for each state. */ -#define YY_ACTTAB_COUNT (2282) +#define YY_ACTTAB_COUNT (2263) static const YYACTIONTYPE yy_action[] = { /* 0 */ 431, 48, 48, 47, 47, 47, 46, 216, 716, 339, /* 10 */ 643, 425, 51, 51, 51, 51, 44, 49, 49, 49, @@ -413,66 +414,64 @@ static const YYACTIONTYPE yy_action[] = { /* 1660 */ 499, 478, 699, 428, 715, 714, 713, 4, 1037, 425, /* 1670 */ 714, 713, 642, 416, 422, 715, 430, 687, 429, 641, /* 1680 */ 428, 350, 690, 619, 686, 172, 641, 494, 454, 642, - /* 1690 */ 689, 688, 687, 430, 111, 428, 411, 286, 337, 714, - /* 1700 */ 713, 686, 190, 714, 713, 621, 287, 72, 430, 428, - /* 1710 */ 715, 428, 436, 685, 209, 558, 686, 188, 41, 715, - /* 1720 */ 567, 287, 430, 642, 430, 676, 9, 642, 716, 96, - /* 1730 */ 686, 196, 686, 195, 715, 38, 39, 641, 716, 283, - /* 1740 */ 431, 327, 40, 716, 207, 428, 203, 319, 150, 428, - /* 1750 */ 4, 425, 715, 318, 641, 642, 325, 422, 430, 716, - /* 1760 */ 687, 429, 430, 719, 716, 690, 686, 197, 709, 641, - /* 1770 */ 686, 201, 642, 689, 688, 687, 428, 224, 411, 716, - /* 1780 */ 261, 716, 86, 641, 221, 641, 708, 651, 258, 430, - /* 1790 */ 428, 695, 220, 715, 428, 685, 420, 686, 232, 227, - /* 1800 */ 41, 715, 651, 430, 715, 433, 642, 430, 676, 9, - /* 1810 */ 642, 686, 290, 428, 707, 686, 191, 38, 39, 641, - /* 1820 */ 149, 147, 431, 641, 40, 257, 430, 82, 432, 256, - /* 1830 */ 714, 713, 4, 425, 686, 194, 679, 642, 715, 422, - /* 1840 */ 714, 713, 714, 429, 716, 714, 713, 690, 716, 715, - /* 1850 */ 641, 367, 428, 15, 642, 689, 688, 687, 428, 684, - /* 1860 */ 411, 714, 713, 700, 641, 430, 714, 713, 641, 145, - /* 1870 */ 17, 430, 476, 686, 193, 234, 521, 685, 294, 686, - /* 1880 */ 185, 714, 713, 714, 713, 293, 400, 641, 642, 428, - /* 1890 */ 676, 9, 642, 541, 428, 502, 292, 28, 529, 38, - /* 1900 */ 39, 474, 430, 291, 248, 408, 40, 430, 481, 428, - /* 1910 */ 686, 189, 55, 683, 4, 686, 314, 715, 715, 642, - /* 1920 */ 428, 422, 430, 463, 687, 429, 641, 428, 716, 690, - /* 1930 */ 686, 313, 641, 430, 402, 216, 642, 689, 688, 687, - /* 1940 */ 430, 686, 312, 428, 536, 428, 714, 713, 686, 184, - /* 1950 */ 714, 713, 43, 640, 419, 66, 430, 229, 430, 214, - /* 1960 */ 415, 228, 34, 641, 686, 171, 686, 170, 641, 637, - /* 1970 */ 642, 635, 676, 9, 642, 428, 141, 626, 428, 622, - /* 1980 */ 246, 139, 715, 641, 477, 428, 108, 389, 430, 428, - /* 1990 */ 715, 430, 715, 715, 641, 386, 686, 183, 430, 686, - /* 2000 */ 169, 641, 430, 380, 577, 471, 686, 186, 617, 244, - /* 2010 */ 686, 168, 428, 473, 133, 428, 242, 641, 330, 641, - /* 2020 */ 470, 715, 715, 583, 578, 430, 277, 715, 430, 715, - /* 2030 */ 714, 713, 428, 686, 167, 428, 686, 93, 574, 716, - /* 2040 */ 535, 573, 443, 572, 716, 430, 547, 128, 430, 641, - /* 2050 */ 310, 428, 641, 686, 166, 428, 686, 164, 428, 641, - /* 2060 */ 716, 236, 716, 641, 430, 322, 546, 716, 430, 428, - /* 2070 */ 393, 430, 686, 174, 715, 554, 686, 173, 309, 686, - /* 2080 */ 175, 716, 430, 715, 716, 275, 641, 716, 545, 641, - /* 2090 */ 686, 178, 428, 80, 428, 568, 716, 428, 715, 428, - /* 2100 */ 544, 716, 127, 106, 716, 430, 641, 430, 715, 641, - /* 2110 */ 430, 549, 430, 686, 94, 686, 177, 428, 686, 176, - /* 2120 */ 686, 180, 269, 428, 715, 641, 212, 392, 126, 641, - /* 2130 */ 430, 354, 641, 262, 24, 715, 430, 526, 686, 179, - /* 2140 */ 430, 714, 713, 641, 686, 165, 714, 713, 686, 70, - /* 2150 */ 124, 363, 78, 527, 123, 105, 121, 155, 523, 513, - /* 2160 */ 84, 104, 714, 713, 714, 713, 641, 348, 641, 714, - /* 2170 */ 713, 641, 263, 641, 518, 360, 492, 489, 120, 493, - /* 2180 */ 441, 480, 103, 714, 713, 715, 714, 713, 715, 714, - /* 2190 */ 713, 641, 648, 118, 345, 347, 76, 641, 714, 713, - /* 2200 */ 442, 641, 343, 714, 713, 427, 714, 713, 715, 284, - /* 2210 */ 264, 253, 117, 715, 250, 241, 75, 116, 715, 115, - /* 2220 */ 237, 74, 715, 715, 715, 73, 238, 715, 715, 114, - /* 2230 */ 323, 113, 23, 715, 451, 652, 20, 449, 101, 715, - /* 2240 */ 100, 445, 112, 61, 439, 162, 295, 669, 655, 623, - /* 2250 */ 412, 665, 520, 628, 618, 278, 569, 260, 198, 361, - /* 2260 */ 305, 374, 681, 522, 664, 6, 654, 556, 211, 45, - /* 2270 */ 364, 487, 566, 560, 296, 559, 409, 81, 71, 587, - /* 2280 */ 586, 550, + /* 1690 */ 689, 688, 687, 430, 111, 428, 411, 716, 72, 714, + /* 1700 */ 713, 686, 190, 714, 713, 621, 287, 337, 430, 428, + /* 1710 */ 436, 428, 96, 685, 209, 558, 686, 188, 41, 715, + /* 1720 */ 567, 287, 430, 642, 430, 676, 9, 642, 716, 207, + /* 1730 */ 686, 196, 686, 195, 715, 38, 39, 641, 716, 286, + /* 1740 */ 431, 327, 40, 224, 86, 428, 695, 319, 203, 428, + /* 1750 */ 4, 425, 715, 318, 641, 642, 325, 422, 430, 715, + /* 1760 */ 687, 429, 430, 150, 261, 690, 686, 197, 221, 641, + /* 1770 */ 686, 201, 642, 689, 688, 687, 428, 715, 411, 716, + /* 1780 */ 719, 709, 708, 641, 433, 641, 707, 651, 258, 430, + /* 1790 */ 428, 283, 220, 536, 428, 685, 149, 686, 232, 714, + /* 1800 */ 713, 715, 651, 430, 715, 147, 642, 430, 676, 9, + /* 1810 */ 642, 686, 290, 428, 82, 686, 191, 38, 39, 641, + /* 1820 */ 679, 367, 432, 641, 40, 15, 430, 145, 700, 234, + /* 1830 */ 714, 713, 4, 715, 686, 194, 408, 642, 420, 422, + /* 1840 */ 714, 713, 687, 429, 716, 428, 684, 690, 637, 715, + /* 1850 */ 641, 227, 428, 294, 642, 689, 688, 687, 430, 716, + /* 1860 */ 293, 715, 428, 17, 641, 430, 686, 193, 641, 292, + /* 1870 */ 400, 291, 402, 686, 185, 430, 521, 28, 683, 55, + /* 1880 */ 428, 714, 713, 686, 189, 43, 428, 641, 642, 640, + /* 1890 */ 676, 9, 642, 430, 216, 419, 428, 66, 529, 430, + /* 1900 */ 428, 686, 314, 428, 229, 214, 228, 686, 313, 430, + /* 1910 */ 428, 415, 34, 430, 141, 626, 430, 686, 312, 641, + /* 1920 */ 428, 686, 184, 430, 686, 171, 641, 428, 715, 635, + /* 1930 */ 139, 686, 170, 430, 108, 386, 641, 716, 463, 622, + /* 1940 */ 430, 686, 183, 428, 617, 428, 714, 713, 686, 169, + /* 1950 */ 428, 716, 715, 389, 641, 583, 430, 715, 430, 380, + /* 1960 */ 641, 714, 713, 430, 686, 186, 686, 168, 428, 716, + /* 1970 */ 641, 686, 167, 541, 641, 428, 578, 641, 716, 257, + /* 1980 */ 133, 430, 577, 256, 641, 428, 474, 428, 430, 686, + /* 1990 */ 93, 428, 715, 715, 641, 716, 686, 166, 430, 716, + /* 2000 */ 430, 641, 330, 716, 430, 716, 686, 164, 686, 174, + /* 2010 */ 428, 277, 686, 173, 393, 428, 275, 641, 716, 641, + /* 2020 */ 716, 568, 574, 430, 641, 428, 573, 715, 430, 715, + /* 2030 */ 428, 686, 175, 489, 715, 428, 686, 178, 430, 714, + /* 2040 */ 713, 572, 641, 430, 716, 428, 686, 94, 430, 641, + /* 2050 */ 310, 686, 177, 714, 713, 128, 686, 176, 430, 641, + /* 2060 */ 554, 641, 549, 716, 428, 641, 686, 180, 716, 428, + /* 2070 */ 716, 714, 713, 716, 392, 715, 547, 430, 546, 545, + /* 2080 */ 714, 713, 430, 502, 641, 686, 179, 430, 544, 641, + /* 2090 */ 686, 165, 527, 309, 80, 686, 70, 714, 713, 641, + /* 2100 */ 535, 714, 713, 269, 641, 714, 713, 714, 713, 641, + /* 2110 */ 127, 106, 471, 523, 248, 263, 715, 518, 481, 641, + /* 2120 */ 714, 713, 714, 713, 476, 212, 246, 715, 715, 244, + /* 2130 */ 477, 126, 492, 473, 480, 262, 242, 354, 641, 715, + /* 2140 */ 470, 236, 715, 641, 360, 322, 714, 713, 641, 715, + /* 2150 */ 347, 363, 24, 652, 715, 442, 427, 715, 443, 441, + /* 2160 */ 124, 284, 526, 715, 648, 714, 713, 264, 715, 715, + /* 2170 */ 714, 713, 714, 713, 715, 714, 713, 253, 78, 250, + /* 2180 */ 715, 241, 237, 238, 105, 123, 121, 84, 104, 155, + /* 2190 */ 715, 513, 715, 120, 715, 715, 715, 493, 348, 103, + /* 2200 */ 118, 345, 76, 343, 117, 75, 116, 115, 114, 74, + /* 2210 */ 73, 113, 23, 323, 451, 101, 20, 100, 623, 112, + /* 2220 */ 61, 520, 449, 445, 439, 655, 628, 162, 278, 669, + /* 2230 */ 665, 412, 569, 295, 681, 198, 374, 522, 618, 260, + /* 2240 */ 361, 6, 305, 664, 654, 556, 364, 409, 566, 211, + /* 2250 */ 296, 71, 560, 559, 487, 587, 586, 81, 550, 1150, + /* 2260 */ 1150, 1150, 45, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 4, 81, 82, 83, 84, 85, 86, 87, 4, 58, @@ -644,107 +643,105 @@ static const YYCODETYPE yy_lookahead[] = { /* 1660 */ 11, 103, 177, 177, 190, 106, 107, 96, 97, 15, /* 1670 */ 106, 107, 101, 276, 103, 190, 190, 106, 107, 251, /* 1680 */ 177, 32, 111, 141, 198, 199, 251, 162, 97, 118, - /* 1690 */ 119, 120, 121, 190, 93, 177, 42, 177, 37, 106, - /* 1700 */ 107, 198, 199, 106, 107, 141, 177, 95, 190, 177, - /* 1710 */ 190, 177, 36, 59, 252, 118, 198, 199, 64, 190, - /* 1720 */ 127, 177, 190, 152, 190, 154, 155, 156, 4, 189, + /* 1690 */ 119, 120, 121, 190, 93, 177, 42, 4, 95, 106, + /* 1700 */ 107, 198, 199, 106, 107, 141, 177, 37, 190, 177, + /* 1710 */ 36, 177, 189, 59, 252, 118, 198, 199, 64, 190, + /* 1720 */ 127, 177, 190, 152, 190, 154, 155, 156, 4, 238, /* 1730 */ 198, 199, 198, 199, 190, 81, 82, 251, 4, 177, - /* 1740 */ 4, 212, 88, 4, 238, 177, 273, 275, 90, 177, - /* 1750 */ 96, 15, 190, 275, 251, 101, 212, 103, 190, 4, - /* 1760 */ 106, 107, 190, 176, 4, 111, 198, 199, 176, 251, - /* 1770 */ 198, 199, 118, 119, 120, 121, 177, 204, 42, 4, - /* 1780 */ 177, 4, 204, 251, 181, 251, 176, 258, 177, 190, - /* 1790 */ 177, 177, 181, 190, 177, 59, 276, 198, 199, 237, - /* 1800 */ 64, 190, 258, 190, 190, 176, 152, 190, 154, 155, - /* 1810 */ 156, 198, 199, 177, 49, 198, 199, 81, 82, 251, - /* 1820 */ 178, 178, 4, 251, 88, 177, 190, 180, 183, 181, - /* 1830 */ 106, 107, 96, 15, 198, 199, 177, 101, 190, 103, - /* 1840 */ 106, 107, 106, 107, 4, 106, 107, 111, 4, 190, - /* 1850 */ 251, 60, 177, 104, 118, 119, 120, 121, 177, 221, - /* 1860 */ 42, 106, 107, 184, 251, 190, 106, 107, 251, 56, - /* 1870 */ 151, 190, 133, 198, 199, 138, 152, 59, 227, 198, - /* 1880 */ 199, 106, 107, 106, 107, 228, 148, 251, 152, 177, - /* 1890 */ 154, 155, 156, 118, 177, 118, 229, 149, 164, 81, - /* 1900 */ 82, 146, 190, 230, 177, 177, 88, 190, 181, 177, - /* 1910 */ 198, 199, 150, 231, 96, 198, 199, 190, 190, 101, - /* 1920 */ 177, 103, 190, 163, 106, 107, 251, 177, 4, 111, - /* 1930 */ 198, 199, 251, 190, 147, 87, 118, 119, 120, 121, - /* 1940 */ 190, 198, 199, 177, 100, 177, 106, 107, 198, 199, - /* 1950 */ 106, 107, 252, 64, 203, 96, 190, 259, 190, 87, - /* 1960 */ 203, 255, 158, 251, 198, 199, 198, 199, 251, 177, - /* 1970 */ 152, 241, 154, 155, 156, 177, 99, 177, 177, 177, - /* 1980 */ 177, 241, 190, 251, 181, 177, 99, 223, 190, 177, - /* 1990 */ 190, 190, 190, 190, 251, 139, 198, 199, 190, 198, - /* 2000 */ 199, 251, 190, 123, 208, 165, 198, 199, 177, 177, - /* 2010 */ 198, 199, 177, 181, 177, 177, 177, 251, 31, 251, - /* 2020 */ 181, 190, 190, 200, 200, 190, 200, 190, 190, 190, - /* 2030 */ 106, 107, 177, 198, 199, 177, 198, 199, 202, 4, - /* 2040 */ 241, 122, 118, 200, 4, 190, 200, 99, 190, 251, - /* 2050 */ 203, 177, 251, 198, 199, 177, 198, 199, 177, 251, - /* 2060 */ 4, 177, 4, 251, 190, 181, 200, 4, 190, 177, - /* 2070 */ 177, 190, 198, 199, 190, 208, 198, 199, 203, 198, - /* 2080 */ 199, 4, 190, 190, 4, 177, 251, 4, 200, 251, - /* 2090 */ 198, 199, 177, 180, 177, 177, 4, 177, 190, 177, - /* 2100 */ 200, 4, 99, 180, 4, 190, 251, 190, 190, 251, - /* 2110 */ 190, 177, 190, 198, 199, 198, 199, 177, 198, 199, - /* 2120 */ 198, 199, 177, 177, 190, 251, 241, 177, 99, 251, - /* 2130 */ 190, 27, 251, 264, 158, 190, 190, 227, 198, 199, - /* 2140 */ 190, 106, 107, 251, 198, 199, 106, 107, 198, 199, - /* 2150 */ 99, 265, 215, 118, 99, 62, 99, 250, 118, 215, - /* 2160 */ 96, 180, 106, 107, 106, 107, 251, 241, 251, 106, - /* 2170 */ 107, 251, 177, 251, 118, 177, 118, 100, 99, 227, - /* 2180 */ 100, 118, 180, 106, 107, 190, 106, 107, 190, 106, - /* 2190 */ 107, 251, 100, 99, 241, 177, 217, 251, 106, 107, - /* 2200 */ 177, 251, 60, 106, 107, 177, 106, 107, 190, 177, - /* 2210 */ 177, 177, 99, 190, 177, 177, 217, 99, 190, 99, - /* 2220 */ 177, 217, 190, 190, 190, 217, 177, 190, 190, 99, - /* 2230 */ 241, 99, 268, 190, 18, 152, 268, 241, 99, 190, - /* 2240 */ 99, 241, 99, 270, 16, 224, 226, 261, 201, 152, - /* 2250 */ 256, 261, 152, 240, 242, 201, 206, 242, 210, 242, - /* 2260 */ 175, 202, 191, 227, 191, 224, 191, 191, 262, 253, - /* 2270 */ 263, 274, 207, 207, 222, 207, 216, 55, 239, 198, - /* 2280 */ 198, 211, + /* 1740 */ 4, 212, 88, 204, 204, 177, 177, 275, 273, 177, + /* 1750 */ 96, 15, 190, 275, 251, 101, 212, 103, 190, 190, + /* 1760 */ 106, 107, 190, 90, 177, 111, 198, 199, 181, 251, + /* 1770 */ 198, 199, 118, 119, 120, 121, 177, 190, 42, 4, + /* 1780 */ 176, 176, 176, 251, 176, 251, 49, 258, 177, 190, + /* 1790 */ 177, 177, 181, 100, 177, 59, 178, 198, 199, 106, + /* 1800 */ 107, 190, 258, 190, 190, 178, 152, 190, 154, 155, + /* 1810 */ 156, 198, 199, 177, 180, 198, 199, 81, 82, 251, + /* 1820 */ 177, 60, 183, 251, 88, 104, 190, 56, 184, 138, + /* 1830 */ 106, 107, 96, 190, 198, 199, 177, 101, 276, 103, + /* 1840 */ 106, 107, 106, 107, 4, 177, 221, 111, 177, 190, + /* 1850 */ 251, 237, 177, 227, 118, 119, 120, 121, 190, 4, + /* 1860 */ 228, 190, 177, 151, 251, 190, 198, 199, 251, 229, + /* 1870 */ 148, 230, 147, 198, 199, 190, 152, 149, 231, 150, + /* 1880 */ 177, 106, 107, 198, 199, 252, 177, 251, 152, 64, + /* 1890 */ 154, 155, 156, 190, 87, 203, 177, 96, 164, 190, + /* 1900 */ 177, 198, 199, 177, 259, 87, 255, 198, 199, 190, + /* 1910 */ 177, 203, 158, 190, 99, 177, 190, 198, 199, 251, + /* 1920 */ 177, 198, 199, 190, 198, 199, 251, 177, 190, 241, + /* 1930 */ 241, 198, 199, 190, 99, 139, 251, 4, 163, 177, + /* 1940 */ 190, 198, 199, 177, 177, 177, 106, 107, 198, 199, + /* 1950 */ 177, 4, 190, 223, 251, 200, 190, 190, 190, 123, + /* 1960 */ 251, 106, 107, 190, 198, 199, 198, 199, 177, 4, + /* 1970 */ 251, 198, 199, 118, 251, 177, 200, 251, 4, 177, + /* 1980 */ 177, 190, 208, 181, 251, 177, 146, 177, 190, 198, + /* 1990 */ 199, 177, 190, 190, 251, 4, 198, 199, 190, 4, + /* 2000 */ 190, 251, 31, 4, 190, 4, 198, 199, 198, 199, + /* 2010 */ 177, 200, 198, 199, 177, 177, 177, 251, 4, 251, + /* 2020 */ 4, 177, 202, 190, 251, 177, 122, 190, 190, 190, + /* 2030 */ 177, 198, 199, 100, 190, 177, 198, 199, 190, 106, + /* 2040 */ 107, 200, 251, 190, 4, 177, 198, 199, 190, 251, + /* 2050 */ 203, 198, 199, 106, 107, 99, 198, 199, 190, 251, + /* 2060 */ 208, 251, 177, 4, 177, 251, 198, 199, 4, 177, + /* 2070 */ 4, 106, 107, 4, 177, 190, 200, 190, 200, 200, + /* 2080 */ 106, 107, 190, 118, 251, 198, 199, 190, 200, 251, + /* 2090 */ 198, 199, 118, 203, 180, 198, 199, 106, 107, 251, + /* 2100 */ 241, 106, 107, 177, 251, 106, 107, 106, 107, 251, + /* 2110 */ 99, 180, 165, 118, 177, 177, 190, 118, 181, 251, + /* 2120 */ 106, 107, 106, 107, 133, 241, 177, 190, 190, 177, + /* 2130 */ 181, 99, 118, 181, 118, 264, 177, 27, 251, 190, + /* 2140 */ 181, 177, 190, 251, 177, 181, 106, 107, 251, 190, + /* 2150 */ 177, 265, 158, 152, 190, 177, 177, 190, 118, 100, + /* 2160 */ 99, 177, 227, 190, 100, 106, 107, 177, 190, 190, + /* 2170 */ 106, 107, 106, 107, 190, 106, 107, 177, 215, 177, + /* 2180 */ 190, 177, 177, 177, 62, 99, 99, 96, 180, 250, + /* 2190 */ 190, 215, 190, 99, 190, 190, 190, 227, 241, 180, + /* 2200 */ 99, 241, 217, 60, 99, 217, 99, 99, 99, 217, + /* 2210 */ 217, 99, 268, 241, 18, 99, 268, 99, 152, 99, + /* 2220 */ 270, 152, 241, 241, 16, 201, 240, 224, 201, 261, + /* 2230 */ 261, 256, 206, 226, 191, 210, 202, 227, 242, 242, + /* 2240 */ 242, 224, 175, 191, 191, 191, 263, 216, 207, 262, + /* 2250 */ 222, 239, 207, 207, 274, 198, 198, 55, 211, 277, + /* 2260 */ 277, 277, 253, }; #define YY_SHIFT_USE_DFLT (-81) #define YY_SHIFT_COUNT (434) #define YY_SHIFT_MIN (-80) -#define YY_SHIFT_MAX (2228) +#define YY_SHIFT_MAX (2208) static const short yy_shift_ofst[] = { /* 0 */ 1158, -4, 201, 1182, 819, 1571, 1571, 689, 361, 1489, /* 10 */ 1654, 1654, 770, 364, 364, 157, 81, 179, 1406, 1323, /* 20 */ 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, /* 30 */ 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, /* 40 */ 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1654, - /* 50 */ 1654, 1654, 1654, 1654, 1654, 1736, 1654, 1818, 370, 798, - /* 60 */ 181, 370, 2083, 2083, 2083, 2083, 2083, 887, 887, 565, + /* 50 */ 1654, 1654, 1654, 1654, 1654, 1654, 1654, 1736, 370, 798, + /* 60 */ 181, 370, 2001, 2001, 2001, 2001, 2001, 887, 887, 565, /* 70 */ 277, 4, 1510, 1492, 1458, 1375, 1449, 1434, 1431, 1427, - /* 80 */ 1379, 448, 1399, 2097, 2097, 2100, 439, 2097, 2092, 2083, + /* 80 */ 1379, 448, 1399, 2066, 2066, 2069, 439, 2066, 2064, 2001, /* 90 */ 565, 1039, 538, 538, 735, 84, 44, 171, 859, 775, /* 100 */ 906, 773, 910, 636, 1172, 5, 450, 5, 443, 413, - /* 110 */ 185, 2080, 1924, 1760, 1840, 1755, 1739, 2063, 2077, 2058, - /* 120 */ 1525, 2056, 1724, 2040, 2035, 1777, 1734, 1517, 1844, 1775, + /* 110 */ 185, 2059, 2040, 1775, 1947, 1840, 1991, 2016, 1933, 2014, + /* 120 */ 1525, 1999, 1724, 1995, 1974, 1965, 1734, 1517, 1693, 1855, /* 130 */ 1047, 1593, 1597, 902, 140, 1542, 1542, 1436, 1564, 1542, /* 140 */ 1236, 780, 1409, 349, 562, 216, 620, 1559, 1515, 1348, - /* 150 */ 90, 829, 829, 829, 872, 544, 2222, 2222, 2222, 2222, - /* 160 */ 2222, -81, -81, 459, 619, 619, 619, 619, 619, 619, + /* 150 */ 90, 829, 829, 829, 872, 544, 2202, 2202, 2202, 2202, + /* 160 */ 2202, -81, -81, 459, 619, 619, 619, 619, 619, 619, /* 170 */ 619, 619, 619, 645, 327, 683, 1180, 1149, 1117, 1087, /* 180 */ 1051, 1021, 985, 958, 916, 767, 1239, 1212, 1276, 509, /* 190 */ 509, -60, -38, -38, -38, -38, 578, -80, 314, 87, /* 200 */ 87, 41, 155, 75, 58, 58, 58, -6, 186, 862, /* 210 */ -47, 808, 1649, 1463, 1284, 206, 908, 424, 400, 25, /* 220 */ 729, 729, 679, 1364, -2, 855, 729, 442, 346, 855, - /* 230 */ 750, 750, 187, -9, 169, 2228, 2143, 2141, 2139, 2216, - /* 240 */ 2216, 2132, 2130, 2142, 2120, 2142, 2118, 2142, 2113, 2142, - /* 250 */ 2094, 1791, 1719, 2079, 1791, 2093, 2064, 2057, 2055, 2093, - /* 260 */ 1719, 2051, 1976, 2104, 2029, 1791, 2003, 1791, 1948, 1859, - /* 270 */ 1880, 1880, 1880, 1880, 1987, 1859, 1880, 1919, 1880, 1987, - /* 280 */ 1880, 1880, 1856, 1887, 1877, 1804, 1859, 1872, 1859, 1889, - /* 290 */ 1848, 1762, 1787, 1748, 1738, 1719, 1737, 1813, 1749, 1791, - /* 300 */ 1765, 1765, 1658, 1658, 1658, 1658, -81, -81, -81, -81, + /* 230 */ 750, 750, 187, -9, 169, 2208, 2120, 2118, 2116, 2196, + /* 240 */ 2196, 2112, 2109, 2143, 2108, 2143, 2107, 2143, 2105, 2143, + /* 250 */ 2101, 1761, 1712, 2094, 1761, 2122, 2091, 2087, 2086, 2122, + /* 260 */ 1712, 2061, 1994, 2110, 2032, 1761, 2011, 1761, 1956, 1801, + /* 270 */ 1836, 1836, 1836, 1836, 1971, 1801, 1836, 1904, 1836, 1971, + /* 280 */ 1836, 1836, 1796, 1835, 1815, 1754, 1801, 1818, 1801, 1825, + /* 290 */ 1807, 1729, 1725, 1728, 1722, 1712, 1691, 1771, 1721, 1761, + /* 300 */ 1737, 1737, 1673, 1673, 1673, 1673, -81, -81, -81, -81, /* 310 */ -81, -81, -81, -81, -81, -81, 564, 79, 158, 45, /* 320 */ 702, 243, -49, 398, 1362, 1321, 1042, 984, 788, 2, - /* 330 */ 471, -20, 758, 678, 344, 144, -44, 1676, 1661, 1601, - /* 340 */ 1612, 1591, 1549, 1558, 1543, 1511, 1541, 1519, 1496, 1459, + /* 330 */ 471, -20, 758, 678, 344, 144, -44, 1674, 1670, 1601, + /* 340 */ 1603, 1591, 1549, 1558, 1543, 1511, 1541, 1519, 1496, 1459, /* 350 */ 1575, 1484, 1545, 1536, 1550, 1490, 1487, 1418, 1420, 1483, /* 360 */ 1480, 1419, 1402, 1527, 1407, 1424, 1417, 1433, 1389, 1380, /* 370 */ 1405, 1454, 1394, 1393, 1377, 1368, 1425, 1444, 1327, 1369, @@ -758,40 +755,40 @@ static const short yy_shift_ofst[] = { #define YY_REDUCE_USE_DFLT (-100) #define YY_REDUCE_COUNT (315) #define YY_REDUCE_MIN (-99) -#define YY_REDUCE_MAX (2085) +#define YY_REDUCE_MAX (2067) static const short yy_reduce_ofst[] = { /* 0 */ 615, 1195, 699, -99, 764, 1138, 189, 705, 1259, 1218, - /* 10 */ 1201, 261, 196, 884, 599, 1187, 1950, 1946, 1940, 1922, - /* 20 */ 1920, 1917, 1915, 1892, 1881, 1878, 1874, 1858, 1855, 1838, - /* 30 */ 1835, 1812, 1808, 1801, 1798, 1768, 1766, 1750, 1743, 1732, - /* 40 */ 1717, 1712, 1681, 1675, 1636, 1617, 1613, 1599, 1572, 1568, + /* 10 */ 1201, 261, 196, 884, 599, 1187, 1897, 1892, 1887, 1868, + /* 20 */ 1858, 1853, 1848, 1838, 1833, 1814, 1810, 1808, 1798, 1791, + /* 30 */ 1773, 1768, 1766, 1750, 1743, 1733, 1726, 1723, 1719, 1709, + /* 40 */ 1703, 1685, 1675, 1668, 1636, 1617, 1613, 1599, 1572, 1568, /* 50 */ 1534, 1532, 1518, 1503, 1486, 1435, 1428, 1404, 490, 1401, /* 60 */ 214, 769, 1544, 1529, 1225, 124, 67, 596, 175, 547, - /* 70 */ 1221, 1562, 1884, 1839, 1832, 1803, 1727, 1648, 1611, 1603, - /* 80 */ 1270, 1520, 203, 1346, 1255, 131, 347, 950, 1397, 195, - /* 90 */ 885, 265, 1134, 1132, 125, 377, 1011, 2049, 2043, 2028, - /* 100 */ 1792, 1792, 2038, 2037, 2034, 697, 2033, 11, 1792, 2032, - /* 110 */ 2028, 2023, 1792, 1792, 1792, 1792, 1792, 1792, 1792, 2018, - /* 120 */ 1792, 1792, 1998, 1792, 1792, 1995, 1792, 1792, 1792, 1945, - /* 130 */ 1934, 1918, 1908, 1893, 1837, 1141, 1140, 1831, 1802, 1065, - /* 140 */ 1800, 1792, 1728, 1659, 1614, 1485, 632, 1474, 1452, 1294, + /* 70 */ 1221, 1614, 1964, 1959, 1952, 1949, 1937, 1802, 1611, 1587, + /* 80 */ 1270, 1562, 203, 1346, 1255, 131, 347, 950, 1397, 195, + /* 90 */ 885, 265, 1134, 1132, 125, 377, 1011, 2006, 2005, 1979, + /* 100 */ 1671, 1671, 2004, 2002, 2000, 697, 1990, 11, 1671, 1984, + /* 110 */ 1979, 1978, 1671, 1671, 1671, 1671, 1671, 1671, 1671, 1973, + /* 120 */ 1671, 1671, 1967, 1671, 1671, 1938, 1671, 1671, 1671, 1926, + /* 130 */ 1885, 1844, 1839, 1837, 1803, 1141, 1140, 1767, 1762, 1065, + /* 140 */ 1738, 1671, 1659, 1643, 1569, 1485, 632, 1474, 1452, 1294, /* 150 */ 1232, 1191, 666, 489, 938, 1022, 1020, 956, 924, 791, /* 160 */ 763, 746, 205, 1462, 1462, 1462, 1462, 1462, 1462, 1462, /* 170 */ 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, /* 180 */ 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, - /* 190 */ 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, 2070, 2082, - /* 200 */ 2081, 1462, 1997, 1997, 2068, 2066, 2065, 2039, 2060, 2016, - /* 210 */ 2052, 2007, 2006, 2076, 2075, 2073, 2071, 2041, 2085, 2036, - /* 220 */ 2017, 2015, 2059, 2048, 2050, 2054, 2012, 2013, 1994, 2047, - /* 230 */ 1990, 1986, 1462, 2020, 2021, 1973, 1799, 2000, 1996, 1968, - /* 240 */ 1964, 1989, 1799, 2008, 1799, 2004, 1799, 1999, 1799, 1979, - /* 250 */ 1953, 2002, 1952, 1926, 1981, 1944, 1907, 1799, 1799, 1937, - /* 260 */ 1910, 1799, 1886, 1869, 1885, 1923, 1799, 1913, 1799, 1875, - /* 270 */ 1900, 1888, 1866, 1846, 1867, 1847, 1843, 1836, 1826, 1796, - /* 280 */ 1824, 1823, 1764, 1740, 1730, 1706, 1757, 1698, 1751, 1700, - /* 290 */ 1462, 1682, 1673, 1667, 1657, 1651, 1638, 1679, 1645, 1647, - /* 300 */ 1643, 1642, 1629, 1610, 1592, 1587, 1478, 1472, 1473, 1578, - /* 310 */ 1573, 1506, 1462, 1462, 1462, 1540, + /* 190 */ 1462, 1462, 1462, 1462, 1462, 1462, 1462, 1462, 2047, 2058, + /* 200 */ 2057, 1462, 1980, 1980, 2046, 2045, 2041, 2012, 2031, 2009, + /* 210 */ 2028, 1983, 1987, 2054, 2053, 2052, 2043, 2017, 2067, 2010, + /* 220 */ 1998, 1997, 2034, 2025, 2026, 2027, 1996, 1986, 1975, 2024, + /* 230 */ 1969, 1968, 1462, 2007, 2003, 1950, 1859, 1982, 1981, 1948, + /* 240 */ 1944, 1972, 1859, 1993, 1859, 1992, 1859, 1988, 1859, 1985, + /* 250 */ 1960, 2019, 1970, 1957, 2008, 1976, 1939, 1859, 1859, 1963, + /* 260 */ 1935, 1859, 1886, 1871, 1884, 1931, 1859, 1914, 1859, 1890, + /* 270 */ 1888, 1879, 1878, 1876, 1852, 1847, 1841, 1820, 1811, 1774, + /* 280 */ 1776, 1755, 1730, 1689, 1688, 1651, 1708, 1645, 1692, 1633, + /* 290 */ 1462, 1647, 1641, 1640, 1632, 1626, 1625, 1644, 1639, 1634, + /* 300 */ 1627, 1618, 1608, 1606, 1605, 1604, 1478, 1472, 1475, 1540, + /* 310 */ 1539, 1491, 1462, 1462, 1462, 1523, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 729, 1037, 1142, 1142, 1026, 1026, 1026, 1142, 1026, 1026, @@ -3183,23 +3180,15 @@ static void yy_reduce( } break; case 81: /* term ::= NULL */ -{ - yygotominor.yy21 = new QVariant(); - } +{yygotominor.yy21 = new QVariant();} break; case 82: /* term ::= INTEGER */ -{ - int base = 10; - if (yymsp[0].minor.yy0->value.startsWith("0x", Qt::CaseInsensitive)) - base = 16; - - yygotominor.yy21 = new QVariant(yymsp[0].minor.yy0->value.toLongLong(nullptr, base)); - } + case 351: /* number ::= INTEGER */ yytestcase(yyruleno==351); +{yygotominor.yy21 = parserContext->handleNumberToken(yymsp[0].minor.yy0->value);} break; case 83: /* term ::= FLOAT */ -{ - yygotominor.yy21 = new QVariant(QVariant(yymsp[0].minor.yy0->value).toDouble()); - } + case 352: /* number ::= FLOAT */ yytestcase(yyruleno==352); +{yygotominor.yy21 = new QVariant(QVariant(yymsp[0].minor.yy0->value).toDouble());} break; case 84: /* term ::= STRING|BLOB */ case 345: /* nmnum ::= ON */ yytestcase(yyruleno==345); @@ -4273,7 +4262,6 @@ static void yy_reduce( } break; case 277: /* exprx ::= BITNOT expr */ - case 278: /* exprx ::= MINUS expr */ yytestcase(yyruleno==278); case 279: /* exprx ::= PLUS expr */ yytestcase(yyruleno==279); { yygotominor.yy490 = new SqliteExpr(); @@ -4281,6 +4269,23 @@ static void yy_reduce( objectForTokens = yygotominor.yy490; } break; + case 278: /* exprx ::= MINUS expr */ +{ + yygotominor.yy490 = new SqliteExpr(); + if (yymsp[0].minor.yy490->mode == SqliteExpr::Mode::LITERAL_VALUE && + parserContext->isCandidateForMaxNegativeNumber() && + yymsp[0].minor.yy490->literalValue == static_cast<qint64>(0L)) + { + yygotominor.yy490->initLiteral(std::numeric_limits<qint64>::min()); + delete yymsp[0].minor.yy490; + } + else + { + yygotominor.yy490->initUnaryOp(yymsp[0].minor.yy490, yymsp[-1].minor.yy0->value); + } + objectForTokens = yygotominor.yy490; + } + break; case 280: /* exprx ::= expr not_opt BETWEEN expr AND expr */ { yygotominor.yy490 = new SqliteExpr(); @@ -4316,7 +4321,7 @@ static void yy_reduce( case 284: /* exprx ::= expr not_opt IN nm dbnm */ { yygotominor.yy490 = new SqliteExpr(); - yygotominor.yy490->initIn(yymsp[-4].minor.yy490, yymsp[-3].minor.yy237, *(yymsp[-1].minor.yy211), *(yymsp[0].minor.yy211)); + yygotominor.yy490->initIn(yymsp[-4].minor.yy490, *(yymsp[-3].minor.yy237), *(yymsp[-1].minor.yy211), *(yymsp[0].minor.yy211)); delete yymsp[-3].minor.yy237; delete yymsp[-1].minor.yy211; objectForTokens = yygotominor.yy490; @@ -4577,19 +4582,18 @@ static void yy_reduce( if (yymsp[0].minor.yy21->type() == QVariant::Double) *(yymsp[0].minor.yy21) = -(yymsp[0].minor.yy21->toDouble()); else if (yymsp[0].minor.yy21->type() == QVariant::LongLong) - *(yymsp[0].minor.yy21) = -(yymsp[0].minor.yy21->toLongLong()); + { + if (parserContext->isCandidateForMaxNegativeNumber()) + *(yymsp[0].minor.yy21) = std::numeric_limits<qint64>::min(); + else + *(yymsp[0].minor.yy21) = -(yymsp[0].minor.yy21->toLongLong()); + } else Q_ASSERT_X(true, "producing minus number", "QVariant is neither of Double or LongLong."); yygotominor.yy21 = yymsp[0].minor.yy21; } break; - case 351: /* number ::= INTEGER */ -{yygotominor.yy21 = new QVariant(QVariant(yymsp[0].minor.yy0->value).toLongLong());} - break; - case 352: /* number ::= FLOAT */ -{yygotominor.yy21 = new QVariant(QVariant(yymsp[0].minor.yy0->value).toDouble());} - break; case 353: /* cmd ::= CREATE temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON nm foreach_clause when_clause BEGIN trigger_cmd_list END */ { yygotominor.yy399 = new SqliteCreateTrigger( diff --git a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.y b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.y index 0353e2c..0bab877 100644 --- a/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.y +++ b/SQLiteStudio3/coreSQLiteStudio/parser/sqlite3_parse.y @@ -57,6 +57,7 @@ #include "parser/ast/sqlitewith.h" #include <QObject> #include <QDebug> +#include <limits.h> #define assert(X) Q_ASSERT(X) #define UNUSED_PARAMETER(X) (void)(X) @@ -539,19 +540,9 @@ ccons(X) ::= CHECK LP RP. { %type term {QVariant*} %destructor term {delete $$;} -term(X) ::= NULL. { - X = new QVariant(); - } -term(X) ::= INTEGER(N). { - int base = 10; - if (N->value.startsWith("0x", Qt::CaseInsensitive)) - base = 16; - - X = new QVariant(N->value.toLongLong(nullptr, base)); - } -term(X) ::= FLOAT(N). { - X = new QVariant(QVariant(N->value).toDouble()); - } +term(X) ::= NULL. {X = new QVariant();} +term(X) ::= INTEGER(N). {X = parserContext->handleNumberToken(N->value);} +term(X) ::= FLOAT(N). {X = new QVariant(QVariant(N->value).toDouble());} term(X) ::= STRING|BLOB(S). {X = new QVariant(S->value);} // The optional AUTOINCREMENT keyword @@ -1625,7 +1616,17 @@ exprx(X) ::= BITNOT(O) expr(E). { } exprx(X) ::= MINUS(O) expr(E). [BITNOT] { X = new SqliteExpr(); - X->initUnaryOp(E, O->value); + if (E->mode == SqliteExpr::Mode::LITERAL_VALUE && + parserContext->isCandidateForMaxNegativeNumber() && + E->literalValue == static_cast<qint64>(0L)) + { + X->initLiteral(std::numeric_limits<qint64>::min()); + delete E; + } + else + { + X->initUnaryOp(E, O->value); + } objectForTokens = X; } exprx(X) ::= PLUS(O) expr(E). [BITNOT] { @@ -1664,7 +1665,7 @@ exprx(X) ::= expr(E) not_opt(N) IN LP exprx(X) ::= expr(E) not_opt(N) IN nm(N1) dbnm(N2). [IN] { X = new SqliteExpr(); - X->initIn(E, N, *(N1), *(N2)); + X->initIn(E, *(N), *(N1), *(N2)); delete N; delete N1; objectForTokens = X; @@ -1991,7 +1992,12 @@ minus_num(X) ::= MINUS number(N). { if (N->type() == QVariant::Double) *(N) = -(N->toDouble()); else if (N->type() == QVariant::LongLong) - *(N) = -(N->toLongLong()); + { + if (parserContext->isCandidateForMaxNegativeNumber()) + *(N) = std::numeric_limits<qint64>::min(); + else + *(N) = -(N->toLongLong()); + } else Q_ASSERT_X(true, "producing minus number", "QVariant is neither of Double or LongLong."); @@ -2000,7 +2006,7 @@ minus_num(X) ::= MINUS number(N). { %type number {QVariant*} %destructor number {delete $$;} -number(X) ::= INTEGER(N). {X = new QVariant(QVariant(N->value).toLongLong());} +number(X) ::= INTEGER(N). {X = parserContext->handleNumberToken(N->value);} number(X) ::= FLOAT(N). {X = new QVariant(QVariant(N->value).toDouble());} //////////////////////////// The CREATE TRIGGER command ///////////////////// |
