xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
BasicTokenizer.h
Go to the documentation of this file.
1#ifndef QUERY_BASIC_TOKENIZER_H
2#define QUERY_BASIC_TOKENIZER_H
3
4#include "Query/ITokenizer.h"
5
6#include <cctype>
7#include <algorithm>
8
9namespace Xale::Query
10{
15 {
16 public:
17 void setInput(const std::string& input) override;
18 Token nextToken() override;
19 Token peekToken() const override;
20 void reset() override;
21 std::vector<Token> tokenize() override;
22 private:
23 Token readToken();
24 void skipWhitespace();
25 char currentChar() const;
26 char goNextChar();
27 bool isAtEnd() const;
28
29 std::string _input;
30 size_t _pos = 0;
31 mutable bool _hasPeeked = false;
32 mutable Token _peekedToken;
33 };
34}
35
36#endif // BASIC_QUERY_TOKENIZER_H
Basic implementation of SQL tokenizer.
Definition BasicTokenizer.h:15
Token nextToken() override
Get the next token.
Definition BasicTokenizer.cpp:26
std::vector< Token > tokenize() override
Tokenize all the input.
Definition BasicTokenizer.cpp:52
void setInput(const std::string &input) override
Set the input string to tokenize.
Definition BasicTokenizer.cpp:8
Token peekToken() const override
Get the current token.
Definition BasicTokenizer.cpp:39
void reset() override
Reset the cursor and the current token.
Definition BasicTokenizer.cpp:17
Interface for SQL tokenizer that converts an input string into a sequence of tokens.
Definition ITokenizer.h:15
Definition BasicParser.h:16
Token struct defined by type, value and pos.
Definition Token.h:31