-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval.q
1734 lines (1642 loc) · 41.7 KB
/
eval.q
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
// =======================================================
// MOD ENTRY POINT
// =======================================================
script eval_startup
//LoadPak \{'MODS/eval.pak'}
decompress_eval
decompress_help
decompress_chars
FGH3Config sect='Mods' 'EvalVerbose' #"0x1ca1ff20"=($evalverbose)
change evalverbose = <value>
printf \{'Running autoexec line'}
FGH3Config \{sect='Mods' 'AutoExec' #"0x1ca1ff20"="printf 'no autoexec specified!!!!!'"}
eval <value> // evalu8 for fun
wait \{2 gameframes}
spawnscriptlater key_events
endscript
eval_mod_info = {
name = 'eval'
desc = 'QbScript Console and Interpreter, within QbScript, bundled with ConVars'
author = 'donnaken15'
version = '24.01'
params = [ // for user config, values stored in config.qb
// non unique named mods have the filename prefixed on vars
{ name = 'console_pause' default = 1 type = bool
ini = [ 'Mods' 'ConsolePause' ]
desc = 'Pause game when the console is active.' }
{ name = 'evalverbose' default = 0 type = bool
ini = [ 'Mods' 'EvalVerbose' ]
desc = 'Print the ongoing process of parsing and executing script text.' }
]
}
// =======================================================
// convars
// =======================================================
// todo?: autocomplete lol // i need help
manual = {}
script decompress_help // desperate
change manual = {
exit = {
'Exit the engine.' name = 'exit'
}
quit = {
'Exit the engine.' name = 'quit'
}
help = {
'Find help about a convar/concommand.'
params = [ { 'script' } ]
name = 'help'
}
give = {
'Give item to player.'
params = [
{ item name = #"0x00000000" }
{ player name = player }
]
name = 'give'
}
fps = {
'Frame rate limiter.'
//params = [ { fps } ]
name = 'fps'
cvar = fps_max
}
sv_speed = {
'Change speed of the song.'
params = [ { speed } ]
name = 'sv_speed'
cvar = current_speedfactor
}
alias = {
'Alias a command, or script string.'
params = [
{ 'name' }
{ 'script' }
]
name = 'give'
}
}
endscript
quit=$ExitGameConfirmed
exit=$ExitGameConfirmed
script help
if NOT GotParam \{#"0x00000000"}
help \{help}
return
endif
if NOT ScriptExists <#"0x00000000">
printf \{'Script does not exist.'}
return
endif
if NOT StructureContains structure=$manual <#"0x00000000">
printf \{'Script does not have information.'}
return
endif
info = ($manual.<#"0x00000000">)
if StructureContains \{structure=info name}
name = (<info>.name)
else
name = <#"0x00000000">
endif
if StructureContains \{structure=info cvar}
formattext textname = helptext "%s = (%v)" s = (<info>.name) v = (<info>.cvar) // wtf, old syntax moment
else
formattext textname = helptext "%n" n = <name>
params = (<info>.params)
GetArraySize <params>
if (<array_size> > 0)
i = 0
begin
param = (<params>[<i>])
if StructureContains \{structure=param name}
if NOT (<param>.name = #"0x00000000")
formattext textname = helptext "%s %p =" s = <helptext> p = (<param>.name)
endif
endif
formattext textname = helptext "%s <%p>" s = <helptext> p = (<param>.#"0x00000000")
Increment \{i}
repeat <array_size>
endif
endif
printf "%h" h = <helptext>
printf " - %s" s = (<info>.#"0x00000000")
endscript
script echo
if GotParam \{#"0x00000000"}
printf "%a" a = <#"0x00000000">
endif
endscript
// doskey freaking
aliases = []
script alias
if not GotParam \{name}
goto #" alias list"
endif
if not GotParam \{#"0xe37e78c5"}
goto #" alias list"
endif
// no functions can suffice to remove or overwrite an existing item,
// have fun leaking memory by creating an alias under the same name over and over, or something
AddArrayElement array = ($aliases) element = { name = <name> command = <#"0xe37e78c5"> }
change aliases = <array>
endscript
script #" alias list"
printf 'Current alias commands:'
array = ($aliases)
GetArraySize \{array}
if (<array_size> = 0)
return
endif
i = 0
begin
printf '%s : %c' s = (<array>[<i>].name) c = (<array>[<i>].command)
Increment \{i}
repeat <array_size>
endscript
// console command like
script give \{player = 1}
if NOT GotParam \{#"0x00000000"}
help \{give}
return
endif
if (<player> = 2)
player_status = player2_status
else
player_status = player1_status
endif
switch <#"0x00000000">
case health
//begin
// IncreaseCrowd player_status=<player_status>
//repeat 10
Change StructureName = <player_status> current_health = ($<player_status>.current_health + 0.5)
if ($<player_status>.current_health > 2.0)
Change StructureName = <player_status> current_health = 2.0
endif
return
endswitch
if NOT ($game_mode = p2_battle)
switch <#"0x00000000">
case starpower
increase_star_power amount = 50.0 player_status = <player_status>
return
endswitch
else
params = { player_status = <player_status> battle_text = 1 }
switch <#"0x00000000">
case starpower
battlemode_ready { battle_gem = 8 <params> }
return
case lightning
battlemode_ready { battle_gem = 0 <params> }
return
case difficulty
battlemode_ready { battle_gem = 1 <params> }
return
case double
battlemode_ready { battle_gem = 2 <params> }
return
case steal
battlemode_ready { battle_gem = 3 <params> }
return
case lefty
battlemode_ready { battle_gem = 4 <params> }
return
case string
battlemode_ready { battle_gem = 5 <params> }
return
case whammy
battlemode_ready { battle_gem = 6 <params> }
return
case deth
battlemode_ready { battle_gem = 7 <params> }
return
endswitch
endif
printf 'unknown item: %i' i = <#"0x00000000">
endscript
script fps
if NOT GotParam \{#"0x00000000"}
help \{fps}
return
endif
change fps_max = <#"0x00000000">
endscript
script sv_speed
if NOT GotParam \{#"0x00000000"}
help \{sv_speed}
return
endif
if NOT ($toggle_console)
change current_speedfactor = <#"0x00000000">
update_slomo
else
change old_speed = <#"0x00000000">
endif
endscript
/* NOT WORKING WITH 2 PLAYER
script sv_mode \{players = 0}
if NOT GotParam \{#"0x00000000"}
help \{sv_mode}
return
endif
restore_start_key_binding
switch <#"0x00000000">
case 1
#"0x00000000" = training
//case 2 // CRASHING AGAIN
// #"0x00000000" = p2_coop
case 3
#"0x00000000" = p2_faceoff
case 4
#"0x00000000" = p2_pro_faceoff
case p1_career
case training
//case p2_coop
//case p2_career
case p2_faceoff
case p2_pro_faceoff
case p1_quickplay
case p2_battle
EmptyScript
case 0
default
#"0x00000000" = p1_quickplay
endswitch
printstruct <...>
change game_mode = <#"0x00000000">
got_players = 0
if NOT (<players> < 1 & <players> > 2)
got_players = 1
endif
if (<got_players> = 0)
switch $game_mode
//case p2_coop
//case p2_career
case p2_pro_faceoff
case p2_faceoff
case p2_battle
players = 2
case training
case p1_quickplay
case p1_career
default
players = 1
endswitch
endif
change current_num_players = (<players> + 1)
old_speed = ($old_speed)
destroy_keyboard_input
change old_speed = <old_speed>
change \{toggle_console = 0}
restart_song
endscript
*///
script xy \{x=0 y=0}
return pair = (((1.0, 0.0) * <x>) + ((0.0, 1.0) * <y>))
endscript
script #"draw base" \{x=640 y=360 just=[center center] parent=root_window alpha=1 scale=1.0}
if GotParam \{w}
if GotParam \{h}
xy x = <w> y = <h>
endif
endif
if GotParam \{pair}
dims = <pair>
RemoveComponent \{pair}
endif
if GotParam \{x}
if GotParam \{y}
xy x = <x> y = <y>
endif
endif
RemoveComponent \{x}
RemoveComponent \{y}
if NOT IsArray \{just}
justt = <just>
RemoveComponent \{just}
just = [center center] // if just is only a qbkey, use it as the horizontal param
SetArrayElement arrayname=just index=0 newvalue=<justt>
RemoveComponent \{justt}
endif
CreateScreenElement {
type = <type>
font = <font>
pos = <pair>
just = <just>
text = <text>
id = <id>
parent = <parent>
dims = <dims>
scale = <scale>
alpha = <alpha>
texture = <texture>
material = <material>
z_priority = <z>
rot_angle = <angle>
}
printf 'The id for this text element is %s' s = <id>
endscript
script drawtext \{font=fontgrid_title_gh3 text='Hello, world!' id=mytext}
#"draw base" type = textelement <...>
endscript
script drawsprite \{id=mysprite}
if NOT GotParam \{texture}
if NOT GotParam \{material}
texture = sprite_missing
endif
endif
#"draw base" type = spriteelement <...>
endscript
script killelement
if ScreenElementExists id = <id>
DestroyScreenElement <...>
endif
if ScreenElementExists id = <#"0x00000000">
DestroyScreenElement id = <#"0x00000000"> <...>
endif
endscript
// =======================================================
// console
// =======================================================
// fun todo: arrow keys to navigate in the current line, and command history
toggle_console = 0
might_hold_shift = 0
console_pause = 1
script create_keyboard_input
//EnableInput OFF ($player1_status.controller)
CreateScreenElement {
parent = root_window
id = console_text
text = ""
type = textblockelement // GAME CRASHES IF TEXT IS TOO LONG
font = text_a1
scale = 0.7
rgba = [ 255 255 255 255 ]
just = [ left bottom ]
internal_just = [ left bottom ]
pos = (72.0, 718.0)
dims = (1200.0, 620.0)
z_priority = 200
}
update_console_input
if ($console_pause = 1)
change old_speed = ($current_speedfactor)
change current_speedfactor = 0.0
update_slomo
endif
spawnscriptnow \{check_user_input}
spawnscriptnow \{blink_cursor_loop}
endscript
script destroy_keyboard_input
//EnableInput ($player1_status.controller)
if ScreenElementExists \{id = console_text}
DestroyScreenElement \{id = console_text}
endif
KillSpawnedScript \{name = check_user_input}
KillSpawnedScript \{name = blink_cursor_loop}
change \{console_input = ""}
if ($console_pause = 1)
change current_speedfactor = ($old_speed)
update_slomo
change old_speed = -1.0
endif
endscript
//console_history = ""
script update_console_input
if NOT ScreenElementExists id = console_text
return
endif
if ($blink_cursor = 1)
cursor = "_"
else
cursor = " "
endif
formattext textname = con ">%t%c" t = ($console_input) c = <cursor>
SetScreenElementProps id = console_text text = <con>
endscript
script clear
//change \{console_history = ""}
//update_console_input
endscript
console_cursor = 0
blink_cursor = 0
script blink_cursor_loop
begin
update_console_input
change blink_cursor = (1 - $blink_cursor)
Wait \{0.1 seconds ignoreslomo}
repeat
endscript
script check_user_input
capslock = 0
shift = 0
begin
WinPortSioGetControlPress \{deviceNum = 3}
if NOT (<controlNum> = -1)
if NOT ($last_key = <controlNum>)
if ord <controlNum>
if IsCapsLockOn
capslock = 1
else
capslock = 0
endif
if ($might_hold_shift = 1)
shift = 1
else
shift = 0
endif
shift = (<shift> - <capslock>)
if (<shift> = 0)
GetLowerCaseString <char>
char = <lowercasestring>
FormatText checksumname = id "%a" a = <char>
if StructureContains structure=$key_chars_lower <id>
char = ($key_chars_lower.<id>)
endif
endif
change console_cursor = ($console_cursor + 1)
change console_input = ($console_input + <char>)
update_console_input
else
//if (<controlNum> = 219) // Back
//
//endif
if (<controlNum> = 229) // Delete
trim ($console_input)
change console_input = <trim>
endif
if (<controlNum> = 293) // Enter
output_log_text "%h" h = ($console_input)
//change console_history = ($console_history + "\n" + $console_input)
spawnscriptnow eval params = { ($console_input) ignore_slomo = 1 accept_aliases = 1 warn_nonexistent = 1 }
change \{console_input = ""}
endif
update_console_input
endif
endif
endif
wait \{1 gameframe}
repeat
endscript
script ord // lol
if (<#"0x00000000"> = -1)
return \{false}
endif
formattext checksumname = id "%a" a = <#"0x00000000">
if StructureContains structure=$key_chars <id>
return true char = ($key_chars.<id>)
endif
return \{false}
endscript
script trim \{c = 1}
StringToCharArray string = <#"0x00000000">
getarraysize \{char_array}
if (<array_size> > 1)
AddParams \{ trim = "" i = 0 } // stupid
begin
trim = (<trim> + <char_array>[<i>])
Increment \{i}
repeat (<array_size> - <c>)
return trim = <trim>
elseif (<array_size> = 1)
return \{trim = ""}
endif
endscript
console_input = ""
key_chars_lower = {}
key_chars = {}
script decompress_chars // desperate
change key_chars = {
#"304" = "Q"
#"331" = "W"
#"232" = "E"
#"305" = "R"
#"322" = "T"
#"341" = "Y"
#"324" = "U"
#"256" = "I"
#"295" = "O"
#"297" = "P"
#"210" = "A"
#"313" = "S"
#"227" = "D"
#"236" = "F"
#"252" = "G"
#"254" = "H"
#"258" = "J"
#"259" = "K"
#"262" = "L"
#"343" = "Z"
#"340" = "X"
#"221" = "C"
#"328" = "V"
#"218" = "B"
#"277" = "N"
#"269" = "M"
#"201" = "!"
#"202" = "@"
#"203" = "#"
#"204" = "$"
#"205" = "%"
#"206" = "^"
#"207" = "&"
#"208" = "*"
#"209" = "("
#"200" = ")"
#"273" = "_"
#"234" = "+"
#"263" = "{"
#"306" = "}"
#"213" = "+"
#"225" = ","
#"299" = "."
#"316" = "?"
#"318" = " "
#"345" = ";"
#"214" = "\""
#"220" = "\\"
}
change key_chars_lower = {
#"0xF89D5196" = "'" // "
#"0xD6295C17" = "-" // _
#"0x8141E932" = "=" // +
#"0xEA2AB8C6" = "[" // {
#"0x03491DF3" = "]" // }
#"0x6194002C" = "1" // !
#"0x5B2151E2" = "2" // @
#"0x8F9A6100" = "3" // #
#"0x11FEF4A3" = "4" // $
#"0x66F9C435" = "5" // %
#"0xA12E6C81" = "6" // ^
#"0xFFF0958F" = "7" // &
#"0xF646D9A4" = "8" // *
#"0x1848B888" = "9" // (
#"0x6F4F881E" = "0" // )
}
endscript
script key_events
begin
//ProfilingStart
//if ($toggle_console = 0)
WinPortSioGetControlPress \{deviceNum = 3 actionNum = 0} //$player1_device // keyboard is always 3
if NOT (<controlNum> = -1)
if (<controlNum> = 323) // Tab
// emulator moment
if (($console_pause = 1 & $toggle_console = 0) | $console_pause = 0)
if ($hold_tab = 0)
change old_speed = ($current_speedfactor)
change current_speedfactor = ($old_speed * $fastforward)
update_slomo
change \{hold_tab = 1}
endif
endif
endif
if (<controlNum> = 253) // ~
if NOT ($last_key = <controlNum>)
toggle = toggle_console
change globalname = <toggle> newvalue = (1 - $<toggle>)
if ($toggle_console)
//printf 'opened console'
create_keyboard_input
else
destroy_keyboard_input
endif
endif
endif
if (<controlNum> = 267 | <controlNum> = 311) // l/rshift
if ($might_hold_shift = 0)
change might_hold_shift = 1
endif
endif
else
if ($might_hold_shift = 1)
change might_hold_shift = 0
endif
endif
if NOT (<controlNum> = 323)
if ($hold_tab = 1)
change current_speedfactor = ($old_speed)
update_slomo
change \{hold_tab = 0}
endif
endif
change last_key = <controlNum>
//ProfilingEnd <...> 'test' loop ____profiling_interval = 800
Wait \{1 gameframe}
repeat
endscript
last_key = 0
old_speed = -1.0
hold_tab = 0
fastforward = 2.0
// =======================================================
// main
// =======================================================
/**///
evalverbose = 0
script eval \{'printf \'no command specified\''}
printf "] %l" l = <#"0x00000000">
if NOT evaltokenizer <#"0x00000000">
printf \{'tokenizer did not return successfully'}
return \{false}
endif
//printstruct <tokens>
//Block
//return
array = [] // nodes
getarraysize \{tokens}
i = 0
begin
token = (<tokens>[<i>])
switch (<token>.type)
case bytecode
switch (<token>.value)
case 1 //newline
if NOT evalparseline <tokens> token_count = <token_count> i = (<i> + 1)
printf \{'line parser did not return successfully'}
return \{false}
endif
//printstruct <node>
endswitch
endswitch
AddArrayElement array = <array> element = <node>
Increment \{i}
if (<i> >= <token_count>)
break
endif
repeat
RemoveComponent \{tokens}
script_locals = {}
script_lastresult = #" invalid "
// node values:
// start_type, line_type, left_op, right_op
getarraysize \{array}
i = 0
begin
node = (<array>[<i>])
//printstruct <node>
switch (<node>.start_type)
case name
switch (<node>.line_type)
case assign
AddParam {
structure_name = script_locals
name = (<node>.left_op) value = (<node>.right_op)
}
case call
evalrun {
(<node>.left_op) params = (<node>.right_op)
ignore_slomo = <ignore_slomo>
accept_aliases = <accept_aliases>
warn_nonexistent = <warn_nonexistent>
}
script_locals = { <script_locals> <returned> }
script_lastresult = <returned>
endswitch
case result
EmptyScript
endswitch
Increment \{i}
repeat <array_size>
//printstruct <script_locals>
//if NOT (<script_lastresult> = #" invalid ")
// printstruct <script_locals>
//endif
//Block
return {
true
locals = <script_locals>
result = <script_lastresult>
}
endscript
script evalrun
// isolate parameters returned from scripts being called
if (<warn_nonexistent> = 1)
if SymbolIsCFunc <#"0x00000000">
elseif ScriptExists <#"0x00000000">
else
printf "%w%s" w = 'Warning, cannot find the function to be called: ' s = <#"0x00000000">
endif
endif
RemoveComponent \{warn_nonexistent}
if NOT GotParam \{elevated}
is_alias = 0
if (<accept_aliases> = 1)
array = ($aliases)
GetArraySize \{array}
if (<array_size> > 0)
i = (<array_size> -1)
begin
alias = (<array>[<i>])
FormatText checksumname = name "%a" a = (<alias>.name)
if (<name> = <#"0x00000000">)
alias = (<alias>.command)
is_alias = 1
break
endif
i = (<i> -1)
repeat <array_size>
endif
if (<is_alias> = 1)
eval <alias> ignore_slomo = <ignore_slomo> accept_aliases = <accept_aliases>
return returned = <result>
endif
endif
if NOT GotParam \{params}
params = {}
endif
ExtendCrc <#"0x00000000"> '__' out = ffs
if (<ignore_slomo> = 1 & <ffs> = Wait__)
// wait by default factors in slomo multiplier, so ignore it for console
params = { <params> ignoreslomo }
endif
RemoveComponent \{ffs}
evalrun elevated #" args " = <params> #" script to run " = <#"0x00000000">
return returned = <returned>
else
RemoveFlag \{elevated}
if NOT ChecksumEquals a = <#" script to run "> b = #"printstruct" // WTFFFFFFFFF
<#" script to run "> <#" args ">
else
printstruct <#" args ">
endif
RemoveComponent \{#" script to run "}
RemoveComponent \{#" args "}
return returned = <...>
endif
endscript
script evalparseglobal
//printstruct <...>
if (<i> + 1 >= <token_count>)
printf \{'parser prematurely ended when global pointer wasn\'t followed by a name!!!!!!'}
return \{false}
endif
next_token = (<#"0x00000000">[(<i> + 1)])
printtoken t = <next_token> i = <i>
//printstruct <next_token>
if NOT (<next_token>.type = name)
printf \{'parser prematurely ended when global pointer wasn\'t followed by a name!!!!!!'}
return \{false}
endif
//printstruct true value = (<next_token>.value) i = (<i> + 1)
return true value = (<next_token>.value) i = (<i> + 1)
endscript
script evalparseexpr \{depth = 0 debug = $evalverbose}
expression_value = 0
operator = 0
operation = 0
mode = 0
printf 'expression evaluating ('
begin
// don't know what the order of operations in qscript is
// but i can somehow imagine if comparison isolates
// the two values around it, somehow this random scenario came to mind
// if without parentheses, this (4+5=5) could be executed as (4+(5=5))
skip = 0
token = (<#"0x00000000">[<i>])
if (<token>.type = bytecode)
operator = (<token>.value)
if NOT (<operator> >= 7 & <operator> <= 15)
if NOT (<operator> = 75)
printf 'invalid or unimplemented bytecode in expression: %a <%b>, skipping' a = (<token>.literal) b = (<token>.value)
skip = 1
endif
endif
else
operator = 0
endif
if (<skip> = 0)
printtoken t = <token> i = <i> indent = (<depth> + 1) depth = <depth>
switch (<mode>)
// 0 - get lvalue (first)
// 1 - get operator
// 2 - get rvalue, apply operator (subsequent values)
case 0
case 2
if (<token>.type = bytecode)
switch (<token>.value)
case 15
if (<mode> = 0)
printf \{'warning: empty expression'}
endif
break
case 14 // (
evalparseexpr <#"0x00000000"> token_count = <token_count> i = (<i> + 1) depth = (<depth> + 1)
i = <t>
case 75 // $
evalparseglobal <#"0x00000000"> token_count = <token_count> i = <i>
value = ($<value>)
//printstruct <...>
default
printf 'invalid operator (mode 0): %a' a = (<token>.literal)
return false
endswitch
else
value = (<token>.value)
endif
if (<mode> = 0)
expression_value = <value>
else
switch <operation>
case 7
expression_value = (<expression_value> = <value>)
case 11
expression_value = (<expression_value> + <value>)
case 10
expression_value = (<expression_value> - <value>)
case 13
expression_value = (<expression_value> * <value>)
case 12
expression_value = (<expression_value> / <value>)
case 8
// uhhhh, will need to put in another expression
expression_value = (<expression_value>.<value>)
default
//case 9
// uhhhhh
printf 'oh no (%e)' e = <operation>
return false
endswitch
endif
printf 'current value = %a' a = <expression_value>
mode = 1
case 1
switch <operator>
case 7 // =(=)
case 8 // .
case 9 // ,
case 11 // +
case 10 // -
case 13 // *
case 12 // /
operation = <operator>
case 15
break
default
printf 'invalid operator (mode 1): %a' a = (<operator>)
return false
endswitch
mode = 2
endswitch
endif
Increment \{i}
repeat
printf ')'
//printstruct <...>
return true value = <expression_value> t = (<i>)
endscript
script evalparsestruct \{depth = 0 debug = $evalverbose}
AddParams \{struct = {} brackets = 0}
token = (<#"0x00000000">[<i>])
if (<debug>)
printf 'struct assembling {'
endif
if (<token>.type = bytecode & <token>.value = 3)
brackets = 1
if (<debug>)
printf 'got brackets'
endif
Increment \{i}
endif
;passthru = 0
type = none
begin
skip = 0
target = #"0x00000000"
token = (<#"0x00000000">[<i>])
printtoken t = <token> i = <i> indent = (<depth> + 1) depth = <depth>
switch (<token>.type)
case name
//printf '%t' t = (<token>.value)
next_token = (<#"0x00000000">[(<i> + 1)])
// this feels like a tumor i'm writing
if (<i> + 1 < <token_count> & <next_token>.type = bytecode & <next_token>.value = 7)
if NOT (<i> + 2 < <token_count>)
printf 'parser prematurely ended when variable assignment wasn\'t followed by a value!!!!!!'
break
endif
next_token = (<#"0x00000000">[(<i> + 2)])
//j = (<i> + 3)
//pad <j> count = 3 pad = ' '
//printf '%i: token: [%v] <%t>' i = <pad> t = (<next_token>.type) v = (<next_token>.value)
switch (<next_token>.type)
case bytecode
switch (<next_token>.value)
//case 14
case 3
// type = struct
// target = (<token>.value)
// value = (<next_token>.value)
// i = (<i> + 3)
evalparsestruct <#"0x00000000"> token_count = <token_count> i = (<i> + 2) depth = (<depth> + 1)
i = <t>
target = (<token>.value)
case 75
evalparseglobal <#"0x00000000"> token_count = <token_count> i = (<i> + 2)
target = (<token>.value)