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:
20 void setInput(const std::string& input) override;
21
25 Token nextToken() override;
26
30 Token peekToken() const override;
31
35 void reset() override;
36
40 std::vector<Token> tokenize() override;
41 private:
46 Token readToken();
47
48 void skipWhitespace();
49 char currentChar() const;
50 char goNextChar();
51 bool isAtEnd() const;
52
53 std::string _input;
54 size_t _pos = 0;
55 mutable bool _hasPeeked = false;
56 mutable Token _peekedToken;
57 };
58}
59
60#endif // BASIC_QUERY_TOKENIZER_H
Basic implementation of SQL tokenizer.
Definition BasicTokenizer.h:15
Token nextToken() override
Get the next token.
Definition BasicTokenizer.cpp:17
std::vector< Token > tokenize() override
Tokenize all the input.
Definition BasicTokenizer.cpp:37
void setInput(const std::string &input) override
Set the input string to tokenize.
Definition BasicTokenizer.cpp:5
Token peekToken() const override
Get the current token.
Definition BasicTokenizer.cpp:27
void reset() override
Reset the cursor and the current token.
Definition BasicTokenizer.cpp:11
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:32