forked from BassamAMansour/compiler_generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTokenGenerator.h
43 lines (29 loc) · 1.11 KB
/
TokenGenerator.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
42
43
//
// Created by sharaf on 08/04/2019.
//
#ifndef COMPILER_GENERATOR_MASTER_TOKENGENERATOR_H
#define COMPILER_GENERATOR_MASTER_TOKENGENERATOR_H
#include <vector>
#include <models/DFAminiState.h>
#include <set>
#include <string>
#include <fstream>
#include <streambuf>
#include <unordered_set>
#define STARTING_STATE_ID 0
class TokenGenerator {
public:
TokenGenerator(vector<vector<DFAminiState>> minimizedDfa, set<char> inputs,
unordered_set<string> punc, unordered_set<string> keywords);
// vector<string> generateTokens(ifstream file);
vector<string> generateTokens(string inputStream);
private:
vector<vector<DFAminiState> > minimizedDfa;
set<char> inputs;
unordered_set<string> keywords, punc;
bool getToken(vector<string> &tokens, int lastAcceptingInput, DFAminiState &lastAcceptingState,
DFAminiState &idleState,int &crrentStateId, int &i, string inputStream, bool endWithPunc);
string isKeyword(int i, string inputStream, bool endWithPunc);
string isPunc(char c);
};
#endif //COMPILER_GENERATOR_MASTER_TOKENGENERATOR_H