-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTokeniser.h
61 lines (51 loc) · 1.22 KB
/
Tokeniser.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Created by shobhit on 24/6/23.
//
#ifndef SOURCECODE_INDENTER_TOKENISER_H
#define SOURCECODE_INDENTER_TOKENISER_H
#include <map>
#include <list>
#include <string>
// preprocessor keyword
#define PRE_PR_KW 1
// preprocessor value
#define PRE_PR_VAL 2
// data type
#define DATA_TYPE 3
// identifier(variable name, etc)
#define IDEN 4
// parenthesis - (, ), [, ]
#define L_PAR 5
#define R_PAR 6
// curly braces
#define OPEN_CURLY 7
#define CLOSE_CURLY 8
// conditions - if, else, while, for, do, switch
#define COND 9
// comparator - <, >, <=, >=, ==, !=
#define COMP 10
// literal - "abcd", 8, 'c', 9.7
#define LITERAL 11
// semi-colon
#define TERMINATOR 12
class Token {
public:
std::string value;
int attribute;
};
class Tokeniser {
std::list<Token> tokenTable;
//std::map<std::string, int> tokenTable;
// <std::string word, int attribute>
public:
// takes specific words as input
// and tokenise
// and adds it to tokenTable list
void tokenise(std::string word);
void printAllToken();
std::list<Token> retTokenTable(std::string original_filePath);
private:
bool isStringInQuotes(std::string word);
bool isStringHeaderVal(std::string word);
};
#endif //SOURCECODE_INDENTER_TOKENISER_H