-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvocabulary.h
116 lines (107 loc) · 2.4 KB
/
vocabulary.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
using namespace std;
// This file contains all the necessary function required to identify each character and their category.
bool isLetter(char newElement)
{
int size = 52;
char letter[size] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
for (int i = 0; i < size; ++i)
{
if (letter[i] == newElement)
{
return true;
}
}
return false;
}
bool isDigit(char newElement)
{
int size = 10;
char digit[size] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
for (int i = 0; i < size; ++i)
{
if (digit[i] == newElement)
{
return true;
}
}
return false;
}
bool isSpace(char newElement)
{
int size = 3;
char space[size] = {' ', '\t', '\n'};
for (int i = 0; i < size; ++i)
{
if (space[i] == newElement)
{
return true;
}
}
return false;
}
bool isOperator(char newElement)
{
int size = 26;
char operator_symb[size] = {'+', '-', '*', '<', '>', '&', '.', '@', '/', ':', '=', '~', '|', '$', '!', '#', '%', '^', '_', '[', ']', '{', '}', '"', '`', '?'};
for (int i = 0; i < size; ++i)
{
if (operator_symb[i] == newElement)
{
return true;
}
}
return false;
}
bool isPunction(char newElement)
{
int size = 4;
char punction[size] = {'(', ')', ';', ','};
for (int i = 0; i < size; ++i)
{
if (punction[i] == newElement)
{
return true;
}
}
return false;
}
bool isReserved(string token)
{
int size = 20;
string reserved[size] = {"dummy", "nil", "within", "and", "rec", "false", "true", "ne", "eq", "le", "ls", "ge", "gr", "not", "or", "aug", "where", "fn", "let", "in"};
for (int i = 0; i < size; ++i)
{
if (reserved[i] == token)
{
return true;
}
}
return false;
}
bool isBOp(string token) // Binary operators
{
int size = 14;
string op[size] = {"aug", "or", "&", "+", "-", "/", "**", "*", "gr", "ge", "le", "ls", "eq", "ne"};
for (int i = 0; i < size; ++i)
{
if (op[i] == token)
{
return true;
}
}
return false;
}
bool isUOp(string token) // Unary operators
{
int size = 2;
string op[size] = {"not", "neg"};
for (int i = 0; i < size; ++i)
{
if (op[i] == token)
{
return true;
}
}
return false;
}