-
Notifications
You must be signed in to change notification settings - Fork 0
/
tokenize.hpp
81 lines (76 loc) · 1.31 KB
/
tokenize.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
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
#pragma once
#include<iostream>
#include<string>
#include<vector>
#include<fstream>
using namespace std;
enum class TokenType{
none,
eof,
error,
string,
integer,
real,
identifier,
contract,
library,
interface,
constructor,
function,
assign, // =
equal, // ==
question, // ?
plus, // +
minus, // -
asterisk, // *
divide, // /
percent, // %
hat, // ^
dot, // .
colon, // :
semicolon, // ;
comma, // ,
lbracket, // {
rbracket, // }
lsbracket, // [
rsbracket, // ]
lparen, // (
rparen, // )
lessequal, // <=
less, // <
greaterequal, // >=
greater, // >
notequal, // !=
or_, // |
doubleor_, // ||
and_, // &
doubleand_, // &&
not_, // !
true_, // true
false_, // false
this_, // this
if_, // i)
else_, // else
for_, // for
while_, // while
do_, // do
return_, // return
break_, // break
continue_, // continue
throw_, // throw
public_, // public
external_, // external
private_, // private
internal_, // internal
is, // is
comment1, // //
comment2, // /*
};
struct Token{
string str;
TokenType type;
int line;
Token(string s = string(), TokenType t = TokenType::none, int _line = 0) : str(s.c_str()), type(t), line(_line) {}
};
vector<Token> Tokenize(const string &str);
typedef vector<Token>::const_iterator Tokit;