-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScanner.hpp
More file actions
40 lines (34 loc) · 752 Bytes
/
Scanner.hpp
File metadata and controls
40 lines (34 loc) · 752 Bytes
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
#ifndef SCANNER_H_
#define SCANNER_H_
#include "Token.hpp"
#include "Lox.hpp"
#include "Object.hpp"
#include <string>
#include <vector>
#include <map>
class Scanner {
public:
Scanner(Lox& lox, std::string input);
std::vector<Token> scanTokens();
void scanToken();
void identifier();
void number();
void string();
bool match(char expected);
char peek();
char peekNext();
bool isAlpha(char c);
bool isAlphaNumeric(char c);
bool isDigit(char c);
bool isAtEnd();
char advance();
void addToken(TokenType type);
void addToken(TokenType type, Object literal);
private:
Lox& m_lox;
std::string m_input;
std::vector<Token> m_tokens;
int m_start, m_current, m_line;
std::map<std::string, TokenType> m_keywords;
};
#endif // SCANNER_H_