-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.hpp
34 lines (27 loc) · 1.1 KB
/
token.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
#ifndef TOKEN_H
#define TOKEN_H
#include <string>
#include <map>
enum class TokenType {
// define all the types of tokens that will be used.
// Whitespace and Newline are not included as they will be discarded during the lexical analysis
// Begin of block { is not included as it only marks comments, which will be discarded
IDENTIFER, INTEGER, CHAR, STRING, COMMENT_1, COMMENT_2,
PROGRAM, VAR, CONST, TYPE, FUNCTION, RETURN, BEGIN, END, SWAP, ASSIGN, OUTPUT, IF,
THEN, ELSE, WHILE, DO, CASE, OF, DOTS, OTHERWISE, REPEAT, FOR, UNTIL, LOOP, POOL,
EXIT, LEQ, NEQ, GEQ, GE, LE, EQ, MOD, AND, OR, NOT, READ, SUCC, PRED, CHR, ORD, EOFT,
COLON, SEMICOLON, PERIOD, COMMA, OPENBRKT, CLSBRKT, PLUS, MINUS, MULT, DIVIDE
};
class Token {
private:
TokenType type;
std::string value;
public:
static std::map<TokenType, std::string> predefined_tokens;
Token(TokenType type);
Token(TokenType type, std::string value);
static TokenType identifyNonPredefinedTokenType(char c);
TokenType getType();
std::string getValue();
};
#endif