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
|
struct Token {
~uint8 data,
int
_type,
line,
col
}
/; method Token
/; eq (Token tok) [bool]
return utils.strcmp(self.data, tok.data)
;/
/; eq_str(~uint8 str) [bool]
return utils.strcmp(self.data, str)
;/
;/
/; _is_space(uint8 char) [bool]
/; if (char == '\t' || char == '\n' || char == '\r' || char == ' ')
return true
;/
return false
;/
/; _in_csv (~uint8 csv, ~uint8 str) [bool]
int along = 0
/; loop (csv` !== 0) [csv++]
/; if (csv` == ',')
/; if (along !< 0 && str{along} == 0)
return true
;/
along = 0
;; else if (along !< 0 && str{along} == csv`)
along++
;; else
along = 0
along--
;/
;/
return along !< 0 && str{along} == 0
;/
/; _str_contains (~uint8 str, uint8 ch) [bool]
/; loop (str` !== 0) [str++]
/; if (str` == ch)
return true
;/
;/
return false
;/
~uint8 KEYWORDS = "module,export,asm,if,else,loop,label,goto,continue,break,return,import,as,using,struct,method,interface,enum,implements,operator,is\0"
~uint8 KEYTYPES = "uint8,uint16,uint32,uint64,uint,int8,int16,int32,int64,int,float32,float64,float,bool,vect,void\0"
~uint8 LITERALS = "false,true\0"
~uint8 RESERVED = "~`!@#$%^&*()[]{}+_=\"\'\\|;:/?.>,<\0"
~uint8 OPS = "`~!%^&*-=+./><\0"
~uint8 MULTI_OPS = "==,&&,||,^^,!==,!&&,!||,!^^,!<,!>,<<,>>,!&,!|,!^,++,--,>==,<==,len\0"
~uint8 DELIMS = "()[]{}\0"
~uint8 MULTI_DELIMS = ";:#\0"
/; tokenize(utils.File fin) [utils.Vector]
Token tok
utils.Vector out
out.init(len tok)
return out
;/
|