-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtokenizer.h
40 lines (33 loc) · 830 Bytes
/
tokenizer.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
#ifndef TOKENIZER_H
#define TOKENIZER_H
#include <string>
#include <vector>
#include <fstream>
#include "enums.h"
#include "utils.h"
class Tokenizer {
private:
std::ifstream JackFile;
std::string currentToken;
std::vector<std::string> tokens;
size_t currentTokenIndex = 0;
bool hasMore = true;
bool isSymbol(char c);
public:
// Constructor
Tokenizer(const std::string& inputFile);
// Destructor
~Tokenizer();
// Public methods
void printAll();
bool hasMoreTokens();
void advance();
TokenType tokenType();
KeywordType keyWord();
char symbol(const std::string& token);
bool isValidIdenitier(const std::string& token);
std::string identifier();
int intVal(const std::string& token);
std::string stringVal(const std::string& token);
};
#endif