-
Notifications
You must be signed in to change notification settings - Fork 0
/
globals.hh
40 lines (31 loc) · 886 Bytes
/
globals.hh
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
#pragma once
#include <iostream>
#include <string>
#include <map>
#include <iterator>
#include <fstream>
#include <vector>
using namespace std;
map<char, char> symbols = { {'+', '+'}, {'-', '-'}, {'*', '*'}, {'/', '/'},
{'=', '='}, {'<', '<'}, {'(', '('}, {')', ')'},
{';', ';'},
};
map<string, string> reservedWords = { {"if", "if"}, {"then", "then"}, {"else", "else"}, {"end", "end"},
{"repeat", "repeat"}, {"until", "until"}, {"read", "read"}, {"write", "write"},
};
typedef enum {
RESERVED, SPECIAL, NUM, ID, ERR, eof
}tokenType;
typedef enum {
START, INCOMMENT, INNUM, INID, INASSIGN, DONE, ERROR
}state;
typedef struct token {
tokenType tType;
string tVal;
}token;
int index = 0;
int limit = 0;
bool isError = false;
int lineNum = 0;
string textBuffer;
vector<string> lines;