-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScanner.h
41 lines (35 loc) · 831 Bytes
/
Scanner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef SCANNER_H
#define SCANNER_H
#include "Utils.h"
#include "Token.h"
interface IScanner {
public:
virtual Array<Token> scanTokens() = 0;
};
class Scanner : public IScanner {
public:
explicit Scanner(String source);
Array<Token> scanTokens() override;
private:
bool isAtEnd() const;
void scanToken();
char advance();
void addToken(TokenType type);
void addToken(TokenType type, Object literal);
bool match(char expected);
char peek();
void string();
static bool isDigit(char c);
void number();
char peekNext();
void identifier();
static bool isAlpha(char c);
static bool isAlphaNumeric(char c);
String source{};
Array<Token> tokens{};
int start{};
int current{};
static int line;
static Map<String, TokenType> keywords;
};
#endif