-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTypes.cpp
More file actions
58 lines (53 loc) · 892 Bytes
/
Copy pathTypes.cpp
File metadata and controls
58 lines (53 loc) · 892 Bytes
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
#include "Types.h"
namespace SmallTranslator
{
bool IsKeyWord(std::string& token)
{
if(token == "if")
return true;
if(token == "then")
return true;
if(token == "else")
return true;
if(token == "elif")
return true;
if(token == "while")
return true;
if(token == "do")
return true;
if(token == "end")
return true;
if(token == "and")
return true;
if(token == "or")
return true;
if(token == "in")
return true;
if(token == "out")
return true;
if(token == "void")
return true;
if(token == "func")
return true;
if(token == "return")
return true;
return false;
}
bool IsName(std::string& str)
{
if (isalpha(str[0]) && !IsKeyWord(str) || str[0] == '_')
{
return true;
}
return false;
}
bool IsNumber(std::string& str)
{
for (auto&c : str)
{
if (!isdigit(c))
return false;
}
return true;
}
}