37 lines
699 B
C++
37 lines
699 B
C++
#ifndef LEXER_H
|
|
#define LEXER_H
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include "token.h"
|
|
|
|
class Lexer {
|
|
public:
|
|
Lexer(const std::string& source);
|
|
std::vector<Token> tokenize();
|
|
|
|
private:
|
|
std::string source;
|
|
size_t position;
|
|
size_t length;
|
|
int line;
|
|
int column;
|
|
|
|
std::vector<Token> tokenBuffer;
|
|
int interpolationDepth = 0;
|
|
bool resumingString = false;
|
|
|
|
char peek(int offset = 0) const;
|
|
char advance();
|
|
bool isAtEnd() const;
|
|
void skipWhitespace();
|
|
Token makeToken(TokenType type, std::string value);
|
|
Token scanToken();
|
|
Token identifierOrKeyword();
|
|
Token number();
|
|
Token string();
|
|
Token stringPart();
|
|
};
|
|
|
|
#endif // LEXER_H
|