- Convert unquoted idents to lowercase. - Recognize quoted idents. - Allow all unicode whitespace characters - Added UnexpectedSymbol token for unexpected input (otherwise it is just ignored) - Handle mixed case keywords in the lexer file instead of filtering the stream
71 lines
No EOL
1.5 KiB
ANTLR
71 lines
No EOL
1.5 KiB
ANTLR
lexer grammar PgsqlLexer;
|
|
|
|
@lexer::preinclude {
|
|
#include <QString>
|
|
}
|
|
|
|
|
|
SemiColon: ';';
|
|
Comma: ',';
|
|
Dot: '.';
|
|
OpenParen: '(';
|
|
CloseParen: ')';
|
|
|
|
fragment A : 'a' | 'A';
|
|
fragment B : 'B' | 'b';
|
|
fragment C : 'C' | 'c';
|
|
fragment D : 'D' | 'd';
|
|
fragment E : 'E' | 'e';
|
|
fragment F : 'F' | 'f';
|
|
fragment G : 'G' | 'g';
|
|
fragment H : 'H' | 'h';
|
|
fragment I : 'I' | 'i';
|
|
fragment J : 'J' | 'j';
|
|
fragment K : 'K' | 'k';
|
|
fragment L : 'L' | 'l';
|
|
fragment M : 'M' | 'm';
|
|
fragment N : 'N' | 'n';
|
|
fragment O : 'O' | 'o';
|
|
fragment P : 'P' | 'p';
|
|
fragment Q : 'Q' | 'q';
|
|
fragment R : 'R' | 'r';
|
|
fragment S : 'S' | 's';
|
|
fragment T : 'T' | 't';
|
|
fragment U : 'U' | 'u';
|
|
fragment V : 'V' | 'v';
|
|
fragment W : 'W' | 'w';
|
|
fragment X : 'X' | 'x';
|
|
fragment Y : 'Y' | 'y';
|
|
fragment Z : 'Z' | 'z';
|
|
|
|
As: A S;
|
|
By: B Y;
|
|
From: F R O M;
|
|
Full: F U L L;
|
|
Group: G R O U P;
|
|
Having: H A V I N G;
|
|
Join: J O I N;
|
|
Left : L E F T;
|
|
Order : O R D E R;
|
|
Right : R I G H T;
|
|
Select: S E L E C T;
|
|
Where: W H E R E;
|
|
|
|
Ident: [\p{Alpha}]~[\p{White_Space}]*
|
|
{
|
|
setText(QString::fromStdString(getText()).toLower().toStdString());
|
|
}
|
|
| '"' ~["]+ '"'
|
|
{
|
|
{
|
|
std::string s = getText();
|
|
s = s.substr(1, s.length() - 2);
|
|
setText(s);
|
|
}
|
|
};
|
|
IntegerLiteral: [1-9][0-9]*;
|
|
StringLiteral: '\'' ('\'\'' | ~['])+ '\'' { setText(getText().substr(1, getText().length()-2)); };
|
|
|
|
Whitespace: [\p{White_Space}] -> skip ; // skip spaces, tabs, newlines
|
|
|
|
UnexpectedSymbol: .; |