/
table.cpp
1734 lines (1616 loc) · 51.4 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-2013 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 <QChar>
#include <QString>
#include "table.h"
#include "commandhandlers.h"
#include "tokenhandlers.h"
#include "basic/commands.h"
const int MaxOperands = 3;
// this value contains the maximum number of operands
// (arguments) for any operator or internal function (there are currently
// no internal function with more than 3 arguments)
const int MaxAssocCodes = 4;
// this value contains the maximum number of associated codes,
// codes in additional to the main code for different possible data types
// for the code (no code currently has more the 3 total codes)
// array of conversion codes [have data type] [need data type]
static Code cvtCodeHaveNeed[sizeof_DataType][sizeof_DataType] = {
{ // have Double, need:
Null_Code, // Double
CvtInt_Code, // Integer
Invalid_Code, // String
Invalid_Code, // SubStr (FIXME this data will be removed)
Null_Code, // None
Null_Code, // Number
Null_Code // Any
},
{ // have Integer, need:
CvtDbl_Code, // Double
Null_Code, // Integer
Invalid_Code, // String
Invalid_Code, // SubStr (FIXME this data will be removed)
Null_Code, // None
Null_Code, // Number
Null_Code // Any
},
{ // have String, need:
Invalid_Code, // Double
Invalid_Code, // Integer
Null_Code, // String
Null_Code, // SubStr (FIXME this data will be removed)
Null_Code, // None
Invalid_Code, // Number
Null_Code // Any
},
{ // have SubStr, need: (FIXME this data will be removed)
Invalid_Code, // Double
Invalid_Code, // Integer
Null_Code, // String
Null_Code, // SubStr
Null_Code, // None
Invalid_Code, // Number
Null_Code // Any
},
{ // have None, need: (print functions have this data type)
Invalid_Code, // Double
Invalid_Code, // Integer
Invalid_Code, // String
Invalid_Code, // SubStr (FIXME this data will be removed)
Null_Code, // None (print function allowed if needed None)
Invalid_Code, // Number
Invalid_Code // Any
},
{ // have Number, need: (will not have any of this data type)
Invalid_Code, // Double
Invalid_Code, // Integer
Invalid_Code, // String
Invalid_Code, // SubStr (FIXME this data will be removed)
Invalid_Code, // None
Invalid_Code, // Number
Invalid_Code // Any
},
{ // have Any, need: (will not have any of this data type)
Invalid_Code, // Double
Invalid_Code, // Integer
Invalid_Code, // String
Invalid_Code, // SubStr (FIXME this data will be removed)
Invalid_Code, // None
Invalid_Code, // Number
Invalid_Code // Any
}
};
// expression information for operators and internal functions
struct ExprInfo
{
Code m_unaryCode; // operator unary code (Null_Code if none)
short m_nOperands; // number of operands (operators/functions)
short m_nAssocCodes; // number of associated codes
short m_assoc2Index; // second operand assoc codes start index
DataType *m_operandDataType; // data type of each operand
Code *m_assocCode; // associated codes
DataType m_expectedDataType; // expected data type of next operand
ExprInfo(Code unaryCode = Null_Code, short nOperands = 0,
DataType *operandDataType = NULL, short nAssocCodes = 0,
short assoc2Index = 0, Code *assocCode = NULL,
DataType expectedDataType = None_DataType) :
m_unaryCode(unaryCode), m_nOperands(nOperands),
m_operandDataType(operandDataType), m_nAssocCodes(nAssocCodes),
m_assoc2Index(assoc2Index), m_assocCode(assocCode),
m_expectedDataType(expectedDataType)
{
}
};
struct TableEntry
{
TokenType type; // type of token for entry
Multiple multiple; // multiple word command/character operator
const QString name; // name for table entry
const QString name2; // name of second word of command
int flags; // flags for entry
int precedence; // precedence of code
DataType dataType; // next expression data type for command
ExprInfo *exprInfo; // expression info pointer (NULL for none)
TokenHandler tokenHandler; // translator token handler pointer
TokenMode tokenMode; // next token mode for command
CommandHandler commandHandler; // translator command handler pointer
TranslateFunction translate; // pointer to translate function
};
Table *Table::s_instance; // pointer to single table instance
QStringList Table::s_errorList; // list of errors found during initialize
// this macro produces two entries for the ExprInfo constructor,
// one for the number of operands, one for the pointer to the
// operand data type array
#define Operands(type) (sizeof(type ## _OperandArray) \
/ sizeof(type ## _OperandArray[0])), type ## _OperandArray
// macro produces associated code fields for table entries
#define AssocCode(code) (sizeof(code ## _AssocCode) \
/ sizeof(code ## _AssocCode[0])), 0, code ## _AssocCode
// macro produces associated code fields with secondary index for table entries
#define AssocCode2(code, index2) (sizeof(code ## _AssocCode) \
/ sizeof(code ## _AssocCode[0])), index2, code ## _AssocCode
// operand data type arrays
static DataType Dbl_OperandArray[] = {
Double_DataType
};
static DataType DblDbl_OperandArray[] = {
Double_DataType, Double_DataType
};
static DataType DblInt_OperandArray[] = {
Double_DataType, Integer_DataType
};
static DataType Int_OperandArray[] = {
Integer_DataType
};
static DataType IntDbl_OperandArray[] = {
Integer_DataType, Double_DataType
};
static DataType IntInt_OperandArray[] = {
Integer_DataType, Integer_DataType
};
static DataType Str_OperandArray[] = {
String_DataType
};
static DataType StrInt_OperandArray[] = {
String_DataType, Integer_DataType
};
static DataType StrIntInt_OperandArray[] = {
String_DataType, Integer_DataType, Integer_DataType
};
static DataType StrStr_OperandArray[] = {
String_DataType, String_DataType
};
static DataType StrStrInt_OperandArray[] = {
String_DataType, String_DataType, Integer_DataType
};
static DataType Sub_OperandArray[] = {
SubStr_DataType
};
static DataType SubStr_OperandArray[] = {
SubStr_DataType, String_DataType
};
// associated code data type arrays
static Code Abs_AssocCode[] = {AbsInt_Code};
static Code Add_AssocCode[] = {
AddI1_Code, CatStr_Code, AddI2_Code
};
static Code AddI1_AssocCode[] = {AddInt_Code};
static Code Assign_AssocCode[] = {
AssignInt_Code, AssignStr_Code, AssignSubStr_Code, AssignList_Code
};
static Code AssignLeft_AssocCode[] = {AssignKeepLeft_Code};
static Code AssignList_AssocCode[] = {
AssignListInt_Code, AssignListStr_Code, AssignListMix_Code
};
static Code AssignInt_AssocCode[] = {AssignListInt_Code};
static Code AssignMid2_AssocCode[] = {AssignKeepMid2_Code};
static Code AssignMid3_AssocCode[] = {AssignKeepMid3_Code};
static Code AssignRight_AssocCode[] = {AssignKeepRight_Code};
static Code AssignStr_AssocCode[] = {
AssignKeepStr_Code, AssignListStr_Code
};
static Code Div_AssocCode[] = {DivI1_Code, DivI2_Code};
static Code DivI1_AssocCode[] = {DivInt_Code};
static Code Eq_AssocCode[] = {
EqI1_Code, EqStr_Code, EqI2_Code
};
static Code EqI1_AssocCode[] = {EqInt_Code};
static Code Gt_AssocCode[] = {
GtI1_Code, GtStr_Code, GtI2_Code
};
static Code GtI1_AssocCode[] = {GtInt_Code};
static Code GtEq_AssocCode[] = {
GtEqI1_Code, GtEqStr_Code, GtEqI2_Code
};
static Code GtEqI1_AssocCode[] = {GtEqInt_Code};
static Code InputAssign_AssocCode[] = {
InputAssignInt_Code, InputAssignStr_Code, InputParse_Code
};
static Code InputAssignInt_AssocCode[] = {InputParseInt_Code};
static Code InputAssignStr_AssocCode[] = {InputParseStr_Code};
static Code Left_AssocCode[] = {AssignLeft_Code};
static Code Lt_AssocCode[] = {
LtI1_Code, LtStr_Code, LtI2_Code
};
static Code LtI1_AssocCode[] = {LtInt_Code};
static Code LtEq_AssocCode[] = {
LtEqI1_Code, LtEqStr_Code, LtEqI2_Code
};
static Code LtEqI1_AssocCode[] = {LtEqInt_Code};
static Code Mid2_AssocCode[] = {AssignMid2_Code};
static Code Mid3_AssocCode[] = {AssignMid3_Code};
static Code Mod_AssocCode[] = {ModI1_Code, ModI2_Code};
static Code ModI1_AssocCode[] = {ModInt_Code};
static Code Mul_AssocCode[] = {MulI1_Code, MulI2_Code};
static Code MulI1_AssocCode[] = {MulInt_Code};
static Code Neg_AssocCode[] = {NegInt_Code};
static Code NotEq_AssocCode[] = {
NotEqI1_Code, NotEqStr_Code, NotEqI2_Code
};
static Code NotEqI1_AssocCode[] = {NotEqInt_Code};
static Code Power_AssocCode[] = {PowerI1_Code, PowerMul_Code};
static Code PowerI1_AssocCode[] = {PowerInt_Code};
static Code Print_AssocCode[] = {
PrintInt_Code, PrintStr_Code
};
static Code Right_AssocCode[] = {AssignRight_Code};
static Code RndArgs_AssocCode[] = {RndArgInt_Code};
static Code Sgn_AssocCode[] = {SgnInt_Code};
static Code Str_AssocCode[] = {StrInt_Code};
static Code Sub_AssocCode[] = {SubI1_Code, SubI2_Code};
static Code SubI1_AssocCode[] = {SubInt_Code};
// standard expression information structures
static ExprInfo Dbl_ExprInfo(Null_Code, Operands(Dbl));
static ExprInfo DblDbl_ExprInfo(Null_Code, Operands(DblDbl));
static ExprInfo DblInt_ExprInfo(Null_Code, Operands(DblInt));
static ExprInfo Int_ExprInfo(Null_Code, Operands(Int));
static ExprInfo IntInt_ExprInfo(Null_Code, Operands(IntInt));
static ExprInfo Str_ExprInfo(Null_Code, Operands(Str));
static ExprInfo StrInt_ExprInfo(Null_Code, Operands(StrInt));
static ExprInfo StrStr_ExprInfo(Null_Code, Operands(StrStr));
static ExprInfo StrStrInt_ExprInfo(Null_Code, Operands(StrStrInt));
static ExprInfo StrIntInt_ExprInfo(Null_Code, Operands(StrIntInt));
// code enumeration names in comments after opening brace
// (code enumeration generated from these by enums.awk)
static TableEntry tableEntries[] =
{
// Null_Code entry at beginning so Null_Code == 0
{ // Null_Code
Operator_TokenType, OneWord_Multiple,
"", "NULL"
},
//***********************
// BEGIN PLAIN WORDS
//***********************
{ // BegPlainWord_Code
Error_TokenType
},
//--------------
// Commands
//--------------
{ // Let_Code
Command_TokenType, OneWord_Multiple,
"LET", NULL, Null_Flag, 4, None_DataType, NULL, NULL,
Assignment_TokenMode, Let_CmdHandler, letTranslate
},
{ // Print_Code
Command_TokenType, OneWord_Multiple,
"PRINT", NULL, Null_Flag, 4, None_DataType, NULL, NULL,
Expression_TokenMode, Print_CmdHandler, printTranslate
},
{ // Input_Code
Command_TokenType, TwoWord_Multiple,
"INPUT", NULL, Null_Flag, 4, None_DataType, NULL, NULL,
Reference_TokenMode, Input_CmdHandler
},
{ // InputPrompt_Code
Command_TokenType, TwoWord_Multiple,
"INPUT", "PROMPT", Null_Flag, 4, String_DataType, NULL, NULL,
Expression_TokenMode, Input_CmdHandler
},
{ // Dim_Code
Command_TokenType, OneWord_Multiple,
"DIM", NULL, Null_Flag, 4, None_DataType
},
{ // Def_Code
Command_TokenType, OneWord_Multiple,
"DEF", NULL, Null_Flag, 4, None_DataType
},
{ // Rem_Code
Command_TokenType, OneWord_Multiple,
"REM", NULL, Null_Flag, 4, None_DataType, NULL, NULL,
Command_TokenMode, Rem_CmdHandler
},
{ // If_Code
Command_TokenType, OneWord_Multiple,
"IF", NULL, Null_Flag, 4, None_DataType
},
{ // Then_Code
Command_TokenType, OneWord_Multiple,
"THEN", NULL, Null_Flag, 4, None_DataType
},
{ // Else_Code
Command_TokenType, OneWord_Multiple,
"ELSE", NULL, Null_Flag, 4, None_DataType
},
{ // End_Code
Command_TokenType, TwoWord_Multiple,
"END", NULL, Null_Flag, 4, None_DataType
},
{ // EndIf_Code
Command_TokenType, TwoWord_Multiple,
"END", "IF", Null_Flag, 4, None_DataType
},
{ // For_Code
Command_TokenType, OneWord_Multiple,
"FOR", NULL, Null_Flag, 4, None_DataType
},
{ // To_Code
Command_TokenType, OneWord_Multiple,
"TO", NULL, Null_Flag, 4, None_DataType
},
{ // Step_Code
Command_TokenType, OneWord_Multiple,
"STEP", NULL, Null_Flag, 4, None_DataType
},
{ // Next_Code
Command_TokenType, OneWord_Multiple,
"NEXT", NULL, Null_Flag, 4, None_DataType
},
{ // Do_Code
Command_TokenType, TwoWord_Multiple,
"DO", NULL, Null_Flag, 4, None_DataType
},
{ // DoWhile_Code
Command_TokenType, TwoWord_Multiple,
"DO", "WHILE", Null_Flag, 4, None_DataType
},
{ // DoUntil_Code
Command_TokenType, TwoWord_Multiple,
"DO", "UNTIL", Null_Flag, 4, None_DataType
},
{ // While_Code
Command_TokenType, TwoWord_Multiple,
"WHILE", NULL, Null_Flag, 4, None_DataType
},
{ // Until_Code
Command_TokenType, TwoWord_Multiple,
"UNTIL", NULL, Null_Flag, 4, None_DataType
},
{ // Loop_Code
Command_TokenType, TwoWord_Multiple,
"LOOP", NULL, Null_Flag, 4, None_DataType
},
{ // LoopWhile_Code
Command_TokenType, TwoWord_Multiple,
"LOOP", "WHILE", Null_Flag, 4, None_DataType
},
{ // LoopUntil_Code
Command_TokenType, TwoWord_Multiple,
"LOOP", "UNTIL", Null_Flag, 4, None_DataType
},
//-----------------------------------------
// Internal Functions (No Parentheses)
//-----------------------------------------
{ // Rnd_Code
IntFuncN_TokenType, OneWord_Multiple,
"RND", NULL, Null_Flag, 2, Double_DataType, new ExprInfo()
},
//--------------------
// Word Operators
//--------------------
{ // Mod_Code
Operator_TokenType, OneWord_Multiple,
"MOD", NULL, Null_Flag, 42, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Mod, 1))
},
{ // And_Code
Operator_TokenType, OneWord_Multiple,
"AND", NULL, Null_Flag, 18, Integer_DataType, &IntInt_ExprInfo
},
{ // Or_Code
Operator_TokenType, OneWord_Multiple,
"OR", NULL, Null_Flag, 14, Integer_DataType, &IntInt_ExprInfo
},
{ // Not_Code
Operator_TokenType, OneWord_Multiple,
"NOT", NULL, Null_Flag, 20, Integer_DataType,
new ExprInfo(Not_Code, Operands(Int))
},
{ // Eqv_Code
Operator_TokenType, OneWord_Multiple,
"EQV", NULL, Null_Flag, 12, Integer_DataType, &IntInt_ExprInfo
},
{ // Imp_Code
Operator_TokenType, OneWord_Multiple,
"IMP", NULL, Null_Flag, 10, Integer_DataType, &IntInt_ExprInfo
},
{ // Xor_Code
Operator_TokenType, OneWord_Multiple,
"XOR", NULL, Null_Flag, 16, Integer_DataType, &IntInt_ExprInfo
},
//*********************
// END PLAIN WORDS
//*********************
{ // EndPlainWord_Code
Error_TokenType
},
//*****************************
// BEGIN PARENTHESES WORDS
//*****************************
{ // BegParenWord_Code
Error_TokenType
},
//--------------------------------------
// INTERNAL FUNCTIONS (Parentheses)
//--------------------------------------
{ // Abs_Code
IntFuncP_TokenType, OneWord_Multiple,
"ABS(", NULL, Null_Flag, 2, Double_DataType,
new ExprInfo(Null_Code, Operands(Dbl), AssocCode(Abs))
},
{ // Fix_Code
IntFuncP_TokenType, OneWord_Multiple,
"FIX(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Frac_Code
IntFuncP_TokenType, OneWord_Multiple,
"FRAC(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Int_Code
IntFuncP_TokenType, OneWord_Multiple,
"INT(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // RndArg_Code
IntFuncP_TokenType, OneWord_Multiple,
"RND(", NULL, Null_Flag, 2, Double_DataType,
new ExprInfo(Null_Code, Operands(Dbl), AssocCode(RndArgs))
},
{ // Sgn_Code
IntFuncP_TokenType, OneWord_Multiple,
"SGN(", NULL, Null_Flag, 2, Double_DataType,
new ExprInfo(Null_Code, Operands(Dbl), AssocCode(Sgn))
},
{ // Cint_Code
IntFuncP_TokenType, OneWord_Multiple,
"CINT(", NULL, Null_Flag, 2, Integer_DataType, &Dbl_ExprInfo
},
{ // Cdbl_Code
IntFuncP_TokenType, OneWord_Multiple,
"CDBL(", NULL, Null_Flag, 2, Double_DataType, &Int_ExprInfo
},
{ // Sqr_Code
IntFuncP_TokenType, OneWord_Multiple,
"SQR(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Atn_Code
IntFuncP_TokenType, OneWord_Multiple,
"ATN(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Cos_Code
IntFuncP_TokenType, OneWord_Multiple,
"COS(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Sin_Code
IntFuncP_TokenType, OneWord_Multiple,
"SIN(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Tan_Code
IntFuncP_TokenType, OneWord_Multiple,
"TAN(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Exp_Code
IntFuncP_TokenType, OneWord_Multiple,
"EXP(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Log_Code
IntFuncP_TokenType, OneWord_Multiple,
"LOG(", NULL, Null_Flag, 2, Double_DataType, &Dbl_ExprInfo
},
{ // Tab_Code
IntFuncP_TokenType, OneWord_Multiple,
"TAB(", NULL, Print_Flag, 2, None_DataType, &Int_ExprInfo
},
{ // Spc_Code
IntFuncP_TokenType, OneWord_Multiple,
"SPC(", NULL, Print_Flag, 2, None_DataType, &Int_ExprInfo
},
{ // Asc_Code
IntFuncP_TokenType, OneWord_Multiple,
"ASC(", NULL, Multiple_Flag, 2, Integer_DataType,
new ExprInfo(Null_Code, Operands(Str))
},
{ // Asc2_Code
IntFuncP_TokenType, OneWord_Multiple,
"ASC(", "ASC2(", Null_Flag, 2, Integer_DataType,
new ExprInfo(Null_Code, Operands(StrInt))
},
{ // Chr_Code
IntFuncP_TokenType, OneWord_Multiple,
"CHR$(", NULL, Null_Flag, 2, String_DataType, &Int_ExprInfo
},
{ // Instr2_Code
IntFuncP_TokenType, OneWord_Multiple,
"INSTR(", "INSTR2(", Multiple_Flag, 2, Integer_DataType,
&StrStr_ExprInfo
},
{ // Instr3_Code
IntFuncP_TokenType, OneWord_Multiple,
"INSTR(", "INSTR3(", Null_Flag, 2, Integer_DataType,
new ExprInfo(Null_Code, Operands(StrStrInt))
},
{ // Left_Code
IntFuncP_TokenType, OneWord_Multiple,
"LEFT$(", NULL, SubStr_Flag, 2, SubStr_DataType,
new ExprInfo(Null_Code, Operands(StrInt), AssocCode2(Left, -1))
},
{ // Len_Code
IntFuncP_TokenType, OneWord_Multiple,
"LEN(", NULL, Null_Flag, 2, Integer_DataType,
new ExprInfo(Null_Code, Operands(Str))
},
{ // Mid2_Code
IntFuncP_TokenType, OneWord_Multiple,
"MID$(", "MID2$(", Multiple_Flag | SubStr_Flag, 2, SubStr_DataType,
new ExprInfo(Null_Code, Operands(StrInt), AssocCode2(Mid2, -1))
},
{ // Mid3_Code
IntFuncP_TokenType, OneWord_Multiple,
"MID$(", "MID3$(", SubStr_Flag, 2, SubStr_DataType,
new ExprInfo(Null_Code, Operands(StrIntInt), AssocCode2(Mid3, -1))
},
{ // Repeat_Code
IntFuncP_TokenType, OneWord_Multiple,
"REPEAT$(", NULL, Null_Flag, 2, String_DataType,
new ExprInfo(Null_Code, Operands(StrInt))
},
{ // Right_Code
IntFuncP_TokenType, OneWord_Multiple,
"RIGHT$(", NULL, SubStr_Flag, 2, SubStr_DataType,
new ExprInfo(Null_Code, Operands(StrInt), AssocCode2(Right, -1))
},
{ // Space_Code
IntFuncP_TokenType, OneWord_Multiple,
"SPACE$(", NULL, Null_Flag, 2, String_DataType, &Int_ExprInfo
},
{ // Str_Code
IntFuncP_TokenType, OneWord_Multiple,
"STR$(", NULL, Null_Flag, 2, String_DataType,
new ExprInfo(Null_Code, Operands(Dbl), AssocCode(Str))
},
{ // Val_Code
IntFuncP_TokenType, OneWord_Multiple,
"VAL(", NULL, Null_Flag, 2, Double_DataType, &Str_ExprInfo
},
//***************************
// END PARENTHESES WORDS
//***************************
{ // EndParenWord_Code
Error_TokenType
},
//***************************
// BEGIN DATA TYPE WORDS
//***************************
{ // BegDataTypeWord_Code
Error_TokenType
},
// Currently None
//*************************
// END DATA TYPE WORDS
//*************************
{ // EndDataTypeWord_Code
Error_TokenType
},
//*******************
// BEGIN SYMBOLS
//*******************
{ // BegSymbol_Code
Error_TokenType
},
//----------------------
// Symbol Operators
//----------------------
{ // Add_Code
Operator_TokenType, OneChar_Multiple,
"+", NULL, Null_Flag, 40, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Add, 2))
},
{ // Sub_Code
Operator_TokenType, OneChar_Multiple,
"-", NULL, Null_Flag, 40, Double_DataType,
new ExprInfo(Neg_Code, Operands(DblDbl), AssocCode2(Sub, 1))
},
{ // Mul_Code
Operator_TokenType, OneChar_Multiple,
"*", NULL, Null_Flag, 46, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Mul, 1))
},
{ // Div_Code
Operator_TokenType, OneChar_Multiple,
"/", NULL, Null_Flag, 46, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Div, 1))
},
{ // IntDiv_Code
Operator_TokenType, OneChar_Multiple,
"\\", NULL, Null_Flag, 44, Integer_DataType, &DblDbl_ExprInfo
},
{ // Power_Code
Operator_TokenType, OneChar_Multiple,
"^", NULL, Null_Flag, 50, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Power, 1))
},
{ // Eq_Code
Operator_TokenType, OneChar_Multiple,
"=", NULL, Null_Flag, 30, Integer_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Eq, 2)),
Equal_Handler
},
{ // Gt_Code
Operator_TokenType, TwoChar_Multiple,
">", NULL, Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Gt, 2))
},
{ // GtEq_Code
Operator_TokenType, TwoChar_Multiple,
">=", NULL, Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(GtEq, 2))
},
{ // Lt_Code
Operator_TokenType, TwoChar_Multiple,
"<", NULL, Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Lt, 2))
},
{ // LtEq_Code
Operator_TokenType, TwoChar_Multiple,
"<=", NULL, Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(LtEq, 2))
},
{ // NotEq_Code
Operator_TokenType, TwoChar_Multiple,
"<>", NULL, Null_Flag, 30, Integer_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(NotEq, 2))
},
{ // OpenParen_Code
Operator_TokenType, OneChar_Multiple,
"(", NULL, Null_Flag, 2, None_DataType
},
{ // CloseParen_Code
Operator_TokenType, OneChar_Multiple,
")", NULL, EndExpr_Flag, 4, None_DataType, NULL,
CloseParen_Handler
},
{ // Comma_Code
Operator_TokenType, OneChar_Multiple,
",", NULL, EndExpr_Flag, 6, None_DataType,
NULL,//new ExprInfo(Comma_Code),
Comma_Handler
},
{ // SemiColon_Code
Operator_TokenType, OneChar_Multiple,
";", NULL, EndExpr_Flag, 6, None_DataType,
NULL,//new ExprInfo(SemiColon_Code),
SemiColon_Handler
},
{ // Colon_Code
Operator_TokenType, OneChar_Multiple,
":", NULL, Null_Flag, 4, None_DataType
},
{ // RemOp_Code
Operator_TokenType, OneChar_Multiple,
"'", NULL, EndExpr_Flag | EndStmt_Flag, 2, None_DataType, NULL,
RemOp_Handler
},
//*****************
// END SYMBOLS
//*****************
{ // EndSymbol_Code
Error_TokenType
},
//***************************
// MISCELLANEOUS ENTRIES
//***************************
{ // Neg_Code
Operator_TokenType, OneWord_Multiple,
// FIXME temporarily replaced "-" with "Neq" for testing
"-", "Neg", Null_Flag, 48, Double_DataType,
new ExprInfo(Neg_Code, Operands(Dbl), AssocCode(Neg))
},
{ // Assign_Code
Operator_TokenType, OneWord_Multiple,
"=", "Assign", Reference_Flag, 4, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(Assign, 3)),
NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignInt_Code
Operator_TokenType, OneWord_Multiple,
"=", "Assign%", Reference_Flag, 4, Integer_DataType,
new ExprInfo(Null_Code, Operands(IntInt), AssocCode(AssignInt)),
NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignStr_Code
Operator_TokenType, OneWord_Multiple,
"=", "Assign$", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(StrStr), AssocCode2(AssignStr, 1)),
NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignSubStr_Code
Operator_TokenType, OneWord_Multiple,
"=", "AssignSub$", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(SubStr)),
NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignLeft_Code
Operator_TokenType, OneWord_Multiple,
"LEFT$(", "AssignLeft", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(StrStr), AssocCode(AssignLeft))
},
{ // AssignMid2_Code
Operator_TokenType, OneWord_Multiple,
"MID$(", "AssignMid2", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(StrStr), AssocCode(AssignMid2))
},
{ // AssignMid3_Code
Operator_TokenType, OneWord_Multiple,
"MID$(", "AssignMid3", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(StrStr), AssocCode(AssignMid3))
},
{ // AssignRight_Code
Operator_TokenType, OneWord_Multiple,
"MID$(", "AssignRight", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(StrStr), AssocCode(AssignRight))
},
{ // AssignList_Code
Operator_TokenType, OneWord_Multiple,
"=", "AssignList", Reference_Flag, 4, Double_DataType,
new ExprInfo(Null_Code, Operands(DblDbl), AssocCode2(AssignList, 3)),
NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignListInt_Code
Operator_TokenType, OneWord_Multiple,
"=", "AssignList%", Reference_Flag, 4, Integer_DataType,
&IntInt_ExprInfo, NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignListStr_Code
Operator_TokenType, OneWord_Multiple,
"=", "AssignList$", Reference_Flag, 4, String_DataType,
&StrStr_ExprInfo, NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignListMix_Code
Operator_TokenType, OneWord_Multiple,
"=", "AssignListMix$", Reference_Flag, 4, String_DataType,
new ExprInfo(Null_Code, Operands(SubStr)),
NULL, Null_TokenMode, Assign_CmdHandler
},
{ // AssignKeepStr_Code
Operator_TokenType, OneWord_Multiple,
"=", "AssignKeep$", Reference_Flag, 4, String_DataType, &StrStr_ExprInfo
},
{ // AssignKeepLeft_Code
Operator_TokenType, OneWord_Multiple,
"LEFT$(", "AssignKeepLeft", Reference_Flag, 4, String_DataType,
&StrStr_ExprInfo
},
{ // AssignKeepMid2_Code
Operator_TokenType, OneWord_Multiple,
"MID$(", "AssignKeepMid2", Reference_Flag, 4, String_DataType,
&StrStr_ExprInfo
},
{ // AssignKeepMid3_Code
Operator_TokenType, OneWord_Multiple,
"MID$(", "AssignKeepMid3", Reference_Flag, 4, String_DataType,
&StrStr_ExprInfo
},
{ // AssignKeepRight_Code
Operator_TokenType, OneWord_Multiple,
"RIGHT$(", "AssignKeepRight", Reference_Flag, 4, String_DataType,
&StrStr_ExprInfo
},
{ // EOL_Code
Operator_TokenType, OneWord_Multiple,
NULL, "EOL", EndExpr_Flag | EndStmt_Flag, 4, None_DataType, NULL,
EndOfLine_Handler
},
{ // AddI1_Code
Operator_TokenType, OneChar_Multiple,
"+", "+%1", Null_Flag, 40, Double_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(AddI1))
},
{ // AddI2_Code
Operator_TokenType, OneChar_Multiple,
"+", "+%2", Null_Flag, 40, Double_DataType, &DblInt_ExprInfo
},
{ // AddInt_Code
Operator_TokenType, OneChar_Multiple,
"+", "+%", Null_Flag, 40, Integer_DataType, &IntInt_ExprInfo
},
{ // CatStr_Code
Operator_TokenType, OneChar_Multiple,
"+", "+$", Null_Flag, 40, String_DataType, &StrStr_ExprInfo
},
{ // SubI1_Code
Operator_TokenType, OneChar_Multiple,
"-", "-%1", Null_Flag, 40, Double_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(SubI1))
},
{ // SubI2_Code
Operator_TokenType, OneChar_Multiple,
"-", "-%2", Null_Flag, 40, Double_DataType, &DblInt_ExprInfo
},
{ // SubInt_Code
Operator_TokenType, OneChar_Multiple,
"-", "-%", Null_Flag, 40, Integer_DataType, &IntInt_ExprInfo
},
{ // NegInt_Code
Operator_TokenType, OneChar_Multiple,
"-", "Neg%", Null_Flag, 40, Integer_DataType,
new ExprInfo(NegInt_Code, Operands(Int))
},
{ // MulI1_Code
Operator_TokenType, OneChar_Multiple,
"*", "*%1", Null_Flag, 46, Double_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(MulI1))
},
{ // MulI2_Code
Operator_TokenType, OneChar_Multiple,
"*", "*%2", Null_Flag, 46, Double_DataType, &DblInt_ExprInfo
},
{ // MulInt_Code
Operator_TokenType, OneChar_Multiple,
"*", "*%", Null_Flag, 46, Integer_DataType, &IntInt_ExprInfo
},
{ // DivI1_Code
Operator_TokenType, OneChar_Multiple,
"/", "/%1", Null_Flag, 46, Double_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(DivI1))
},
{ // DivI2_Code
Operator_TokenType, OneChar_Multiple,
"/", "/%2", Null_Flag, 46, Double_DataType, &DblInt_ExprInfo
},
{ // DivInt_Code
Operator_TokenType, OneChar_Multiple,
"/", "/%", Null_Flag, 46, Integer_DataType, &IntInt_ExprInfo
},
{ // ModI1_Code
Operator_TokenType, OneChar_Multiple,
"MOD", "MOD%1", Null_Flag, 42, Double_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(ModI1))
},
{ // ModI2_Code
Operator_TokenType, OneChar_Multiple,
"MOD", "MOD%2", Null_Flag, 42, Double_DataType, &DblInt_ExprInfo
},
{ // ModInt_Code
Operator_TokenType, OneWord_Multiple,
"MOD", "MOD%", Null_Flag, 42, Integer_DataType, &IntInt_ExprInfo
},
{ // PowerI1_Code
Operator_TokenType, OneChar_Multiple,
"^", "^%1", Null_Flag, 50, Double_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(PowerI1))
},
{ // PowerMul_Code
Operator_TokenType, OneChar_Multiple,
"^", "^*", Null_Flag, 50, Double_DataType, &DblInt_ExprInfo
},
{ // PowerInt_Code
Operator_TokenType, OneChar_Multiple,
"^", "^%", Null_Flag, 50, Integer_DataType, &IntInt_ExprInfo
},
{ // EqI1_Code
Operator_TokenType, OneChar_Multiple,
"=", "=%1", Null_Flag, 30, Integer_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(EqI1))
},
{ // EqI2_Code
Operator_TokenType, OneChar_Multiple,
"=", "=%2", Null_Flag, 30, Integer_DataType, &DblInt_ExprInfo
},
{ // EqInt_Code
Operator_TokenType, OneChar_Multiple,
"=", "=%", Null_Flag, 30, Integer_DataType, &IntInt_ExprInfo
},
{ // EqStr_Code
Operator_TokenType, OneChar_Multiple,
"=", "=$", Null_Flag, 30, Integer_DataType, &StrStr_ExprInfo
},
{ // GtI1_Code
Operator_TokenType, OneChar_Multiple,
">", ">%1", Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(GtI1))
},
{ // GtI2_Code
Operator_TokenType, OneChar_Multiple,
">", ">%2", Null_Flag, 32, Integer_DataType, &DblInt_ExprInfo
},
{ // GtInt_Code
Operator_TokenType, OneChar_Multiple,
">", ">%", Null_Flag, 32, Integer_DataType, &IntInt_ExprInfo
},
{ // GtStr_Code
Operator_TokenType, OneChar_Multiple,
">", ">$", Null_Flag, 32, Integer_DataType, &StrStr_ExprInfo
},
{ // GtEqI1_Code
Operator_TokenType, OneChar_Multiple,
">=", ">=%1", Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(GtEqI1))
},
{ // GtEqI2_Code
Operator_TokenType, OneChar_Multiple,
">=", ">=%2", Null_Flag, 32, Integer_DataType, &DblInt_ExprInfo
},
{ // GtEqInt_Code
Operator_TokenType, OneChar_Multiple,
">=", ">=%", Null_Flag, 32, Integer_DataType, &IntInt_ExprInfo
},
{ // GtEqStr_Code
Operator_TokenType, OneChar_Multiple,
">=", ">=$", Null_Flag, 32, Integer_DataType, &StrStr_ExprInfo
},
{ // LtI1_Code
Operator_TokenType, OneChar_Multiple,
"<", "<%1", Null_Flag, 32, Integer_DataType,
new ExprInfo(Null_Code, Operands(IntDbl), AssocCode(LtI1))
},
{ // LtI2_Code
Operator_TokenType, OneChar_Multiple,
"<", "<%2", Null_Flag, 32, Integer_DataType, &DblInt_ExprInfo
},
{ // LtInt_Code
Operator_TokenType, OneChar_Multiple,
"<", "<%", Null_Flag, 32, Integer_DataType, &IntInt_ExprInfo
},
{ // LtStr_Code