Sketched rough parser code construction including some SQL AST classes.
This commit is contained in:
parent
f3898599fd
commit
5b20f900fc
15 changed files with 459 additions and 4 deletions
|
|
@ -15,7 +15,8 @@ enum class BasicTokenType {
|
|||
QuotedIdentifier,
|
||||
Parameter,
|
||||
Operator,
|
||||
Self, // single char representing it self
|
||||
Self, // single char representing it self, maybe remove this and replace with token for each possibility
|
||||
Comma,
|
||||
Cast
|
||||
};
|
||||
|
||||
|
|
@ -25,6 +26,14 @@ enum class LexerState {
|
|||
InBlockComment
|
||||
};
|
||||
|
||||
class SqlToken {
|
||||
public:
|
||||
bool ok;
|
||||
int startPos;
|
||||
int length;
|
||||
BasicTokenType tokenType;
|
||||
QString out;
|
||||
};
|
||||
|
||||
class SqlLexer {
|
||||
public:
|
||||
|
|
@ -40,6 +49,12 @@ public:
|
|||
* @return false when input seems invalid, it will return what it did recognize but something wasn't right, parser should try to recover
|
||||
*/
|
||||
bool nextBasicToken(int &startpos, int &length, BasicTokenType &tokentype, QString &out);
|
||||
SqlToken nextBasicToken()
|
||||
{
|
||||
SqlToken token;
|
||||
token.ok = !nextBasicToken(token.startPos, token.length, token.tokenType, token.out);
|
||||
return token;
|
||||
}
|
||||
|
||||
LexerState currentState() const { return m_state; }
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue