diff --git a/CMakeLists.txt b/CMakeLists.txt index ec76119..8de5134 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,8 +109,6 @@ add_executable(pglab pglab/QueryTab.cpp pglab/RolesTableModel.cpp pglab/ServerWindow.cpp - pglab/SqlHighlighter.cpp - pglab/sqlparser.cpp pglab/SqlSyntaxHighlighter.cpp pglab/stopwatch.cpp pglab/tsqueue.cpp diff --git a/pglab/SqlHighlighter.cpp b/pglab/SqlHighlighter.cpp deleted file mode 100644 index 36885b4..0000000 --- a/pglab/SqlHighlighter.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "SqlHighlighter.h" - -// static const wchar_t *keywords[] = { -// L"as", L"alter", L"all", L"and", L"any", L"by", L"char", L"column", L"create", L"database", L"date", L"from", L"full", L"group", L"having", -// L"in", L"inner", L"int", L"join", L"left", L"not", L"numeric", L"or", L"order", L"outer", L"right", L"select", L"smallint", L"table", L"time", -// L"timestamp", L"timestamptz", L"varchar", L"where" -// }; -// -// static const wchar_t *operators[] = { -// L"+", L"-", L"*", L"/", L"<", L">", L"<=", L">=", L"<>", L"!=", L"~" -// }; - - -/* - - + - * / < > = ~ ! @ # % ^ & | ` ? - -There are a few restrictions on your choice of name: - - -- and C-comment start cannot appear anywhere in an operator name, since they will be taken as the start of a comment. - - A multicharacter operator name cannot end in + or -, unless the name also contains at least one of these characters: - - ~ ! @ # % ^ & | ` ? - For example, @- is an allowed operator name, but *- is not. This restriction allows PostgreSQL to parse SQL-compliant commands without requiring spaces between tokens. - - The use of => as an operator name is deprecated. It may be disallowed altogether in a future release. - -The operator != is mapped to <> on input, so these two names are always equivalent. - -+ - * / < > = - -*/ - -//static auto types = R"-(bigint|boolean|char|character varying|date|int[248]|integer|numeric|smallint|time|timestamp(?:tz)?|timestamp(?:\s+with\s+timezone)?|varchar)-"; -//static auto err = R"-(left|right|inner|outer)-"; - -// static_assert(sizeof(keywords)/4 == 25, -// "sizeof keywords"); - - -SqlHighlighter::SqlHighlighter(QTextDocument *parent) - : QSyntaxHighlighter(parent) -{ -// { - static auto keywords = - R"-(\balter\b|\ball\b|\band\b|\bany\b|\bas\b|\bby\b|\bcascade\b|\bcheck\b|\bcolumn\b|\bcopy\b|\bcreate\b|\bdatabase\b|\bdefault\b|\bdelete\b)-" - R"-(|\foreign\b|\bfrom\b|\bgroup\b|\bhaving\b|\bin\b|\bindex\b|\bis\b|\bkey\b|\blimit\b|\bnatural\b|\bnot\b|\bnull\b|\boffset\b|\bon\b)-" - R"-(|\bor\b|\border\b|\bover\b|\bparition\b|\bprimary\b|\breferences\b|\brestrict\b|\bselect\b|\btable\b|\btruncate\b|\bunique\b|\bupdate\b|\busing\b)-" - R"-(|\bwhere\b|\bwith\b|(?:(?:inner|(?:left|right|full)(\s+outer)?)\s+)?join)-"; - - // into temp DISTINCT true false - - static auto types = - R"-(\bbigint\b|\bboolean\b|\bchar\b|\bcharacter varying\b|\bdate\b|\bint[248]\b|\binteger\b|\bnumeric\b|\bsmallint\b)-" - R"-(|\btime\b|\btimestamp(?:tz)?\b|\btimestamp(?:\s+with\s+time\s+zone)?\b|\bvarchar\b)-"; -// static auto err = R"-(left|right|inner|outer)-"; - -// QTextCharFormat errFormat; -// errFormat.setForeground(QColor(255, 128, 128)); -// errFormat.setFontWeight(QFont::Bold); -// highlightingRules.emplace_back(QRegExp(err, Qt::CaseInsensitive), errFormat); - - QTextCharFormat keywordFormat; - keywordFormat.setForeground(QColor(64, 64, 192)); - keywordFormat.setFontWeight(QFont::Bold); - highlightingRules.emplace_back(QRegExp(keywords, Qt::CaseInsensitive), keywordFormat); - - QTextCharFormat typesFormat; - typesFormat.setForeground(QColor(64, 192, 64)); - typesFormat.setFontWeight(QFont::Bold); - highlightingRules.emplace_back(QRegExp(types, Qt::CaseInsensitive), typesFormat); - -// } -} - -void SqlHighlighter::highlightBlock(const QString &text) -{ - foreach (const HighlightingRule &rule, highlightingRules) { - QRegExp expression(rule.pattern); - int index = expression.indexIn(text); - while (index >= 0) { - int length = expression.matchedLength(); - setFormat(index, length, rule.format); - index = expression.indexIn(text, index + length); - } - } - setCurrentBlockState(0); -} - - - diff --git a/pglab/SqlHighlighter.h b/pglab/SqlHighlighter.h deleted file mode 100644 index ee3ab91..0000000 --- a/pglab/SqlHighlighter.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once - -#include -#include - -#include - -class SqlHighlighter : public QSyntaxHighlighter -{ - Q_OBJECT - -public: - SqlHighlighter(QTextDocument *parent = 0); - -protected: - void highlightBlock(const QString &text) override; - -private: - struct HighlightingRule - { - QRegExp pattern; - QTextCharFormat format; - - HighlightingRule(const QRegExp ®ex, const QTextCharFormat &f) - : pattern(regex), format(f) - {} - }; - //QVector highlightingRules; - std::vector highlightingRules; - -// QRegExp commentStartExpression; - // QRegExp commentEndExpression; - - QTextCharFormat keywordFormat; -// QTextCharFormat classFormat; -// QTextCharFormat singleLineCommentFormat; -// QTextCharFormat multiLineCommentFormat; -// QTextCharFormat quotationFormat; -// QTextCharFormat functionFormat; - -}; - diff --git a/pglab/sqlparser.cpp b/pglab/sqlparser.cpp deleted file mode 100644 index 3d960b0..0000000 --- a/pglab/sqlparser.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "sqlparser.h" - -/** Responsible for splitting the query into logical elements. - * - * It first uses common seperators to split the input, then it tries - * to determine if the fields it gets have a special meaning. - * - * However because SQL is very forgiving about the use of keywords - * as names. - * - * The lexical analyzer does however distinguish between - * - symbols/keywords (symbols might be schema, table, columns, functions etc) - * - numbers - * - strings - * - quoted symbol (a symbol between "" must be the name of something) - * - * seperators - * whitespace - * special chars ;,. - * operators - */ -class LexicalAnalyser { -public: - -}; - -SqlParser::SqlParser() -{ - -} diff --git a/pglab/sqlparser.h b/pglab/sqlparser.h deleted file mode 100644 index 4dc8b4d..0000000 --- a/pglab/sqlparser.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef SQLPARSER_H -#define SQLPARSER_H - - -class SqlParser -{ -public: - SqlParser(); -}; - -#endif // SQLPARSER_H \ No newline at end of file