-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenHelp.cpp
More file actions
154 lines (149 loc) · 2.74 KB
/
Copy pathtokenHelp.cpp
File metadata and controls
154 lines (149 loc) · 2.74 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#include <bits/stdc++.h>
#include "TokenHeader.h"
using namespace std;
string trim_left(string st, char ch)
{
while (st.size() && st[0] == ch)
{
st.erase(0, 1);
}
return st;
}
string trim_right(string st, char ch)
{
while (st.size() && st[st.size() - 1] == ch)
{
st.erase(st.size() - 1, 1);
}
return st;
}
string trim_both(string st, char ch)
{
st = trim_right(st, ch);
st = trim_left(st, ch);
return st;
}
bool isDigit(char ch)
{
return ch >= '0' && ch <= '9';
}
bool isCapitalLetter(char ch)
{
return ch >= 'A' && ch <= 'Z';
}
bool isSmallLetter(char ch)
{
return ch >= 'a' && ch <= 'z';
}
bool isLetter(char ch)
{
return isSmallLetter(ch) || isCapitalLetter(ch);
}
bool isNumber(string str){
int i=0;
while(str[i]!='\0'){
if(!(isdigit(str[i])))
{
return false;
}
}
return true;
}
string intTostr(int number)
{
string temp;
while (number)
{
int lastDigit = number % 10;
temp += '0' + lastDigit;
number /= 10;
}
reverse(temp.begin(), temp.end());
return temp;
}
int strToint(string str)
{
int temp;
int i = 0;
while (str[i] != '\0')
{
temp *= 10;
temp += str[i] - '0';
i++;
}
return temp;
}
bool validVariableName(string str)
{
if (!(isLetter(str[0]) || str[0] == '_'))
{
return false;
}
int i = 1;
while (str[i] != '\0')
{
if (!(isLetter(str[i]) || isDigit(str[i]) || str[i] == '_'))
{
return false;
}
i++;
}
return true;
}
bool operatorCheck(char ch)
{
if (ch == '{' || ch == '}' || ch == '[' || ch == ']' || ch == '(' || ch == ')' || ch == '#' || ch == ';' || ch == ':' || ch == '?' || ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%' || ch == '^' || ch == '&' || ch == '|' || ch == '!' || ch == '=' || ch == '<' || ch == '>' || ch == ',')
{
return true;
}
else
{
return false;
}
}
bool operatorCheckdouble(char ch)
{
if (ch == '+' || ch == '-' || ch == '&' || ch == '|' || ch == '=' || ch == '>' || ch == '<')
{
return true;
}
else
{
return false;
}
}
bool isItInteger(string check)
{
int i = 0;
while (check[i] != '\0')
{
if (!(isDigit(check[i])))
{
return false;
}
i++;
}
return true;
}
bool isItDouble(string check)
{
int dot = 0;
int i = 0;
while (check[i] != '\0')
{
if (isDigit(check[i]))
{
continue;
}
if (check[i] == '.')
{
dot++;
}
else
{
return false;
}
i++;
}
return dot <= 1;
}