-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jass.j
1718 lines (1452 loc) · 45.2 KB
/
Jass.j
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
library Jass initializer init
public keyword List
globals
public key LPAREN
public key RPAREN
public key RBRACKET
public key LBRACKET
public key NEQ
public key EQ
public key LEQ
public key LT
public key GEQ
public key GT
public key PLUS
public key MINUS
public key MUL
public key DIV
public key MOD
public key AND
public key OR
public key NOT
public key CALL
public key SET
public key LOCAL
public key GLOBALS
public key ENDGLOBALS
public key TYPE
public key EXTENDS
public key NATIVE
public key CONSTANT
public key FUNCTION
public key TAKES
public key RETURNS
public key RETURN
public key IF
public key ELSEIF
public key THEN
public key ELSE
public key ENDIF
public key LOOP
public key EXITWHEN
public key ENDLOOP
public key ENDFUNCTION
public key NULL
public key TrueTok
public key FalseTok
public key ARRAY
public key NL
public key COMMA
public key NOTHING
public key IDENT
public key INTEGER
public key REAL
public key STRING
public key CODE
public key BOOL
public key HEX
public key OCT
public key RAWCODE
public key EqualTok
public constant integer EOF = 0
public string array NAMES
public string array OPERATORS
private integer array hex
public List Nil = 0
endglobals
public struct List
integer head = 0
List tail = 0
endstruct
public function cons takes integer hd, List tl returns List
local List l = List.create()
set l.head = hd
set l.tail = tl
return l
endfunction
public keyword Statement
public keyword NormalDecl
public keyword Expr
private function B2S takes boolean b returns string
if b then
return "true"
else
return "false"
endif
endfunction
private function print takes string s returns nothing
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 120, s)
endfunction
private function trace takes string s returns real
call print(s)
return 0.0
endfunction
private function error takes string s returns nothing
local integer i
call print(s)
set i = 1/0
endfunction
private function assert takes boolean b, string s returns nothing
if not b then
call error("assert: "+ s)
endif
endfunction
/*************************\
* * * * * * * * * * * * * *
* *
* *
* *
* A S T *
* *
* *
* *
* * * * * * * * * * * * * *
\*************************/
public struct Ast
stub method toString takes nothing returns string
return ""
endmethod
endstruct
public struct Toplevel extends Ast
endstruct
public struct VarDecl extends Ast
endstruct
public struct Globals extends Toplevel
List /*VarDecl*/ glbls
static method create takes List defs returns thistype
local thistype this = allocate()
set .glbls = defs
return this
endmethod
method toString takes nothing returns string
local string ret = "(globals \n"
local List l = glbls
loop
exitwhen l == Nil
set ret = ret + VarDecl(l.head).toString() +"\n"
set l = l.tail
endloop
return ret + ")\n"
endmethod
endstruct
public struct TypeDef extends Toplevel
string base
string new
static method create takes string base, string new returns thistype
local thistype this = allocate()
set .base = base
set .new = new
return this
endmethod
method toString takes nothing returns string
return "(type "+ new +" "+ base +")\n"
endmethod
endstruct
public struct TypeAndName extends Ast
string type
string name
static method create takes string typ, string name returns thistype
local thistype this = allocate()
set .name = name
set .type = typ
return this
endmethod
method toString takes nothing returns string
return .type +" : "+ .name
endmethod
endstruct
public struct Native extends Toplevel
boolean const
string name
List /*name, type*/ params
string returntype
static method create takes boolean const, string name, List paramlist, string returntype returns thistype
local thistype this = allocate()
set .const = const
set .name = name
set .params = paramlist
set .returntype = returntype
return this
endmethod
method toString takes nothing returns string
local List l = params
local string ret = "(native "+ name +" "
loop
exitwhen l == Nil
set ret = ret + TypeAndName(l.head).toString() +" "
set l = l.tail
endloop
set ret = ret + "-> "+ returntype +")\n"
return ret
endmethod
endstruct
public struct Function extends Toplevel
boolean const
string name
List /*name, type*/ params
string returntype
List /*Statement*/ body
static method create takes boolean const, string name, List paramlist, string returntype, List body returns thistype
local thistype this = allocate()
set .const = const
set .name = name
set .params = paramlist
set .returntype = returntype
set .body = body
return this
endmethod
method toString takes nothing returns string
local List l = params
local string ret = "(function "+ name +" "
loop
exitwhen l == Nil
set ret = ret + TypeAndName(l.head).toString() +" "
set l = l.tail
endloop
set ret = ret + "-> "+ returntype +"\n"
set l = body
loop
exitwhen l == Nil
set ret = ret + Statement(l.head).toString()
set l = l.tail
endloop
return ret + ")\n"
endmethod
endstruct
public struct ArrayDecl extends VarDecl
string name
string typ
static method create takes string t, string name returns thistype
local thistype this = allocate()
set .name = name
set .typ = t
return this
endmethod
method toString takes nothing returns string
return "(def "+ name +" : "+ typ +"-array)"
endmethod
endstruct
public struct NormalDecl extends VarDecl
boolean const
string name
string typ
Expr init
static method create takes boolean const, string t, string name, Expr init returns thistype
local thistype this = allocate()
set .name = name
set .typ = t
set .init = init
return this
endmethod
method toString takes nothing returns string
if init == 0 then
return "(def "+ name +" : "+ typ +")"
else
return "(def "+ name +" : "+ typ +" "+ init.toString() +")"
endif
endmethod
endstruct
public struct Statement extends Ast
endstruct
public struct Var extends Ast
endstruct
public struct Expr extends Ast
endstruct
public struct ArrayVar extends Var
string name
Expr idx
static method create takes string name, Expr idx returns thistype
local thistype this = allocate()
set .name = name
set .idx = idx
return this
endmethod
method toString takes nothing returns string
return "([] "+ name + " " + idx.toString() +")"
endmethod
endstruct
public struct NormalVar extends Var
string name
static method create takes string name returns thistype
local thistype this = allocate()
set .name = name
return this
endmethod
method toString takes nothing returns string
return name
endmethod
endstruct
public struct Set extends Statement
Var var
Expr value
static method create takes Var v, Expr e returns thistype
local thistype this = allocate()
set .var = v
set .value = e
return this
endmethod
method toString takes nothing returns string
return "(set "+ var.toString() +" "+ value.toString() +")\n"
endmethod
endstruct
public struct Call extends Ast
string name
List /*Expr*/ args
static method create takes string s, List /*Expr*/ l returns thistype
local thistype this = allocate()
set name = s
set .args = l
return this
endmethod
method toString takes nothing returns string
local string ret="(" + .name
local List l = args
loop
exitwhen l == 0
set ret = ret +" "+ Expr(l.head).toString()
set l = l.tail
endloop
return ret+")"
endmethod
endstruct
public struct CallStmt extends Statement
Call cll
static method create takes string s, List /*Expr*/ l returns thistype
local thistype this = allocate()
set .cll = Call.create(s, l)
return this
endmethod
method toString takes nothing returns string
return "(call "+ .cll.toString() +")\n"
endmethod
endstruct
public struct Local extends Statement
VarDecl vd
static method create takes VarDecl vd returns thistype
local thistype this = allocate()
set .vd = vd
return this
endmethod
method toString takes nothing returns string
return "(local "+ .vd.toString() +")\n"
endmethod
endstruct
public struct Loop extends Statement
List /*Statement*/ body
static method create takes List l returns thistype
local thistype this = allocate()
set .body = l
return this
endmethod
method toString takes nothing returns string
local string ret = "(loop \n"
local List l = body
loop
exitwhen l == Nil
set ret = ret + Statement(l.head).toString()
set l = l.tail
endloop
return ret +")\n"
endmethod
endstruct
public struct If extends Statement
Expr cond
List /*Statement*/ thenBody
List /*Statement*/ elseBody
static method create takes Expr cond, List thenBody, List elseBody returns thistype
local thistype this = allocate()
set .cond = cond
set .thenBody = thenBody
set .elseBody = elseBody
return this
endmethod
method toString takes nothing returns string
local string ret
local List it
local List tmp
set ret = "(if " + cond.toString() +" (\n"
set it = thenBody
loop
exitwhen it == Nil
set ret = ret + Statement(it.head).toString()
set it=it.tail
endloop
set ret = ret + ")("
set it = elseBody
loop
exitwhen it == Nil
set ret = ret + Statement(it.head).toString()
set it=it.tail
endloop
set ret = ret + "))\n"
return ret
endmethod
endstruct
public struct Exitwhen extends Statement
Expr cond
static method create takes Expr r returns thistype
local thistype this = allocate()
set .cond = r
return this
endmethod
method toString takes nothing returns string
return "(exitwhen "+ cond.toString() +")\n"
endmethod
endstruct
public struct Return extends Statement
Expr value
static method create takes Expr r returns thistype
local thistype this = allocate()
set .value = r
return this
endmethod
method toString takes nothing returns string
if value == 0 then
return "(return)\n"
else
return "(return "+ value.toString() +")\n"
endif
endmethod
endstruct
public struct Integer extends Expr
integer val
static method create takes integer s returns thistype
local thistype this = allocate()
set .val = s
return this
endmethod
method toString takes nothing returns string
return I2S(.val)
endmethod
endstruct
public struct Rawcode extends Expr
string val
static method create takes string s returns thistype
local thistype this = allocate()
set .val = s
return this
endmethod
method toString takes nothing returns string
return "'"+ .val +"'"
endmethod
endstruct
public struct Real extends Expr
real val
static method create takes real s returns thistype
local thistype this = allocate()
set .val = s
return this
endmethod
method toString takes nothing returns string
return R2SW(.val, 0, 5)
endmethod
endstruct
public struct String extends Expr
string val
static method create takes string s returns thistype
local thistype this = allocate()
set .val = s
return this
endmethod
method toString takes nothing returns string
return "\""+ .val +"\""
endmethod
endstruct
public struct Code extends Expr
string name
static method create takes string s returns thistype
local thistype this = allocate()
set .name = s
return this
endmethod
method toString takes nothing returns string
return "(function "+name+")"
endmethod
endstruct
public struct Null extends Expr
method toString takes nothing returns string
return "null"
endmethod
endstruct
public struct Bool extends Expr
boolean val
static method create takes boolean s returns thistype
local thistype this = allocate()
set .val = s
return this
endmethod
method toString takes nothing returns string
return B2S(.val)
endmethod
endstruct
public struct CallExpr extends Expr
Call cll
static method create takes string s, List /*Expr*/ l returns thistype
local thistype this = allocate()
set .cll = Call.create(s, l)
return this
endmethod
method toString takes nothing returns string
return .cll.toString()
endmethod
endstruct
public struct VarExpr extends Expr
Var var
static method create takes Var var returns thistype
local thistype this = allocate()
set .var = var
return this
endmethod
method toString takes nothing returns string
return .var.toString()
endmethod
endstruct
/*************************\
* * * * * * * * * * * * * *
* *
* *
* *
* L E X E R *
* *
* *
* *
* * * * * * * * * * * * * *
\*************************/
public struct Token
integer type
string value
static method create takes integer k, string v returns thistype
local thistype this = allocate()
set .type = k
set .value = v
return this
endmethod
method toString takes nothing returns string
return NAMES[.type]+" "+.value
endmethod
endstruct
private function startsWith takes string input, string t returns boolean
return SubString(input, 0, StringLength(t)) == t
endfunction
private function isDelim takes string s returns boolean
return s == " " or s == "\t" or s =="\n" or s=="\r" or s=="[" or s=="]" /*
*/ or s == "(" or s == ")" or s == "," or s =="." or s== "<" or s==">" /*
*/ or s == "/" or s=="*" or s== "+" or s =="-" or s=="$" or s== "=" /*
*/ or s == "\"" or s =="'" or s == "!" or s == "%"
endfunction
private function isDigit takes string s returns boolean
return s == "0" or s =="1" or s=="2" or s=="3" or s=="4" or s=="5" /*
*/ or s=="6" or s=="7" or s=="8" or s=="9"
endfunction
private function isLetter takes string s returns boolean
set s = StringCase(s, false)
return s=="a" or s=="b" or s=="c" or s=="d" or s=="e" or s=="f" /*
*/ or s=="g" or s=="h" or s=="i" or s=="j" or s=="k" or s=="l" /*
*/ or s=="m" or s=="n" or s=="o" or s=="p" or s=="q" or s=="r" /*
*/ or s=="s" or s=="t" or s=="u" or s=="v" or s=="w" or s=="x" /*
*/ or s=="y" or s=="z"
endfunction
private function isHex takes string s returns boolean
set s = StringCase(s, false)
return isDigit(s) or s=="a" or s=="b" or s=="c" or s=="d" /*
*/ or s == "e" or s=="f"
endfunction
private function isOct takes string s returns boolean
return s == "0" or s =="1" or s=="2" or s=="3" or s=="4" or s=="5" /*
*/ or s=="6" or s=="7"
endfunction
private function token takes string input, string t returns boolean
local integer i = StringLength(t)
return SubString(input, 0, i) == t and (isDelim(SubString(input, i, i+1)) or i==StringLength(input))
endfunction
private function op takes string input, string t returns boolean
return startsWith(input, t)
endfunction
private function hash takes string s returns integer
return StringHash(s) / 3183177 + 641
endfunction
private function hex2int takes string h returns integer
local integer i = 0
local integer sum = 0
local integer len = StringLength(h)
loop
exitwhen i >= len
set sum = sum*16 + hex[hash(SubString(h, i, i+1))]
set i = i +1
endloop
return sum
endfunction
private function oct2int takes string h returns integer
local integer i = 0
local integer sum = 0
local integer len = StringLength(h)
loop
exitwhen i >= len
set sum = sum*8 + hex[hash(SubString(h, i, i+1))]
set i = i +1
endloop
return sum
endfunction
public struct Lexer
private string input
private integer pos
private integer length
static method create takes string input returns thistype
local thistype this = allocate()
set .pos = 0
set .input = input
set .length = StringLength(.input)
return this
endmethod
private method slurpWhitespace takes nothing returns nothing
local string c = SubString(.input, .pos, .pos+1)
loop
exitwhen c != " " and c != "\t"
set .pos = .pos +1
set c = SubString(.input, .pos, .pos+1)
endloop
endmethod
private method parseIdent takes nothing returns Token
local integer p = .pos
local string c = SubString(.input, p, p +1)
local Token r
loop
exitwhen isDelim(c) or p >=.length
set p = p +1
set c = SubString(.input, p, p+1)
endloop
set r = Token.create(IDENT, SubString(.input, .pos, p))
set .pos = p
return r
endmethod
private method parseDotFloat takes nothing returns Token
local integer start = .pos
loop
exitwhen not isDigit(SubString(.input, .pos, .pos+1))
set .pos = .pos +1
endloop
return Token.create(REAL, "0." + SubString(.input, start, .pos))
endmethod
private method parseHex takes nothing returns Token
local integer start = .pos
loop
exitwhen not isHex(SubString(.input, .pos, .pos+1))
set .pos = .pos +1
endloop
return Token.create(INTEGER, I2S(hex2int(SubString(.input, start, .pos))))
endmethod
private method parseNumber takes nothing returns Token
local integer start = .pos
local boolean isReal = false
loop
exitwhen not isDigit(SubString(.input, .pos, .pos+1))
set .pos = .pos +1
endloop
if SubString(.input, .pos, .pos+1) == "." then
set isReal = true
set .pos = .pos +1
loop
exitwhen not isDigit(SubString(.input, .pos, .pos+1))
set .pos = .pos +1
endloop
endif
if isReal then
return Token.create(REAL, SubString(.input, start, .pos))
else
return Token.create(INTEGER, SubString(.input, start, .pos))
endif
endmethod
private method parseOct takes nothing returns Token
local integer start = .pos
local boolean isReal = false
loop
exitwhen not isDigit(SubString(.input, .pos, .pos+1))
set .pos = .pos +1
endloop
if SubString(.input, .pos, .pos+1) == "." then
set isReal = true
set .pos = .pos +1
loop
exitwhen not isDigit(SubString(.input, .pos, .pos+1))
set .pos = .pos +1
endloop
endif
if isReal then
return Token.create(REAL, SubString(.input, start, .pos))
else
// we may have parsed non-oct digits. for now we'll just ignore this possibility
return Token.create(INTEGER, I2S(oct2int(SubString(.input, start, .pos))))
endif
endmethod
private method parseRawcode takes nothing returns Token
local integer start = .pos
local string c
local Token t
loop
set c = SubString(.input, .pos, .pos +1)
if c == "\\" then
set .pos = .pos +1
elseif c == "'" then
exitwhen true
elseif .pos >= .length then
call error("Unclosed rawcode")
endif
set .pos = .pos +1
endloop
set t = Token.create(RAWCODE, SubString(.input, start, .pos))
set .pos = .pos +1
return t
endmethod
private method parseString takes nothing returns Token
local integer start = .pos
local string c
local Token t
loop
set c = SubString(.input, .pos, .pos +1)
if c == "\\" then
set .pos = .pos +1
elseif c == "\"" then
exitwhen true
elseif .pos >= .length then
call error("Unclosed string")
endif
set .pos = .pos +1
endloop
set t = Token.create(STRING, SubString(.input, start, .pos))
set .pos = .pos +1
return t
endmethod
method next takes nothing returns Token
local string c
local string cur
call .slurpWhitespace()
set c = SubString(.input, .pos, .pos +1)
set cur = SubString(.input, .pos, .length)
// TODO: comments
if c == "\r" or c == "\n" then
loop
exitwhen c != "\r" and c!= "\n" and c!=" " and c!="\t"
set .pos = .pos +1
set c = SubString(.input, .pos, .pos+1)
endloop
return Token.create(NL, "")
elseif c == "\"" then
set .pos = .pos +1
return .parseString()
elseif c == "'" then
set .pos = .pos +1
return .parseRawcode()
elseif token(cur, "call") then
set .pos = .pos +4
return Token.create(CALL, "")
elseif token(cur, "set") then
set .pos = .pos +3
return Token.create(SET, "")
elseif token(cur, "return") then
set .pos = .pos +6
return Token.create(RETURN, "")
elseif token(cur, "loop") then
set .pos = .pos +4
return Token.create(LOOP, "")
elseif token(cur, "exitwhen") then
set .pos = .pos +8
return Token.create(EXITWHEN, "")
elseif token(cur, "endloop") then
set .pos = .pos +7
return Token.create(ENDLOOP, "")
elseif token(cur, "if") then
set .pos = .pos +2
return Token.create(IF, "")
elseif token(cur, "then") then
set .pos = .pos +4
return Token.create(THEN, "")
elseif token(cur, "elseif") then
set .pos = .pos +6
return Token.create(ELSEIF, "")
elseif token(cur, "else") then
set .pos = .pos +4
return Token.create(ELSE, "")
elseif token(cur, "endif") then
set .pos = .pos +5
return Token.create(ENDIF, "")
elseif token(cur, "function") then
set .pos = .pos +8
return Token.create(FUNCTION, "")
elseif token(cur, "takes") then
set .pos = .pos +5
return Token.create(TAKES, "")
elseif token(cur, "returns") then
set .pos = .pos +7
return Token.create(RETURNS, "")
elseif token(cur, "nothing") then
set .pos = .pos +7
return Token.create(NOTHING, "")
elseif token(cur, "endfunction") then
set .pos = .pos +11
return Token.create(ENDFUNCTION, "")
elseif token(cur, "constant") then
set .pos = .pos +8
return Token.create(CONSTANT, "")
elseif token(cur, "native") then
set .pos = .pos +6
return Token.create(NATIVE, "")
elseif token(cur, "globals") then
set .pos = .pos +7
return Token.create(GLOBALS, "")
elseif token(cur, "endglobals") then
set .pos = .pos +10
return Token.create(ENDGLOBALS, "")
elseif token(cur, "type") then
set .pos = .pos +4
return Token.create(TYPE, "")
elseif token(cur, "extends") then
set .pos = .pos +7
return Token.create(EXTENDS, "")
elseif token(cur, "local") then
set .pos = .pos +5
return Token.create(LOCAL, "")
elseif token(cur, "array") then
set .pos = .pos +5
return Token.create(ARRAY, "")
elseif token(cur, "null") then
set .pos = .pos +4
return Token.create(NULL, "")
elseif token(cur, "true") then
set .pos = .pos +4
return Token.create(TrueTok, "")
elseif token(cur, "false") then
set .pos = .pos +5
return Token.create(FalseTok, "")
elseif token(cur, "and") then
set .pos = .pos +3
return Token.create(AND, "")
elseif token(cur, "or") then
set .pos = .pos +2
return Token.create(OR, "")
elseif token(cur, "not") then
set .pos = .pos +3
return Token.create(NOT, "")
elseif op(cur, "<=") then
set .pos = .pos +2
return Token.create(LEQ, "")