-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscanner.hpp
45 lines (37 loc) · 871 Bytes
/
scanner.hpp
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
42
43
// Copyright 2020 <Copyright hulin>
#ifndef SCANNER_HPP_
#define SCANNER_HPP_
#include <string>
#include <vector>
#include <map>
#include "./Token.hpp"
using std::string;
using std::map;
using std::vector;
class Scanner {
private:
string source;
vector<Token> tokens;
static map<string, TokenType> keywords;
int start = 0;
int current = 0;
int line = 1;
void scanToken();
char advance();
void addToken(TokenType type);
void addToken(TokenType type, Object literal);
bool match(char expected);
char peek();
void generateString();
void generateNumber();
bool isDigit(char c);
char peekNext();
void identifier();
bool isAlpha(char c);
bool isAlphaNumeric(char c);
public:
explicit Scanner(string source);
vector<Token> scanTokens();
bool isAtEnd();
};
#endif // SCANNER_HPP_