-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.h
2082 lines (1918 loc) · 76.9 KB
/
code.h
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
#define CMDSRC "/tau/src/cmd"
#define CMDDIR "/tau/cmd"
#define CODEHEAD "code.h"
#define CODEHD CODEHEAD
#define IF if
#define If IF
#define IFEQ(var, num) IF (var EQ num)
#define IFLT(var, num) IF (var LT num)
#define IFLQ(var, num) IF (var LQ num)
#define IFGT(var, num) IF (var GT num)
#define IFGQ(var, num) IF (var GQ num)
#define IFNQ(var, num) IF (var NQ num)
#define IFEQOR2(var, n1, n2) IF (var EQ n1 OR var EQ n2)
#define IFEQAND2(var, n1, n2) IF (var EQ n1 AND var EQ n2)
#define IFEQOR3(var, n1, n2, n3) IF (var EQ n1 OR var EQ n2 OR var EQ n3)
#define IFEQAND3(var, n1, n2, n3) IF (var EQ n1 AND var EQ n2 AND var EQ n3)
#define IFEQOR4(var, n1, n2, n3, n4) IF (var EQ n1 OR var EQ n2 OR var EQ n3 OR var EQ n4)
#define IFEQAND4(var, n1, n2, n3, n4) IF (var EQ n1 AND var EQ n2 AND var EQ n3 AND var EQ n4)
#define IFEQ1(var, n1) IFEQ(var, n1)
#define IFEQ2(var, n1, n2) IFEQOR2(var, n1, n2)
#define IFEQ3(var, n1, n2, n3) IFEQOR3(var, n1, n2, n3)
#define IFEQ4(var, n1, n2, n3, n4) IFEQOR4(var, n1, n2, n3, n4)
#define IFEQ5(var, n1, n2, n3, n4, n5) IFEQOR5(var, n1, n2, n3, n4, n5)
#define EF else if
#define ELSEIF EF
#define ELIF ELSEIF
#define ElseIf ELSEIF
#define EFEQ(var, num) EF (var EQ num)
#define EFLT(var, num) EF (var LT num)
#define EFLQ(var, num) EF (var LQ num)
#define EFGT(var, num) EF (var GT num)
#define EFGQ(var, num) EF (var GQ num)
#define EFNQ(var, num) EF (var NQ num)
#define EFEQOR2(var, n1, n2) EF (var EQ n1 OR var EQ n2)
#define EFEQAND2(var, n1, n2) EF (var EQ n1 AND var EQ n2)
#define EFEQOR3(var, n1, n2, n3) EF (var EQ n1 OR var EQ n2 OR var EQ n3)
#define EFEQAND3(var, n1, n2, n3) EF (var EQ n1 AND var EQ n2 AND var EQ n3)
#define EFEQOR4(var, n1, n2, n3, n4) EF (var EQ n1 OR var EQ n2 OR var EQ n3 OR var EQ n4)
#define EFEQAND4(var, n1, n2, n3, n4) EF (var EQ n1 AND var EQ n2 AND var EQ n3 AND var EQ n4)
#define EFEQOR5(var, n1, n2, n3, n4, n5) EF (var EQ n1 OR var EQ n2 OR var EQ n3 OR var EQ n4 OR var EQ n5)
#define EFEQAND5(var, n1, n2, n3, n4, n5) EF (var EQ n1 AND var EQ n2 AND var EQ n3 AND var EQ n4 OR var EQ n5)
#define EFEQ1(var, n1) EFEQ(var, n1)
#define EFEQ2(var, n1, n2) EFEQOR2(var, n1, n2)
#define EFEQ3(var, n1, n2, n3) EFEQOR3(var, n1, n2, n3)
#define EFEQ4(var, n1, n2, n3, n4) EFEQOR4(var, n1, n2, n3, n4)
#define EFEQ5(var, n1, n2, n3, n4, n5) EFEQOR5(var, n1, n2, n3, n4, n5)
#define EL else
#define ELSE EL
#define Else ELSE
#define DO do
#define Do DO
#define WI while
#define WHILE WI
#define While WHILE
#define WHILELOOP WHILE
#define LOOP WHILE (1)
#define LP LOOP
#define WhileLoop WHILE
#define WINQEOF(var) WI (var NQEOF)
#define WIEQ(var, num) WI (var EQ num)
#define WILT(var, num) WI (var LT num)
#define WILQ(var, num) WI (var LQ num)
#define WIGT(var, num) WI (var GT num)
#define WIGQ(var, num) WI (var GQ num)
#define WINQ(var, opt) WI (var NQ opt)
#define WINQ2(var, o1, o2) WI (var NQ o1 AND var NQ o2)
#define WINQ3(var, o1, o2, o3) WI (var NQ o1 AND var NQ o2 AND var NQ o3)
#define WINQ4(var, o1, o2, o3, o4) WI (var NQ o1 AND var NQ o2 AND var NQ o3 AND var NQ o4)
//#define INWINCEQ(var, num) IN var = -1; WI (INC var EQ num)
#define INWI1(var, val) IN var = val; WI (1)
#define INWINCLT(var, num) IN var = -1; WI (INC var LT num)
#define INWINCLQ(var, num) IN var = -1; WI (INC var LQ num)
#define IN0WINCLT(var, num) IN var = 0; WI (INC var LT num)
#define IN0WINCLQ(var, num) IN var = 0; WI (INC var LQ num)
#define INWDECGT(lim, var, num) IN var = lim; WI (DEC var GT num)
#define INWDECGQ(lim, var, num) IN var = lim; WI (DEC var GQ num)
//#define INWINCNQ(var, num) IN var = -1; WI (INC var NQ num)
#define INWINCNQNUL(var, str) IN var = -1; WI (str[INC var] NQNUL)
#define INWINCELNQ(var, str, elch) IN var = -1; WI (str[INC var] NQNUL AND str[var] NQ elch)
#define INWINC(var, str) INWINCNQNUL(var, str)
#define FOR for
#define For FOR
#define FORLOOP FOR
#define ForLoop FOR
#define IN int
#define UIN unsigned IN
#define SIN signed IN
#define UNSIGNEDINT UIN
#define UNSIGNEDINTEGER UIN
#define UNSIGNEDINTEGERNUMBER UIN
#define SIGNEDINTEGERNUMBER IN
#define SIGNEDINTEGER IN
//#define SIN SIGNEDINTEGERNUMBER
//#define SIN SINE <-- no, that is sin(). SIN can mean Signed Integer Number
// define SIN as SINE over SIGNEDINTEGERNUMBER <-- no, but this should be configurable
//#define INT IN <-- conflicts with INT(name, value) definition.. fix! IN() LN() etc also
#define INTEGER IN
#define INTEGERNUMBER INTEGER
#define IntegerNumber INTEGERNUMBER
#define INP IN *
#define LONGTYPE long long
#define LONGLIMIT LLONG_MAX
#define LN LONGTYPE
#define LL LONGLIMIT
#define LLDIGITS 19 // 18 whole digits actually
typedef struct { LN numb; LN frac; LN diff; } LF;
#define LFP LF *
#define ULN unsigned LN
#define SLN signed LN
#define LONG LN
#define LNP LN *
#define LNA LNP
#define LONGARRAY LNA
#define LONGPOINTER LNP
#define LONGP LONGPOINTER
#define LONGNUMBER LONG
#define LongNumber LONGNUMBER
// ------------------------------------------------------------------------------------
// all deprecated in favour of lf.h
/*
#define LONGFLOATSTRUCT LF
#define LongFloatStruct LONGFLOATSTRUCT
#define LONGFLOAT LONGFLOATSTRUCT
#define LongFloat LONGFLOAT
typedef struct { LF valueA; LF valueB; LF valueC;
LF digitsA; LF digitsB; LF digitsC;
LF scaleA; LF scaleB; LF scaleC;
LF excessA; LF excessB; LF excessC; } LFP;
#define LONGFLOATPAIR LFP
#define LongFloatPair LONGFLOATPAIR
//typedef struct { LF valuenumb; LF valuefrac; LF valuemeld; } LFMUL;
//#define LFADD LFMUL
//#define LFSUB LFMUL
//#define LFDIV LFMUL
//#define LFMOD LFMUL
// later, more complicated constructs may have extra variables
//#define LONGFLOATMULTIPLY LFMUL
// also LFA, LFS, LFD, LFMOD (LFM -> LFMUL, not LFMOD) .. or just use non-ambiguous names
// so, LFADD, LFSUB, LFMUL, LFDIV, LFMOD
#define LF_0_0(lf) lf.numb = 0; lf.frac = 0; lf.diff = -1; // -0.0
typedef struct { LF value; LF scale; LN overflow; } LFO;
typedef struct { LF value; LF digits; LF scale; } LFDS;
#define LONGFLOATOVERFLOW LFO
#define LongFloatOverflow LONGFLOATOVERFLOW
#define LONGFLOATDIGITSCALE LFDS
#define LongFloatDigitScale LONGFLOATDIGITSCALE
#define LONGFLOATDETAIL LFD
#define LongFloatDetail LONGFLOATDETAIL
#define LONGFLOATDETAILSTRUCT LFD
#define LongFloatDetailStruct LONGFLOATDETAILSTRUCT
#define LDF LFD
#define LONGDETAILEDFLOATSTRUCT LDF
#define LongDetailedFloatStruct LONGDETAILEDFLOATSTRUCT
#define LONGDETAILEDFLOAT LONGDETAILEDFLOATSTRUCT
#define LongDetailedFloat LONGDETAILEDFLOAT
*/
#define FIX1(pre, suf1) pre##suf1
#define FIX2(pre, suf1, suf2) pre##suf1; pre##suf2
#define FIX3(pre, suf1, suf2, suf3) pre##suf1; pre##suf2; pre##suf3;
#define GLFLOATTYPE GLfloat
#define GLFP GLFLOATTYPE
#define GLFPP GLFP *
#define GLFPA GLFPP
#define GLFLOATARRAY GLFPA
#define GLFloatArray GLFLOATARRAY
#define FLOATTYPE float
#define FP FLOATTYPE
#define FPP FP *
#define FPA FPP
#define FLOATARRAY FPA
#define FloatArray FLOATARRAY
#define FLOATINGPOINTARRAY FPA
#define FloatingPointArray FLOATINGPOINTARRAY
#define FLOATPOINTER FPP
#define FLOATP FLOATPOINTER
#define FLOAT FP
#define FLOATINGPOINT FLOAT
#define FloatingPoint FLOATINGPOINT
#define DOUBLETYPE double
#define DP DOUBLETYPE
#define DPP DP *
#define DPA DPP
#define DOUBLEARRAY DPA
#define DoubleArray DOUBLEARRAY
#define DOUBLEPRECISIONFLOATINGPOINTARRAY DPA
#define DoublePrecisionFloatingPointArray DOUBLEPRECISIONFLOATINGPOINTARRAY
#define DOUBLEPOINTER DPP
#define DOUBLEP DOUBLEPOINTER
#define DOUBLE DP
#define DOUBLINGPOINT DOUBLE
#define DoublingPoint DOUBLINGPOINT
// exclude the below if kernel mode active (was KLOG used?)
#ifndef KERNELMODE
#ifndef STDIO_H
#include <stdio.h>
#define STDIO_H
// for printf
#endif
#define FS FILE *
#define CMD FILE *
#define FILEP FILE *
// ^ file string ? i guess that makes sense
// ^ no, file stream...
#define FILESTRING FS
#define FileString FILESTRING
#define FILESTREAM FS
#define FileStream FILESTREAM
#define OPENCMD(cmd) popen(cmd, "r")
#define OPENFILE(f) fopen(f, "r")
#define OPENFILENAME(f) OPENFILE(f) // open by name, close file
#define SAVEFILE(f) fopen(f, "w")
#define SENDCMD(cmd) popen(cmd, "w")
#define MODIFYFILE(f) fopen(f, "r+")
#define EDITFILE(f) MODIFYFILE(f)
#define WRITEFILE(f) fopen(f, "w+")
#define OPENBLOCKFILE(f) fopen(f, "rb")
#define SAVEBLOCKFILE(f) fopen(f, "wb")
#define GETCH(fs) fgetc(fs)
#define GETFCH(fs) fgetc(fs)
#define GETCMDCH(fs) GETCH(fs)
#define GETFILECH(fs) GETCH(fs)
#define GETSTDCH GETCH(stdin)
#define GETSTDCHAR GETSTDCH
#define PUTSTDCH(ch) fputc(ch, stdout)
#define PUTSTDCHAR(ch) PUTSTDCH(ch)
#define PUTFCH(fs, ch) fputc(ch, fs)
#define STDGETCHAR GETSTDCHAR
#define STDPUTCHAR(ch) PUTSTDCH(ch)
#define FGETCHAR(fs) GETFCH(fs)
#define FPUTCHAR(fs, ch) PUTFCH(fs, ch)
#define STDGETCH STDGETCHAR
#define STDPUTCH(ch) STDPUTCHAR(ch)
#define FGETCH(fs) FGETCHAR(fs)
#define FPUTCH(fs, ch) FPUTCHAR(fs, ch)
//#define CLOSECMD(cmd) IF (cmd) { pclose(cmd); }
#define CLOSEFILE(f) IF (f) { fclose(f); } // cannot be used as QUICKFILE ...
// graceful in case of failed open, should have error handler functions
#define CLOSEBLOCKFILE(f) fclose(f)
#define GOTOEOF(fs) fseek(fs, 0, SEEK_END)
#define GOTOSOF(fs) fseek(fs, 0, SEEK_SET)
#define GETFPOS(fs) ftell(fs)
#define NEXTFCH(fs) fseek(fs, 1, SEEK_CUR)
#define PREVFCH(fs) fseek(fs, -1, SEEK_CUR)
#define NEXTCH(fs) NEXTFCH(fs) // <-- deprecated
#define PREVCH(fs) PREVFCH(fs) // <-- deprecated
#define STEPF(fs, n) fseek(fs, n, SEEK_CUR)
#define ISFEOF(fs) (feof(fs))
#define NOTFEOF(fs) (!feof(fs))
#define NOTSTDEOF NOTFEOF(stdin)
#define MORECHARS NOTSTDEOF
//#define FCHOUT(ch,fs) fputc(ch, fs)
#define CHFOUT(ch, fs) fputc(ch, fs)
#define FCHOUT(fs, ch) fputc(ch, fs)
#define OUTFCH(fs, ch) fputc(ch, fs)
#define PUTFCH(fs, ch) fputc(ch, fs)
#define PUTFCS(fs, cs) fputs(cs, fs)
//#define FPUTCH(fs, ch) fputc(ch, fs) // already defined above....
// do not encourage FPUTC since params are backwards
#define STDCHOUT(ch) CHFOUT(ch, stdout)
#define STDOUTCH(ch) STDCHOUT(ch)
// ^^ CLOSECMD(cmd) --> IF (OPENCMD(cmd)) { pclose(OPENCMD(cmd); } // nope ....
//#define CLOSECMD(fs) fclose(fs) // assumes command opens
// wait wut ^ and ^^
#define CLOSECMD(cmd) pclose(cmd) // does not check .. should CLOSEFILE ? TRY-
#define QUICKCMD(cmd) CLOSECMD(OPENCMD(cmd))
#define IFNOTFEOF(fs) IF (NOTFEOF(fs))
#define IFNFEOF(fs) IFNOTFEOF(fs)
#define EFNFEOF(fs) EF (NOTFEOF(fs))
#define EFNOTFEOF(fs) EFNFEOF(fs)
#define WINOTFEOF(fs) WI (NOTFEOF(fs))
#define WINFEOF(fs) WINOTFEOF(fs)
#define WINEOF(fs) WINOTFEOF(fs)
#define IFNOT(cn) IF (!(cn))
#define MAXNEGINT -2147483648
#define MAXNEG MAXNEGINT
#define ISNEG LT 0
#define NEG ISNEG
#define INMUL10ADDCH(in, ch) in = (in * 10) + (ch - A0);
#define INMULADD(in, ch) INMUL10ADDCH(in, ch)
//#define INNEGMUL10ADDCH(in, ch) in MULS -1; INMUL10ADDCH(in, ch); in MULS -1;
#define INNEGMUL10ADDCH(in, ch) in = 0 - in; INMUL10ADDCH(in, ch); in = 0 - in;
#define INNEGMULADD(in, ch) INNEGMUL10ADDCH(in, ch)
#define INCHADD(in, ch) IF (in NEG) { INNEGMULADD(in, ch); } EL { INMULADD(in, ch); }
// unpredictable but perhaps reasonable results for non-alphanum
#define INCALPHANUM(ch) (INRANGE(ch, A9, AA - 1) ? AA : INRANGE(ch, AZ, Aa - 1) ? Aa : (ch GQ Az - 1) ? Az : (ch LT A0) ? A0 : ch + 1)
#define DECALPHANUM(ch) (INRANGE(ch, A9 + 1, AA) ? A9 : INRANGE(ch, AZ + 1, Aa) ? AZ : (ch GQ Az) ? Az : (ch LQ A0) ? A0 : ch - 1)
// assume base 10 for now
#define GETIN(ch, fs, to) \
IF (IRA09(ch) OR ch EQ Adash) { \
IF (ch EQ Adash) { ch = GETCH(fs); to = 0 - (ch - A0); ch = GETCH(fs); } \
WI (IRA09(ch)) { INCHADD(to, ch); ch = GETCH(fs); } }
#define GETPADIN(ch, fs, to) \
WI (ch EQ Atab OR ch EQ Aspace) { ch = GETCH(fs); } \
GETIN(ch, fs, to);
// ^ uses current char and grabs more until not int
// ^ not going to work when there are pair bytes
// contrast with MUNCHIN (which eats strings)
#define MUNCHIN(var, tgt) \
IF (IRA09(EL0(var)) OR EL0(var) EQ Adash) { \
IF (EL0(var) EQ Adash) { NEXT1(var); tgt = 0 - (EL0(var) - A0); NEXT1(var); } \
WI (IRA09(EL0(var))) { INCHADD(tgt, EL0(var)); NEXT1(var); } }
#define MUNCHPADIN(var, tgt) \
WI (EL0(var) EQ Atab OR EL0(var) EQ Aspace)) { NEXT1(var); } \
MUNCHIN(var, tgt);
// consider a MUNCHIN that allows -00001, though that probably implies octal representation. or not. w/e it's erroneous.
// LFDS tgt = { { 0, 0 }, { 0, 0 }, { 1, 1 } };
#define MUNCHLFDS(var, tgt) \
IF (IRA09(EL0(var)) OR EL0(var) EQ Adash) { \
IF (EL0(var) EQ Adash) { tgt.scale.numb = -tgt.scale.numb; NEXT1(var); } \
WI (IRA09(EL0(var))) { INCHADD(tgt.value.numb, EL0(var)); NEXT1(var); } \
IF (EL0(var) EQ Adot) { tgt.scale.frac = -tgt.scale.frac; NEXT1(var); } \
WI (IRA09(EL0(var))) { INCHADD(tgt.value.frac, EL0(var)); NEXT1(var); } }
#define LFDSTOFP(lfds) ((lfds.value.numb * lfds.scale.numb) + ((0.1f * lfds.value.frac) / lfds.scale.frac))
// #define LFDSTOLF( ....) 10.123 but 10.000123 .... as 10.123000 ? seems counterintuitive
// WI (IRA09(var[0])) { tgt = (tgt * 10) + (var[0] - A0); var = &var[1]; } // "555" -> 555
// MUNCHLF deprecated in favour of storing fractions with backward scaling
// LF should be { 0, 0, 1 } .. but can probably have an offset at MSD scale
#define MUNCHLF(var, tgt) \
IF (IRA09(EL0(var)) OR EL0(var) EQ Adash) { \
IF (EL0(var) EQ Adash) { tgt.diff = -tgt.diff; NEXT1(var); } \
WI (IRA09(EL0(var))) { INCHADD(tgt.numb, EL0(var)); NEXT1(var); } \
IF (EL0(var) EQ Adot) { \
tgt.diff = tgt.diff; NEXT1(var); \
WI (IRA09(EL0(var))) { INCHADD(tgt.frac, EL0(var)); NEXT1(var); } } }
#define LFTOFP(lf) (((1.0f / lf.diff) * lf.frac) + lf.numb)
//#define EATCH(var) var = &var[1];
//#define NEXTCH(var) EATCH(var)
// ^ defined earlier - need reordering tool
#ifndef STDLIB_H
#include <stdlib.h>
#define STDLIB_H
// for malloc
#endif
#ifndef STRING_H
#include <string.h>
#define STRING_H
// for strcmp
#endif
#ifndef UNISTD_H
#include <unistd.h>
#define UNISTD_H
// for usleep, isatty
#endif
#endif
#define STDLINESIZE 4096
#define WAIT(n) usleep(n * 1000000)
#define FPSWAIT(n) IF (n GT 0) { usleep(1000000 / n); } EL { _c('*'); }
#define WAITFPS(n) FPSWAIT(n)
#define WAITMS(n) usleep(n * 1000)
#define WAIT1MS WAIT(0.001)
#define WAIT10MS WAIT(0.01)
#define WAIT50MS WAIT(0.05)
#define WAIT100MS WAIT(0.1)
#define WAIT200MS WAIT(0.2)
#define WAIT300MS WAIT(0.3)
#define WAIT400MS WAIT(0.4)
#define WAIT500MS WAIT(0.5)
#define WAIT600MS WAIT(0.6)
#define WAIT700MS WAIT(0.7)
#define WAIT800MS WAIT(0.8)
#define WAIT900MS WAIT(0.9)
#define WAIT1S WAIT(1)
#define WAIT1SEC WAIT1S
#define Wait1Sec WAIT1SEC
#define WAIT1SECOND WAIT1SEC
#define Wait1Second WAIT1SECOND
#define SLEEP1MS WAIT1MS
#define SLEEP10MS WAIT10MS
#define SLEEP100MS WAIT100MS
#define SLEEP200MS WAIT100MS; WAIT100MS;
#define SLEEP1S WAIT1S
#define SLEEP5FPS SLEEP200MS
#define SLEEPMS(n) WAITMS(n)
// ^ this should be replaced with BOUNDARY CHECKS - flag recompile with larger buffer if exceeded
#define GLFPMEM(n) (GLFPP) malloc(sizeof(GLFP) * (n))
#define INMEM(n) (INP) malloc(sizeof(IN) * (n))
#define CHMEM(n) (CHP) malloc(sizeof(CH) * (n))
#define FPMEM(n) (FPP) malloc(sizeof(FP) * (n))
#define KCHMEM(n) (UCHP) kmalloc(sizeof(UCH) * (n))
#define MALLOC malloc
#define NEWMEM malloc
#define MEM malloc
#define UNMEM(v) free(v)
#define NOMEM(v) UNMEM(v)
#define INTMEM(n) INMEM(n)
#define STRMEM(n) CHMEM(n)
//^ file stream
#define UCH unsigned char
#define UCHP UCH *
#define UCHPOINTER UCHP
#define UCHSIZE sizeof(UCH)
#define SCH signed char
#define SC SCH // .. actually CCH has the same issue
#define CH char // UCH
#define CHP UCHP
#define CHARPOINTER CHP
#define CHPOINTER CHP
#define CCH const CH
// #define CCH const CH // CCH * for const char string.. CCS label (not function) could still be used
// ^ signed char
#define SH short
#define SSH signed short
#define USH unsigned short
//#define ST char *
// ST no longer means string, use CS
#define ST static
#define STATIC ST
#define CN const
#define CONSTANT CN
#define CS CH *
#define CSA CS *
#define CSAA CS **
#define CSAAA CS ***
#define CHARSTR CS
#define CHARSTRARRAY CSA
#define CHARSTRARRAYOFARRAYS CSAA
#define CHARSTRARRAYOFARRAYSOFARRAYS CSAAA
#define CCS CCH *
#define CNCS CCS
#define CNIN CONSTANT INTEGER
#define CIN CNIN
#define CINP CN INP
#define UCS unsigned CS
// DEF: name a b c -> blabc (syn, syn, syn -> def)
// --> to set output file for - and -> commands
// -> #define name(a,b,c) blabc
// -> #define syn1 name
// -> #define syn2 name
// -> #define syn3 def)
#define STCS ST CS
#define SCS signed CS
//^define SCS // SCS :> SIGNED CONSTANT string
// (:> :> would be / should be - check, remark (suggested secondary connection)
// (=> => is - check, error if not (required secondary connection))
#define STCNCS ST CNCS
#define SCCS STCNCS
#define CUCS CN UCS
#define CUCH CN UCH
#define CUCHP CUCS
#define CUSHP CN USH *
// #define CSCS SCCS
// ^ static const character string
#define STIN ST IN
//#define SIN STIN <-- support math probably
// ^ simple throwback definitions should point to the best word
#define STCNIN ST CN IN
#define STCIN STCNIN
#define SCIN STCNIN
#define STCNCH ST CN CH
#define STCNUCH ST CN UCH
#define SCCH STCNCH
#define SCUCH STCNUCH
#define STCNSH ST CN SH
#define STCNUSH ST CN USH
#define SCSH STCNSH
#define SCUSH STCNUSH
#define CNFP CN FP
#define CFP CNFP
#define STFP ST FP
#define SFP STFP // no signed FP to compete with
#define STCSFP ST CS FP
#define SCFP STCSFP
// #define CCS CCH * // need to allow label and function definitions
#define VD void
#define VDP VD *
#define VDPP VDP *
#define VDPPP VDPP *
#define BK break
#define CT continue
#define RT return
#define RT0Rs(str) R1_("%s", str); RT 0;
#define RT1Rs(str) R1_("%s", str); RT 1;
#define RT2Rs(str) R1_("%s", str); RT 2;
#define RT3Rs(str) R1_("%s", str); RT 3;
#define RT4Rs(str) R1_("%s", str); RT 4;
#define RT5Rs(str) R1_("%s", str); RT 5;
#define RTREDERR(str) RT1Rs(str)
#define RT0(str) RT0Rs(str)
#define RT1(str) RT1Rs(str)
#define RT2(str) RT2Rs(str)
#define RT3(str) RT3Rs(str)
#define RT4(str) RT4Rs(str)
#define RT5(str) RT5Rs(str)
#define EXIT RT
#define ERT RLOG("***********"); RT
// ----- NOP -------!
#define NOP 0; // presumably compiles to nothing
// e.g. IF (bla) { NOP } EF (bla) { NOP } EL { SOMETHING; }
// ------------------------- EQUAL ------------------------------------------------------------------------------------
#define IS = // <- allow IS and IS() when func and word unique (maybe)
// Prefer to retain IS as this IS that;, but IF IS(this) { } has its value
// Also, IF this IS that-> IF IS(this, that)-> IF (this EQ that)-> IF (this == that)
//#define AT &
// ^ also ASCII T
#define AT(var) &var
// ATn defubed kater.. AT before var is probably not ASCII T - can has universal def?
#define EQ ==
#define OEQ1(dv, o, a) dv[0 + o] EQ a
#define OEQ(dv, o, a) OEQ1(dv, o, a)
#define OEQ2(dv, o, a, b) OEQ(dv, 0, a) AND OEQ(dv, 1, b)
#define OEQ3(dv, o, a, b, c) OEQ2(dv, 0, a, b) AND OEQ(dv, 2, c)
#define OEQ4(dv, o, a, b, c, d) OEQ3(dv, 0, a, b, c) AND OEQ(dv, 3, d)
#define OEQ5(dv, o, a, b, c, d, e) OEQ4(dv, 0, a, b, c, d) AND OEQ(dv, 4, e)
#define OEQ6(dv, o, a, b, c, d, e, f) OEQ5(dv, 0, a, b, c, d, e) AND OEQ(dv, 5, f)
#define OEQNUL(dv, o) OEQ(dv, o, NUL)
#define OFFSETEQUAL(dv, o, a) OEQ(dv, o, a)
// VALUE EQUALS ---------------- VEQ4(abcd, 'a', 'b', 'c', 'd')
#define VEQ1(dv, a) (OEQ1(dv, 0, a))
#define VEQ2(dv, a, b) (OEQ2(dv, 0, a, b))
#define VEQ3(dv, a, b, c) (OEQ3(dv, 0, a, b, c))
#define VEQ4(dv, a, b, c, d) (OEQ4(dv, 0, a, b, c, d))
#define VEQ5(dv, a, b, c, d, e) (OEQ5(dv, 0, a, b, c, d, e))
#define VEQ6(dv, a, b, c, d, e, f) (OEQ6(dv, 0, a, b, c, d, e, f))
// ^^ These are for VEQ, VALUE EQUALS, V[0] ==, *V ==
// ELEMENTS EQUAL
#define SEQ0(dv) (OEQNUL(dv, 0))
#define SEQ1(dv, a) (OEQ1(dv, 0, a) AND OEQNUL(dv, 1))
#define SEQ2(dv, a, b) (OEQ2(dv, 0, a, b) AND OEQNUL(dv, 2))
#define SEQ3(dv, a, b, c) (OEQ3(dv, 0, a, b, c) AND OEQNUL(dv, 3))
#define SEQ4(dv, a, b, c, d) (OEQ4(dv, 0, a, b, c, d) AND OEQNUL(dv, 4))
#define SEQ5(dv, a, b, c, d, e) (OEQ5(dv, 0, a, b, c, d, e) AND OEQNUL(dv, 5))
#define SEQ6(dv, a, b, c, d, e, f) (OEQ6(dv, 0, a, b, c, d, e, f) AND OEQNUL(dv, 6))
#define SEQNUL(dv) (SEQ0(dv))
// SEQUENCE EQUALS (with NUL terminator)
#define OEQQ1(dv, o, a) (OEQ1(dv, o, a) OR (a EQ '?'))
#define EQQ1(dv, a) (OEQQ1(dv, 0, a))
#define EQQ2(dv, a, b) (EQQ1(dv, a) AND OEQQ1(dv, 1, b))
#define EQQ3(dv, a, b, c) (EQQ2(dv, a, b) AND OEQQ1(dv, 2, c))
#define EQQ4(dv, a, b, c, d) (EQQ3(dv, a, b, c) AND OEQQ1(dv, 3, d))
#define EQQ5(dv, a, b, c, d, e) (EQQ4(dv, a, b, c, d) AND OEQQ1(dv, 4, e))
#define EQQ6(dv, a, b, c, d, e, f) (EQQ5(dv, a, b, c, d, e) AND OEQQ1(dv, 5, f))
// ELEMENTS EQUAL QUERY (where EL '?' EQ anything)
#define SEQQ1(dv, a) (EQQ1(dv, a) AND OEQNUL(dv, 1))
#define SEQQ2(dv, a, b) (EQQ2(dv, a, b) AND OEQNUL(dv, 2))
#define SEQQ3(dv, a, b, c) (EQQ3(dv, a, b, c) AND OEQNUL(dv, 3))
#define SEQQ4(dv, a, b, c, d) (EQQ4(dv, a, b, c, d) AND OEQNUL(dv, 4))
#define SEQQ5(dv, a, b, c, d, e) (EQQ5(dv, a, b, c, d, e) AND OEQNUL(dv, 5))
#define SEQQ6(dv, a, b, c, d, e, f) (EQQ6(dv, a, b, c, d, e, f) AND OEQNUL(dv, 6))
// SEQUENCE EQUALS QUERY (where EL '?' EQ anything, with NUL terminator)
#define CSQ1(dv, cs) SEQQ1(dv, cs[0])
#define CSQ2(dv, cs) SEQQ2(dv, cs[0], cs[1])
#define CSQ3(dv, cs) SEQQ3(dv, cs[0], cs[1], cs[2])
#define CSQ4(dv, cs) SEQQ4(dv, cs[0], cs[1], cs[2], cs[3])
#define CSQ5(dv, cs) SEQQ5(dv, cs[0], cs[1], cs[2], cs[3], cs[4])
#define CSQ6(dv, cs) SEQQ6(dv, cs[0], cs[1], cs[2], cs[3], cs[4], cs[5])
// later: #define CSQ(dv, cs) should check cs length and trigger the appropriate function
// requires: string.h
#define STREQ(str, str1) (str && str1 && strcmp(str, str1) == 0)
#define STREQ2(str, str1, str2) (STREQ(str, str1) OR STREQ(str, str2))
// ^ either A or B......... this should maybe be BOTH by default... AND
// STREQALL2 ... STREQBOTH ... STREQEITHER2
#define STRNEQ(str, str1) (str && str1 && strcmp(str, str1) != 0)
#define STRNEQ2(str, str1, str2) (STRNEQ(str, str1) AND STRNEQ(str, str2))
// ^ neither A nor B
#define STREQANY2(str, str1, str2) (STREQ(str, str1) OR STREQ(str, str2))
#define STREQANY3(str, str1, str2, str3) (STREQANY2(str, str1, str2) OR STREQ(str, str3))
#define STREQANY4(str, str1, str2, str3, str4) (STREQANY3(str, str1, str2, str3) OR STREQ(str, str4))
#define STRNUL(str) STREQ(str, "")
#define STRNNUL(str) STRNEQ(str, "")
#define STRNQNUL(str) STRNEQ(str, "")
// Case insensitive string matches:
//#define STREQCI(str, str1) (str && str1 && strcmpi(str, str1) == 0)
// requires: strings.h
#define STREQCI(str, str1) (str AND str1 AND strcasecmp(str, str1) EQ 0)
#define STREQANY2CI(str, str1, str2) (STREQCI(str, str1) OR STREQCI(str, str2))
#define STREQANY3CI(str, str1, str2, str3) (STREQANY2CI(str, str1, str2) OR STREQCI(str, str3))
#define STREQANY4CI(str, str1, str2, str3, str4) (STREQANY3CI(str, str1, str2, str3) OR STREQCI(str, str4))
// String prefix matches:
#define STRPREFIXEQ(str, prefix) (str AND prefix AND strncmp(str, prefix, strlen(prefix)) EQ 0)
// etc...
// #define STREQ2(dv, ab) SEQ2(dv, ab[0], ab[1])
// ^ STREQ and STRNEQ
//#define CSQ(dv, cs) (cs[0] EQNUL)
// #define SEQ2ANY2(dv, ab, cd) (STREQ2(dv, ab) OR STREQ2(dv, cd))
// THIS EQUALS ANY OF THESE
#define EQANY2(var, opt1, opt2) (var EQ opt1 OR var EQ opt2)
#define EQANY3(var, opt1, opt2, opt3) (var EQ opt1 OR var EQ opt2 OR var EQ opt3)
#define EQANY4(var, opt1, opt2, opt3, opt4) (var EQ opt1 OR var EQ opt2 OR var EQ opt3 OR var EQ opt4)
#define EQANY5(var, opt1, opt2, opt3, opt4, opt5) (var EQ opt1 OR var EQ opt2 OR var EQ opt3 OR var EQ opt4 OR var EQ opt5)
// #define IFANY2SEQ(var, opt1, opt2) IFSEQ2ANY2 <-- will check the first two characters, not the whole string
// IFANY2SEQ should check the whole string and allow for varying size
#define EL0(var) var[0]
#define EL1(var) var[1]
#define EL2(var) var[2]
#define EL3(var) var[3]
#define EL4(var) var[4]
#define EL5(var) var[5]
//#defube AT(var) &var <-- defubed earuker, also consider ASCII T
#define AT0(var) &var[0]
#define AT1(var) &var[1]
#define AT2(var) &var[2]
#define AT3(var) &var[3]
#define AT4(var) &var[4]
#define AT5(var) &var[5]
#define NEXT1(var) var = AT1(var);
// ---------------------- NOT EQUAL -----------------------------------------------------------------------------------
#define NOT !
#define NQ !=
#define NEQ NQ
#define ISEQUAL EQ
#define EQUALS EQ
#define NOTEQUAL NQ
#define ISNOTEQUALTO NQ
#define UNEQUAL NQ
#define EQEOF EQ EOF
#define NQEOF NQ EOF
#define IFEQEOF(ch) IF (ch EQEOF)
#define IFNQEOF(ch) IF (ch NQEOF)
#define EFEQEOF(ch) EF (ch EQEOF)
#define EFNQEOF(ch) EF (ch NQEOF)
#define BKIFEQEOF(ch) IF (ch EQEOF) { BK; }
#define BKIFEQEOFORNEWLINE(ch) IF (ch EQEOF OR ch EQ Anewline) { BK; }
#define BKEQEOF(ch) BKIFEQEOF(ch)
#define BKEQEOFORNL(ch) BKIFEQEOFORNEWLINE(ch)
#define BKIFNQEOF(ch) IF (ch EQEOF) { BK; }
#define BKNQEOF(ch) BKIFNQEOF(ch)
#define BKIFEQNUL(ch) IF (ch EQNUL) { BK; }
#define BKEQNUL(ch) BKIFEQNUL(ch)
#define BKIFNQNUL(ch) IF (ch EQNUL) { BK; }
#define BKNQNUL(ch) BKIFNQNUL(ch)
#define BKEQNEWLINE(ch) IF (ch EQ NEWLINE) { BK; }
#define BKEQAnewline(ch) BKEQNEWLINE(ch)
#define BKEQAnl(ch) BKEQNEWLINE(ch)
#define BKEQNULL(ch) IF (ch EQNULL) { BK; }
#define IFYESNO(yv, nv) IF (yv YES AND nv NO)
#define IFNOYES(nv, yv) IF (nv NO AND yv YES)
#define IFYN(yv, nv) IFYESNO(yv, nv)
#define IFNY(yv, nv) IFNOYES(nv, yv)
#define EQNUL EQ NUL
#define NQNUL NQ NUL
#define EQNULL EQ NULL
#define NQNULL NQ NULL
//#define 0EQ 0 EQ <-- can't, but try IF0EQ ... no, that's IFEL0EQ ... ambiguity flag
//#define OBJ NQNULL <-- OBJ now means STRUCT
#define ISOBJ NQNULL
#define NOBJ EQNULL
#define NOTOBJ NQNULL
#define LT <
#define LESSTHAN LT
#define LQ <=
#define LESSEQUAL LQ
#define MT >
#define MORETHAN MT
#define MQ >=
#define MOREEQUAL MQ
#define GT >
#define GREATERTHAN GT
#define GQ >=
#define GREATEREQUAL GQ
#define PLUS +
//#define PL PLUS
#define MINUS -
//#define MN MINUS
#define TIMES *
#define MULTIPLIEDBY TIMES
#define MultipliedBy MULTIPLIEDBY
#define MUL TIMES
#define MULTIPLY MUL
//#define TM TIMES
#define DIVIDEDBY /
#define DividedBy DIVIDEDBY
#define DIV DIVIDEDBY
#define DIVIDE DIV
//#define DV DIVIDEDBY
#define MOD %
#define MODULUS MOD
#define Modulus MODULUS
#define AND &&
#define OR ||
#define ORR OR
#define INCMOD(var,lim) (INC var MOD lim)
#define RINC RLOG("++"); ++
#define YINC YLOG("++"); ++
#define GINC GLOG("++"); ++
#define CINC CLOG("++"); ++
#define BINC BLOG("++"); ++
#define MINC MLOG("++"); ++
#define OREQ2(dv, a, b) (dv EQ a OR dv EQ b)
#define EQOR2(dv, a, b) OREQ2(dv, a, b)
#define OREQ3(dv, a, b, c) (dv EQ a OR dv EQ b OR dv EQ c)
#define ORNQ2(dv, a, b) (dv NQ a OR dv NQ b)
#define ORNQ3(dv, a, b, c) (dv NQ a OR dv NQ b OR dv NQ c)
#define ANDNQ2(dv, a, b) (dv NQ a AND dv NQ b)
#define ANDNQ3(dv, a, b, c) (dv NQ a AND dv NQ b AND dv NQ c)
#define ORREQ2(dv, a, b) OREQ2(dv, a, b)
#define ORREQ3(dv, a, b, c) OREQ3(dv, a, b, c)
#define ORRNQ2(dv, a, b) ORNQ2(dv, a, b)
#define ORRNQ3(dv, a, b, c) ORNQ3(dv, a, b, c)
#define ORRNEQ2(dv, a, b) ORNQ2(dv, a, b)
#define ORRNEQ3(dv, a, b, c) ORNQ3(dv, a, b, c)
#define ANDNEQ2(dv, a, b) ANDNQ2(dv, a, b)
#define ANDNEQ3(dv, a, b, c) ANDNQ3(dv, a, b, c)
#define LT1(n, v1) (v1 LT n)
#define LT2(n, v1, v2) (v1 LT n AND v2 LT n)
#define LT3(n, v1, v2, v3) (v1 LT n AND v2 LT n AND v3 LT n)
#define LT4(n, v1, v2, v3, v4) (LT2(n, v1, v2) AND LT2(n, v3, v4))
#define LT5(n, v1, v2, v3, v4, v5) (LT3(n, v1, v2, v3) AND LT2(n, v4, v5))
#define LT6(n, v1, v2, v3, v4, v5, v6) (LT3(n, v1, v2, v3) AND LT3(n, v4, v5, v6))
#define GT1(n, v1) (v1 GT n)
#define GT2(n, v1, v2) (v1 GT n AND v2 GT n)
#define GT3(n, v1, v2, v3) (v1 GT n AND v2 GT n AND v3 GT n)
#define GT4(n, v1, v2, v3, v4) (GT2(n, v1, v2) AND GT2(n, v3, v4))
#define GT5(n, v1, v2, v3, v4, v5) (GT3(n, v1, v2, v3) AND GT2(n, v4, v5))
#define GT6(n, v1, v2, v3, v4, v5, v6) (GT3(n, v1, v2, v3) AND GT3(n, v4, v5, v6))
#define MIN2(a, b) ((b < a) ? b : a)
#define MIN3(a, b, c) MIN2(MIN2(a, b), MIN2(b, c))
#define MIN4(a, b, c, d) MIN2(MIN3(a, b, c), d)
#define MAX2(a, b) ((b > a) ? b : a)
#define MAX3(a, b, c) MAX2(MAX2(a, b), MAX2(b, c))
#define MAX4(a, b, c, d) MAX2(MAX3(a, b, c), d)
#define XOR ^
// ^ XOR should be changed to ^|, freeing ^ to mean power
#define INC ++
#define INCS ++
#define DEC --
#define DECS --
#define ADDS +=
#define SUBS -=
#define MULS *=
#define DIVS /=
#define INC1(v) INC v;
#define INC2(v) INC v; INC v;
#define INC3(v) INC v; INC v; INC v;
#define DEC1(v) DEC v;
#define DEC2(v) DEC v; DEC v;
#define DEC3(v) DEC v; DEC v; DEC v;
#define INCONTO(str, ch) WI (ANDNQ2(str[0], ch, NUL)) { INC str; }
#define INCONTO0(str) INCONTO(str, NUL)
//#define INCONTO0(str) WI (str[0] NQNUL) { INC str; printf("%c", str[0]); }
#define INCONTO1(str, c1) INCONTO(str, c1)
#define INCONTO2(str, c1, c2) WI (ANDNQ3(str[0], c1, c2, NUL)) { INC str; }
#define INCTHRU(str, ch) INCONTO(str, ch); INC str;
#define INCTHRU0(str) INCTHRU(str, NUL)
#define INCTHRU1(str, c1) INCTHRU(str, c1)
#define INCTHRU2(str, c1, c2) INCONTO2(str, c1, c2); INC str;
// -------------------------------------------------------------------
#define STRF sprintf
#define STR1(s,a) STRF(s, "%s", a)
#define STR2(s,a,b) STRF(s, "%s%s", a, b)
#define STR3(s,a,b,c) STRF(s, "%s%s%s", a, b, c)
//#define STRSIZE(str) snprintf(NULL, 0, str)
// ^ um segfault? ..... works in snprintf.c ..
//#define STR0SIZE(str) (STRSIZE(str) + 1)
//#define STRNF(var, size, str) snprintf(var, size + 1, str)
// ^ prints up to the given size (strlen), + 1 for NUL
//#define STR0NF(var, size, str) snprintf(var, size, str)
// ^ prints up to size - 1 (strlen), + 1 for NUL
// not safe for some reason .............................
// --------------------------------------------------------- move --
#define CS1(nm, sz, fmt, p1) CH nm[sz]; STRF(nm, fmt, p1);
#define CS2(nm, sz, fmt, p1, p2) CH nm[sz]; STRF(nm, fmt, p1, p2);
#define CS3(nm, sz, fmt, p1, p2, p3) CH nm[sz]; STRF(nm, fmt, p1, p2, p3);
#define CS4(nm, sz, fmt, p1, p2, p3, p4) CH nm[sz]; STRF(nm, fmt, p1, p2, p3, p4);
// -- ^ deprecated ... -----------------------------------------
#define INRANGE(var, min, max) (var >= min && var <= max)
#define INRANGE2(v1, v2, min, max) (INRANGE(v1, min, max) AND INRANGE(v2, min, max))
#define INRANGE3(v1, v2, v3, min, max) (INRANGE2(v1, v2, min, max) AND INRANGE(v3, min, max))
#define INRANGE4(v1, v2, v3, v4, min, max) (INRANGE3(v1, v2, v3, min, max) AND INRANGE(v4, min, max))
#define EXRANGE(var, min, max) (var < min || var > max)
#define CHISINT(var) INRANGE(var, A0, A9)
#define ISNUMCH(var) CHISINT(var)
#define NUMCH(var) CHISINT(var)
#define SPACH(var) (var EQ Aspace OR var EQ Atab)
#define ISSPACECH(var) SPACH(var)
#define IRA09(var) INRANGE(var, A0, A9)
#define EL0IRA09(var) INRANGE(EL0(var), A0, A9)
#define ASCH(ch) ((ch < ' ') ? (ch + 'A') : (ch > '~') ? '#' : ch)
#define LOG0 fflush(stdout);
//#define _ printf <-- currently prints newline but - can do that later
#define FPUTF fprintf
#define LOGF printf
#define LOG(str) fprintf(stdout, str); LOG0
#define LOG1(str, v1) fprintf(stdout, str, v1); LOG0
#define LOG2(str, v1, v2) fprintf(stdout, str, v1, v2); LOG0
#define LOG3(str, v1, v2, v3) fprintf(stdout, str, v1, v2, v3); LOG0
#define LOG4(str, v1, v2, v3, v4) fprintf(stdout, str, v1, v2, v3, v4); LOG0
#define LOG5(str, v1, v2, v3, v4, v5) fprintf(stdout, str, v1, v2, v3, v4, v5); LOG0
#define LOG6(str, v1, v2, v3, v4, v5, v6) fprintf(stdout, str, v1, v2, v3, v4, v5, v6); LOG0
#define LOG7(str, v1, v2, v3, v4, v5, v6, v7) fprintf(stdout, str, v1, v2, v3, v4, v5, v6, v7); LOG0
#define LOG8(str, v1, v2, v3, v4, v5, v6, v7, v8) fprintf(stdout, str, v1, v2, v3, v4, v5, v6, v7, v8); LOG0
#define LOG9(str, v1, v2, v3, v4, v5, v6, v7, v8, v9) fprintf(stdout, str, v1, v2, v3, v4, v5, v6, v7, v8, v9); LOG0
#define LOGCH(ix) LOG1("%c", ix); LOG0
#define EXTCH(ix) LOG("\016"); LOG1("%c", ix); LOG("\017"); LOG0
#define LOGSPACE LOGCH(SPACE);
// ^ maybe one day this will be deprecated
#define LOGNEWLINE LOGCH(NEWLINE);
#define _ LOGNEWLINE;
#define _tab LOGCH(TAB);
#define _t _tab
#define _leftspace MOVELEFT(1);
#define _ls _leftspace
// _s for space when _s() is differentiated
#define LOGNL(str) LOG(str); _;
//#define LOGN(str) LOGNL(str); redefined below
#define LOGLINE(str) LOGNL(str);
// later LOGNEWLINE() function form
// LOGLINE() should consider padding options
// later -(str) -> LOGLINE(str)
// later E(str) can be ECHO(str)
#define ECHO(str) LOGLINE(str);
#define TOPREVLINE MOVEUP(1);
#define LO(str) printf(stdout, str);
#define LO1(str, v1) printf(stdout, str, v1);
#define LO2(str, v1, v2) printf(stdout, str, v1, v2);
#define LO3(str, v1, v2, v3) printf(stdout, str, v1, v2, v3);
#define LO4(str, v1, v2, v3, v4) printf(stdout, str, v1, v2, v3, v4);
#define LO5(str, v1, v2, v3, v4, v5) printf(stdout, str, v1, v2, v3, v4, v5);
#define LON(str) printf("%s%s", str, "\n")
#define LOGN(str) LON(str)
#define LORN(str) printf("%s%s", str, "\r\n")
#define LORN1i(str, v1) printf("%s%d%s", str, v1, "\r\n")
#define LORN1s(str, v1) printf("%s%s%s", str, v1, "\r\n")
#define LORN2s(str, v1, v2) printf("%s%s%s%s", str, v1, v2, "\r\n")
#define LORN1F(str, v1) printf(str"\r\n", v1)
#define LORN2F(str, v1, v2) printf(str"\r\n", v1, v2)
#define LORN3F(str, v1, v2, v3) printf(str"\r\n", v1, v2, v3)
// ^ cannot use dynamically allocated string for format due to concatenation
//#define OUT(str) LOG(str)
//#define OUT1(str, v1) LOG1(str, v1)
//#define OUT2(str, v1, v2) LOG2(str, v1, v2)
//#define OUT3(str, v1, v2, v3) LOG3(str, v1, v2, v3)
//#define OUT4(str, v1, v2, v3, v4) LOG4(str, v1, v2, v3, v4)
// ^ currently incompatible with cdat
#define ERR0 fflush(stderr);
#define ERR(str) fprintf(stderr, str); ERR0
#define ERR1(str, v1) fprintf(stderr, str, v1); ERR0
#define ERR2(str, v1, v2) fprintf(stderr, str, v1, v2); ERR0
#define ERR3(str, v1, v2, v3) fprintf(stderr, str, v1, v2, v3); ERR0
#define ERR4(str, v1, v2, v3, v4) fprintf(stderr, str, v1, v2, v3, v4); ERR0
#define WITHARGS IN argc, CH **argv
#define SHIFTARGS argc--; argv = &argv[1];
#define NOARGS argc < 1
#define SHIFT1(cval, varr) DEC1(cval); varr = AT1(varr);
#define SHIFT2(cval, varr) DEC2(cval); varr = AT2(varr);
#define SHIFT3(cval, varr) DEC3(cval); varr = AT3(varr);
#define SHIFT4(cval, varr) DEC4(cval); varr = AT4(varr);
#define SHIFT5(cval, varr) DEC5(cval); varr = AT5(varr);
#define SHIFT6(cval, varr) DEC6(cval); varr = AT6(varr);
//#define NEXTCH(cval) cval = AT1(cval);
//#define EATCH(cval) NEXTCH(cval)
#define EATCH(cval) cval = AT1(cval);
#define WRITEBUFCH(buf, bufi, bufsize, ch) \
buf[bufi] = ch; buf[INC bufi] = NUL; IF (bufi + 1 GQ bufsize) { bufi = bufsize - 2; }
#define CLEARBUF(buf, bufi) buf[bufi = 0] = NUL;
#define SHIFT_1 SHIFT1(argc, argv);
#define SHIFT_2 SHIFT2(argc, argv);
#define SHIFT_3 SHIFT3(argc, argv);
#define SHIFT_4 SHIFT4(argc, argv);
#define SHIFT_5 SHIFT5(argc, argv);
#define SHIFT_6 SHIFT6(argc, argv);
#define $$1 SHIFT_1
#define $$2 SHIFT_2
#define $$3 SHIFT_3
#define $$4 SHIFT_4
#define $$5 SHIFT_5
#define $$6 SHIFT_6
#define NEXTDARGCH(var) var = &var[1]; var[0] = '-';
#define NEXTDASHARGUMENTCHARACTER(var) NEXTDARGCH(var)
#define NextDashArgumentCharacter(var) NEXTDASHARGUMENTCHARACTER(var)
#define NEXT_ARGCH(var) var = &var[1]; var[0] = '_';
#define NEXT_ARGUMENTCHARACTER(var) NEXT_ARGCH(var)
#define NEXTUNDERSCOREARGUMENTCHARACTER(var) NEXT_ARGCH(var)
#define NextUnderscoreArgumentCharacter NEXTUNDERSCOREARGUMENTCHARACTER
#define WIEQDASHOR_(var) WI (var EQ DASH OR var EQ UNDERSCORE)
#define WIPARAM(var) WI (var NQNULL AND (var[0] EQ DASH OR var[0] EQ UNDERSCORE))
#define PARAMS \
IF ($1) { CLOG1("1:%s ", $1); }\
IF ($2) { CLOG1("2:%s ", $2); }\
IF ($3) { CLOG1("3:%s ", $3); }\
IF ($4) { CLOG1("4:%s ", $4); }\
IF ($5) { CLOG1("5:%s ", $5); }\
IF ($6) { CLOG1("6:%s ", $6); }\
IF ($7) { CLOG1("7:%s ", $7); }\
IF ($8) { CLOG1("8:%s ", $8); }\
IF ($9) { CLOG1("9:%s ", $9); }
#define ISSTRING(var) (var NQNULL AND var[0] NQNUL)
#define IsString(var) ISSTRING(var)
// later: this is that; and this (string) IS that (string);
// for now: IS(this, that);
//#define IS(this, that)
#define CSIS(this, that) CS that = this;
#define INIS(this, that) IN that = this;
#define $0 argv[0]
#define $1 argv[MIN2(argc, 1)]
#define $2 argv[MIN2(argc, 2)]
#define $3 argv[MIN2(argc, 3)]
#define $4 argv[MIN2(argc, 4)]
#define $5 argv[MIN2(argc, 5)]
#define $6 argv[MIN2(argc, 6)]
#define $N (argc - 1) // later, support $#
// #define $ IN argc, CS *argv
#define $ IN argc, CH **argv
#define AA 'A'
#define AB 'B'
#define AC 'C'
#define AD 'D'
#define AE 'E'
#define AF 'F'
#define AG 'G'
#define AH 'H'
#define AI 'I'
#define AJ 'J'
#define AK 'K'
#define AL 'L'
#define AM 'M'
#define AN 'N'
#define AO 'O'
#define AP 'P'
#define AQ 'Q'
#define AR 'R'
#define AS 'S'
//#define AT 'T' <--- this means AT, as in INTO & ADDRESS OF & .. currently
#define AU 'U'
#define AV 'V'
#define AW 'W'
#define AX 'X'
#define AY 'Y'
#define AZ 'Z'
#define Aa 'a'
#define Ab 'b'
#define Ac 'c'
#define Ad 'd'
#define Ae 'e'
#define Af 'f'
#define Ag 'g'
#define Ah 'h'
#define Ai 'i'
#define Aj 'j'
#define Ak 'k'
#define Al 'l'
#define Am 'm'
#define An 'n'
#define Ao 'o'
#define Ap 'p'
#define Aq 'q'
#define Ar 'r'
#define As 's'