/
table.cpp
1633 lines (1548 loc) · 41.5 KB
/
table.cpp
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
// vim:ts=4:sw=4:
// Interactive BASIC Compiler Project
// File: table.cpp - operator/command/function table source file
// Copyright (C) 2010-2015 Thunder422
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// For a copy of the GNU General Public License,
// see <http://www.gnu.org/licenses/>.
//
//
// Change History:
//
// 2010-02-18 initial version
#include <iostream>
#include <string>
#include <unordered_map>
#include <vector>
#include "table.h"
#include "token.h"
#include "utility.h"
#include "basic/basic.h"
// operands initializers
constexpr auto Operands_Dbl = {DataType::Double};
constexpr auto Operands_DblDbl = {DataType::Double, DataType::Double};
constexpr auto Operands_DblInt = {DataType::Double, DataType::Integer};
constexpr auto Operands_Int = {DataType::Integer};
constexpr auto Operands_IntDbl = {DataType::Integer, DataType::Double};
constexpr auto Operands_IntInt = {DataType::Integer, DataType::Integer};
constexpr auto Operands_Str = {DataType::String};
constexpr auto Operands_StrInt = {DataType::String, DataType::Integer};
constexpr auto Operands_StrStr = {DataType::String, DataType::String};
constexpr auto Operands_StrIntInt = {
DataType::String, DataType::Integer, DataType::Integer
};
constexpr auto Operands_StrStrInt = {
DataType::String, DataType::String, DataType::Integer
};
// expression information structure instances
static ExprInfo Null_ExprInfo;
static ExprInfo Dbl_None_ExprInfo(DataType::Double);
static ExprInfo Dbl_Dbl_ExprInfo(DataType::Double, Operands_Dbl);
static ExprInfo Dbl_DblDbl_ExprInfo(DataType::Double, Operands_DblDbl);
static ExprInfo Dbl_DblInt_ExprInfo(DataType::Double, Operands_DblInt);
static ExprInfo Dbl_Int_ExprInfo(DataType::Double, Operands_Int);
static ExprInfo Dbl_IntDbl_ExprInfo(DataType::Double, Operands_IntDbl);
static ExprInfo Dbl_Str_ExprInfo(DataType::Double, Operands_Str);
static ExprInfo Int_None_ExprInfo(DataType::Integer);
static ExprInfo Int_Dbl_ExprInfo(DataType::Integer, Operands_Dbl);
static ExprInfo Int_DblDbl_ExprInfo(DataType::Integer, Operands_DblDbl);
static ExprInfo Int_DblInt_ExprInfo(DataType::Integer, Operands_DblInt);
static ExprInfo Int_Int_ExprInfo(DataType::Integer, Operands_Int);
static ExprInfo Int_IntInt_ExprInfo(DataType::Integer, Operands_IntInt);
static ExprInfo Int_IntDbl_ExprInfo(DataType::Integer, Operands_IntDbl);
static ExprInfo Int_Str_ExprInfo(DataType::Integer, Operands_Str);
static ExprInfo Int_StrInt_ExprInfo(DataType::Integer, Operands_StrInt);
static ExprInfo Int_StrStr_ExprInfo(DataType::Integer, Operands_StrStr);
static ExprInfo Int_StrStrInt_ExprInfo(DataType::Integer, Operands_StrStrInt);
static ExprInfo Str_None_ExprInfo(DataType::String);
static ExprInfo Str_Dbl_ExprInfo(DataType::String, Operands_Dbl);
static ExprInfo Str_Int_ExprInfo(DataType::String, Operands_Int);
static ExprInfo Str_Str_ExprInfo(DataType::String, Operands_Str);
static ExprInfo Str_StrInt_ExprInfo(DataType::String, Operands_StrInt);
static ExprInfo Str_StrStr_ExprInfo(DataType::String, Operands_StrStr);
static ExprInfo Str_StrIntInt_ExprInfo(DataType::String, Operands_StrIntInt);
static ExprInfo Str_StrStrInt_ExprInfo(DataType::String, Operands_StrStrInt);
static ExprInfo None_Dbl_ExprInfo(DataType::None, Operands_Dbl);
static ExprInfo None_Int_ExprInfo(DataType::None, Operands_Int);
static ExprInfo None_Str_ExprInfo(DataType::None, Operands_Str);
Table::NameMap Table::s_nameToEntry; // name to code table map
std::unordered_map<TableEntry *, Table::EntryVectorArray> Table::s_alternate;
std::unordered_map<TableEntry *, DataType> Table::s_expectedDataType;
struct AlternateInfo
{
Code primaryCode; // primary code of alternates
int index; // alternate array index
std::initializer_list<Code> codes; // alternate codes
};
std::initializer_list<AlternateInfo> alternateInfo =
{
// assignment alternate codes
{Let_Code, 0, {Assign_Code}},
{Assign_Code, 0, {AssignInt_Code, AssignStr_Code}},
{Assign_Code, 1, {AssignList_Code}},
{AssignInt_Code, 1, {AssignListInt_Code}},
{AssignStr_Code, 0, {AssignKeepStr_Code}},
{AssignStr_Code, 1, {AssignListStr_Code}},
// sub-string assignment alternate codes
{Left_Code, 1, {AssignLeft_Code}},
{AssignLeft_Code, 0, {AssignKeepLeft_Code}},
{Mid2_Code, 1, {AssignMid2_Code}},
{AssignMid2_Code, 0, {AssignKeepMid2_Code}},
{Mid3_Code, 1, {AssignMid3_Code}},
{AssignMid3_Code, 0, {AssignKeepMid3_Code}},
{Right_Code, 1, {AssignRight_Code}},
{AssignRight_Code, 0, {AssignKeepRight_Code}},
// internal command alternate codes
{Input_Code, 0, {InputBegin_Code}},
{Input_Code, 1, {InputAssign_Code}},
{InputPrompt_Code, 0, {InputBeginStr_Code}},
{InputPrompt_Code, 1, {InputAssign_Code}},
{InputAssign_Code, 0, {InputAssignInt_Code, InputAssignStr_Code}},
{InputAssign_Code, 1, {InputParse_Code}},
{InputAssignInt_Code, 1, {InputParseInt_Code}},
{InputAssignStr_Code, 1, {InputParseStr_Code}},
{Print_Code, 0, {PrintDbl_Code}},
{PrintDbl_Code, 0, {PrintInt_Code, PrintStr_Code}},
{SemiColon_Code, 0, {Print_Code}},
// codes with operands alternate codes
{Const_Code, 0, {ConstInt_Code, ConstStr_Code}},
{Var_Code, 0, {VarInt_Code, VarStr_Code}},
{Var_Code, 1, {VarRef_Code}},
{VarRef_Code, 0, {VarRefInt_Code, VarRefStr_Code}},
{Array_Code, 0, {ArrayInt_Code, ArrayStr_Code}},
{DefFuncN_Code, 0, {DefFuncNInt_Code, DefFuncNStr_Code}},
{DefFuncP_Code, 0, {DefFuncPInt_Code, DefFuncPStr_Code}},
{Function_Code, 0, {FunctionInt_Code, FunctionStr_Code}}
};
// code enumeration names in comments after opening brace
// (code enumeration generated from these by enums.awk)
static TableEntry tableEntries[] =
{
// Code{} entry at beginning because Code{} == 0
{ // Code{}
Type{},
"", "NULL", "",
TableFlag{}, 0, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
//--------------
// Commands
//--------------
{ // Let_Code
Type::Command,
"LET", "", "",
TableFlag{}, 4, &Null_ExprInfo,
letTranslate, NULL, NULL, NULL, NULL
},
{ // Print_Code
Type::Command,
"PRINT", "", "",
TableFlag{}, 4, &Null_ExprInfo,
printTranslate, NULL, NULL, NULL, printRecreate
},
{ // Input_Code
Type::Command,
"INPUT", "", "Keep",
Two_Flag, 4, &Null_ExprInfo,
inputTranslate, NULL, NULL, NULL, inputRecreate
},
{ // InputPrompt_Code
Type::Command,
"INPUT", "PROMPT", "Keep",
Two_Flag, 4, &Null_ExprInfo,
inputTranslate, NULL, NULL, NULL, inputRecreate
},
{ // Dim_Code
Type::Command,
"DIM", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Def_Code
Type::Command,
"DEF", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Rem_Code
Type::Command,
"REM", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, remEncode, remOperandText, remRemove, remRecreate
},
{ // If_Code
Type::Command,
"IF", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Then_Code
Type::Command,
"THEN", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Else_Code
Type::Command,
"ELSE", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // End_Code
Type::Command,
"END", "", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // EndIf_Code
Type::Command,
"END", "IF", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // For_Code
Type::Command,
"FOR", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // To_Code
Type::Command,
"TO", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Step_Code
Type::Command,
"STEP", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Next_Code
Type::Command,
"NEXT", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Do_Code
Type::Command,
"DO", "", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // DoWhile_Code
Type::Command,
"DO", "WHILE", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // DoUntil_Code
Type::Command,
"DO", "UNTIL", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // While_Code
Type::Command,
"WHILE", "", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Until_Code
Type::Command,
"UNTIL", "", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // Loop_Code
Type::Command,
"LOOP", "", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // LoopWhile_Code
Type::Command,
"LOOP", "WHILE", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // LoopUntil_Code
Type::Command,
"LOOP", "UNTIL", "",
Two_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
//-----------------------------------------
// Internal Functions (No Parentheses)
//-----------------------------------------
{ // Rnd_Code
Type::IntFunc,
"RND", "", "",
TableFlag{}, 2, &Dbl_None_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
//--------------------
// Word Operators
//--------------------
{ // Mod_Code
Type::Operator,
"MOD", "", "",
TableFlag{}, 42, &Dbl_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // And_Code
Type::Operator,
"AND", "", "",
TableFlag{}, 18, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Or_Code
Type::Operator,
"OR", "", "",
TableFlag{}, 14, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Not_Code
Type::Operator,
"NOT", "", "",
TableFlag{}, 20, &Int_Int_ExprInfo,
NULL, NULL, NULL, NULL, unaryOperatorRecreate
},
{ // Eqv_Code
Type::Operator,
"EQV", "", "",
TableFlag{}, 12, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Imp_Code
Type::Operator,
"IMP", "", "",
TableFlag{}, 10, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Xor_Code
Type::Operator,
"XOR", "", "",
TableFlag{}, 16, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
//--------------------------------------
// INTERNAL FUNCTIONS (Parentheses)
//--------------------------------------
{ // Abs_Code
Type::IntFunc,
"ABS(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Fix_Code
Type::IntFunc,
"FIX(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Frac_Code
Type::IntFunc,
"FRAC(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Int_Code
Type::IntFunc,
"INT(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // RndArg_Code
Type::IntFunc,
"RND(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Sgn_Code
Type::IntFunc,
"SGN(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Cint_Code
Type::IntFunc,
"CINT(", "", "",
TableFlag{}, 2, &Int_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Cdbl_Code
Type::IntFunc,
"CDBL(", "", "",
TableFlag{}, 2, &Dbl_Int_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Sqr_Code
Type::IntFunc,
"SQR(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Atn_Code
Type::IntFunc,
"ATN(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Cos_Code
Type::IntFunc,
"COS(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Sin_Code
Type::IntFunc,
"SIN(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Tan_Code
Type::IntFunc,
"TAN(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Exp_Code
Type::IntFunc,
"EXP(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Log_Code
Type::IntFunc,
"LOG(", "", "",
TableFlag{}, 2, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Tab_Code
Type::IntFunc,
"TAB(", "", "",
Print_Flag, 2, &None_Int_ExprInfo,
NULL, NULL, NULL, NULL, printFunctionRecreate
},
{ // Spc_Code
Type::IntFunc,
"SPC(", "", "",
Print_Flag, 2, &None_Int_ExprInfo,
NULL, NULL, NULL, NULL, printFunctionRecreate
},
{ // Asc_Code
Type::IntFunc,
"ASC(", "", "",
TableFlag{}, 2, &Int_Str_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Asc2_Code
Type::IntFunc,
"ASC(", "2", "",
TableFlag{}, 2, &Int_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Chr_Code
Type::IntFunc,
"CHR$(", "", "",
TableFlag{}, 2, &Str_Int_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Instr2_Code
Type::IntFunc,
"INSTR(", "2", "",
TableFlag{}, 2, &Int_StrStr_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Instr3_Code
Type::IntFunc,
"INSTR(", "3", "",
TableFlag{}, 2, &Int_StrStrInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Left_Code
Type::IntFunc,
"LEFT$(", "", "",
SubStr_Flag, 2, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Len_Code
Type::IntFunc,
"LEN(", "", "",
TableFlag{}, 2, &Int_Str_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Mid2_Code
Type::IntFunc,
"MID$(", "2", "",
SubStr_Flag, 2, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Mid3_Code
Type::IntFunc,
"MID$(", "3", "",
SubStr_Flag, 2, &Str_StrIntInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Repeat_Code
Type::IntFunc,
"REPEAT$(", "", "",
TableFlag{}, 2, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Right_Code
Type::IntFunc,
"RIGHT$(", "", "",
SubStr_Flag, 2, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Space_Code
Type::IntFunc,
"SPACE$(", "", "",
TableFlag{}, 2, &Str_Int_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Str_Code
Type::IntFunc,
"STR$(", "", "",
TableFlag{}, 2, &Str_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
{ // Val_Code
Type::IntFunc,
"VAL(", "", "",
TableFlag{}, 2, &Dbl_Str_ExprInfo,
NULL, NULL, NULL, NULL, internalFunctionRecreate
},
//----------------------
// Symbol Operators
//----------------------
{ // Add_Code
Type::Operator,
"+", "", "",
TableFlag{}, 40, &Dbl_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Neg_Code
Type::Operator,
"-", "U", "",
UseConstAsIs_Flag, 48, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, unaryOperatorRecreate
},
{ // Mul_Code
Type::Operator,
"*", "", "",
TableFlag{}, 46, &Dbl_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Div_Code
Type::Operator,
"/", "", "",
TableFlag{}, 46, &Dbl_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // IntDiv_Code
Type::Operator,
"\\", "", "",
TableFlag{}, 44, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Power_Code
Type::Operator,
"^", "", "",
UseConstAsIs_Flag, 50, &Dbl_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Eq_Code
Type::Operator,
"=", "", "",
TableFlag{}, 30, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Gt_Code
Type::Operator,
">", "", "",
Two_Flag, 32, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtEq_Code
Type::Operator,
">=", "", "",
TableFlag{}, 32, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Lt_Code
Type::Operator,
"<", "", "",
Two_Flag, 32, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // LtEq_Code
Type::Operator,
"<=", "", "",
TableFlag{}, 32, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // NotEq_Code
Type::Operator,
"<>", "", "",
Two_Flag, 30, &Int_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // OpenParen_Code
Type::Operator,
"(", "", "",
TableFlag{}, 2, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // CloseParen_Code
Type::Operator,
")", "", "",
TableFlag{}, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, parenRecreate
},
{ // Comma_Code
Type::Operator,
",", "", "",
Command_Flag, 6, &Null_ExprInfo,
NULL, NULL, NULL, NULL, printCommaRecreate
},
{ // SemiColon_Code
Type::Operator,
";", "", "",
Command_Flag, 6, &Null_ExprInfo,
NULL, NULL, NULL, NULL, printSemicolonRecreate
},
{ // Colon_Code
Type::Operator,
":", "", "",
EndStmt_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // RemOp_Code
Type::Operator,
"'", "", "",
EndStmt_Flag, 2, &Null_ExprInfo,
NULL, remEncode, remOperandText, remRemove, remRecreate
},
//***************************
// MISCELLANEOUS ENTRIES
//***************************
{ // Assign_Code
Type{},
"=", "Assign", "LET",
Reference_Flag | Command_Flag, 4, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, assignRecreate
},
{ // AssignInt_Code
Type{},
"=", "Assign%", "LET",
Reference_Flag | Command_Flag, 4, &Int_Int_ExprInfo,
NULL, NULL, NULL, NULL, assignRecreate
},
{ // AssignStr_Code
Type{},
"=", "Assign$", "LET",
Reference_Flag | Command_Flag, 4, &Str_Str_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignLeft_Code
Type{},
"LEFT$(", "Assign", "LET",
Reference_Flag | SubStr_Flag | Command_Flag, 4, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignMid2_Code
Type{},
"MID$(", "Assign2", "LET",
Reference_Flag | SubStr_Flag | Command_Flag, 4, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignMid3_Code
Type{},
"MID$(", "Assign3", "LET",
Reference_Flag | SubStr_Flag | Command_Flag, 4, &Str_StrIntInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignRight_Code
Type{},
"RIGHT$(", "Assign", "LET",
Reference_Flag | SubStr_Flag, 4, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignList_Code
Type{},
"=", "AssignList", "LET",
Reference_Flag | Command_Flag, 4, &Dbl_Dbl_ExprInfo,
NULL, NULL, NULL, NULL, assignRecreate
},
{ // AssignListInt_Code
Type{},
"=", "AssignList%", "LET",
Reference_Flag | Command_Flag, 4, &Int_Int_ExprInfo,
NULL, NULL, NULL, NULL, assignRecreate
},
{ // AssignListStr_Code
Type{},
"=", "AssignList$", "LET",
Reference_Flag | Command_Flag, 4, &Str_Str_ExprInfo,
NULL, NULL, NULL, NULL, assignRecreate
},
{ // AssignKeepStr_Code
Type{},
"", "AssignKeep$", "LET",
Reference_Flag | Keep_Flag, 4, &Str_Str_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignKeepLeft_Code
Type{},
"LEFT$(", "AssignKeep", "LET",
Reference_Flag | SubStr_Flag | Keep_Flag, 4, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignKeepMid2_Code
Type{},
"MID$(", "AssignKeep2", "LET",
Reference_Flag | SubStr_Flag | Keep_Flag, 4, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignKeepMid3_Code
Type{},
"MID$(", "AssignKeep3", "LET",
Reference_Flag | SubStr_Flag | Keep_Flag, 4, &Str_StrStrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // AssignKeepRight_Code
Type{},
"RIGHT$(", "AssignKeep", "LET",
Reference_Flag | SubStr_Flag | Keep_Flag, 4, &Str_StrInt_ExprInfo,
NULL, NULL, NULL, NULL, assignStrRecreate
},
{ // EOL_Code
Type::Operator,
"", "EOL", "",
EndStmt_Flag, 4, &Null_ExprInfo,
NULL, NULL, NULL, NULL, NULL
},
{ // AddI1_Code
Type::Operator,
"+", "%1", "",
TableFlag{}, 40, &Dbl_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // AddI2_Code
Type::Operator,
"+", "%2", "",
TableFlag{}, 40, &Dbl_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // AddInt_Code
Type::Operator,
"+", "%", "",
TableFlag{}, 40, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // CatStr_Code
Type::Operator,
"+", "$", "",
TableFlag{}, 40, &Str_StrStr_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // Sub_Code
Type::Operator,
"-", "", "",
TableFlag{}, 40, &Dbl_DblDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // SubI1_Code
Type::Operator,
"-", "%1", "",
TableFlag{}, 40, &Dbl_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // SubI2_Code
Type::Operator,
"-", "%2", "",
TableFlag{}, 40, &Dbl_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // SubInt_Code
Type::Operator,
"-", "%", "",
TableFlag{}, 40, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // NegInt_Code
Type::Operator,
"-", "U%", "",
TableFlag{}, 48, &Int_Int_ExprInfo,
NULL, NULL, NULL, NULL, unaryOperatorRecreate
},
{ // MulI1_Code
Type::Operator,
"*", "%1", "",
TableFlag{}, 46, &Dbl_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // MulI2_Code
Type::Operator,
"*", "%2", "",
TableFlag{}, 46, &Dbl_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // MulInt_Code
Type::Operator,
"*", "%", "",
TableFlag{}, 46, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // DivI1_Code
Type::Operator,
"/", "%1", "",
TableFlag{}, 46, &Dbl_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // DivI2_Code
Type::Operator,
"/", "%2", "",
TableFlag{}, 46, &Dbl_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // DivInt_Code
Type::Operator,
"/", "%", "",
TableFlag{}, 46, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // ModI1_Code
Type::Operator,
"MOD", "%1", "",
TableFlag{}, 42, &Dbl_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // ModI2_Code
Type::Operator,
"MOD", "%2", "",
TableFlag{}, 42, &Dbl_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // ModInt_Code
Type::Operator,
"MOD", "%", "",
TableFlag{}, 42, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // PowerI1_Code
Type::Operator,
"^", "%1", "",
TableFlag{}, 50, &Dbl_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // PowerMul_Code
Type::Operator,
"^", "*", "",
TableFlag{}, 50, &Dbl_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // PowerInt_Code
Type::Operator,
"^", "%", "",
TableFlag{}, 50, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // EqI1_Code
Type::Operator,
"=", "%1", "",
TableFlag{}, 30, &Int_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // EqI2_Code
Type::Operator,
"=", "%2", "",
TableFlag{}, 30, &Int_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // EqInt_Code
Type::Operator,
"=", "%", "",
TableFlag{}, 30, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // EqStr_Code
Type::Operator,
"=", "$", "",
TableFlag{}, 30, &Int_StrStr_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtI1_Code
Type::Operator,
">", "%1", "",
TableFlag{}, 32, &Int_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtI2_Code
Type::Operator,
">", "%2", "",
TableFlag{}, 32, &Int_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtInt_Code
Type::Operator,
">", "%", "",
TableFlag{}, 32, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtStr_Code
Type::Operator,
">", "$", "",
TableFlag{}, 32, &Int_StrStr_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtEqI1_Code
Type::Operator,
">=", "%1", "",
TableFlag{}, 32, &Int_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtEqI2_Code
Type::Operator,
">=", "%2", "",
TableFlag{}, 32, &Int_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtEqInt_Code
Type::Operator,
">=", "%", "",
TableFlag{}, 32, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // GtEqStr_Code
Type::Operator,
">=", "$", "",
TableFlag{}, 32, &Int_StrStr_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // LtI1_Code
Type::Operator,
"<", "%1", "",
TableFlag{}, 32, &Int_IntDbl_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // LtI2_Code
Type::Operator,
"<", "%2", "",
TableFlag{}, 32, &Int_DblInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},
{ // LtInt_Code
Type::Operator,
"<", "%", "",
TableFlag{}, 32, &Int_IntInt_ExprInfo,
NULL, NULL, NULL, NULL, binaryOperatorRecreate
},