-
Notifications
You must be signed in to change notification settings - Fork 227
/
Formula.cpp
7807 lines (7669 loc) · 296 KB
/
Formula.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
/* Formula.cpp
*
* Copyright (C) 1992-2021 Paul Boersma
*
* This code 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 2 of the License, or (at
* your option) any later version.
*
* This code 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.
*
* You should have received a copy of the GNU General Public License
* along with this work. If not, see <http://www.gnu.org/licenses/>.
*/
#if defined (UNIX)
#include <sys/stat.h>
#endif
#include "../dwsys/NUM2.h"
#include "Formula.h"
#include "Interpreter.h"
#include "Ui.h"
#include "praatP.h"
#include "praat_script.h"
#include "../kar/UnicodeData.h"
#include "../kar/longchar.h"
#include "UiPause.h"
#include "DemoEditor.h"
static Interpreter theInterpreter;
static autoInterpreter theLocalInterpreter;
static Daata theSource;
static conststring32 theExpression;
static int theLevel = 1;
#define MAXIMUM_NUMBER_OF_LEVELS 20
static int theExpressionType [1 + MAXIMUM_NUMBER_OF_LEVELS];
static bool theOptimize;
typedef struct structFormulaInstruction {
integer symbol;
integer position;
union {
double number;
integer label;
char32 *string;
Daata object;
InterpreterVariable variable;
} content;
} *FormulaInstruction;
static FormulaInstruction lexan, parse;
static integer ilabel, ilexan, iparse, numberOfInstructions, numberOfStringConstants;
enum { NO_SYMBOL_,
#define DECLARE_WITH_TENSORS(symbol) \
symbol, symbol##VEC_, symbol##MAT_,
/* First, all symbols after which "-" is unary. */
/* The list ends with "MINUS_" itself. */
/* Opening symbols. */
IF_, THEN_, ELSE_, OPENING_PARENTHESIS_, OPENING_BRACKET_, OPENING_BRACE_, COMMA_, COLON_, FROM_, TO_,
/* Operators with boolean results. */
OR_, AND_, NOT_, EQ_, NE_, LE_, LT_, GE_, GT_,
/* Operators with results. */
ADD_, SUB_, MUL_, RDIV_, IDIV_, MOD_, POWER_, CALL_, MINUS_,
/* Then, the symbols after which "-" is binary. */
/* Closing symbols. */
ENDIF_, FI_, CLOSING_PARENTHESIS_, CLOSING_BRACKET_, CLOSING_BRACE_,
/* Things with a value. */
#define LOW_VALUE NUMBER_
NUMBER_, NUMBER_PI_, NUMBER_E_, NUMBER_UNDEFINED_,
/* Attributes of objects. */
#define LOW_ATTRIBUTE XMIN_
XMIN_, XMAX_, YMIN_, YMAX_, NX_, NY_, DX_, DY_,
ROW_, COL_, NROW_, NCOL_, ROW_STR_, COL_STR_, Y_, X_,
#define HIGH_ATTRIBUTE X_
#define HIGH_VALUE HIGH_ATTRIBUTE
SELF_, SELF_STR_, OBJECT_, OBJECT_STR_, MATRIX_, MATRIX_STR_,
STOPWATCH_,
/* The following symbols can be followed by "-" only if they are a variable. */
/* Functions of 1 variable; if you add, update the #defines. */
#define LOW_FUNCTION_1 ABS_
DECLARE_WITH_TENSORS (ABS_)
DECLARE_WITH_TENSORS (ROUND_) DECLARE_WITH_TENSORS (FLOOR_) DECLARE_WITH_TENSORS (CEILING_)
DECLARE_WITH_TENSORS (RECTIFY_)
DECLARE_WITH_TENSORS (SQRT_)
DECLARE_WITH_TENSORS (SIN_) DECLARE_WITH_TENSORS (COS_) DECLARE_WITH_TENSORS (TAN_)
DECLARE_WITH_TENSORS (ARCSIN_) DECLARE_WITH_TENSORS (ARCCOS_) DECLARE_WITH_TENSORS (ARCTAN_)
SINC_, SINCPI_,
DECLARE_WITH_TENSORS (EXP_)
DECLARE_WITH_TENSORS (SINH_) DECLARE_WITH_TENSORS (COSH_) DECLARE_WITH_TENSORS (TANH_)
DECLARE_WITH_TENSORS (ARCSINH_) DECLARE_WITH_TENSORS (ARCCOSH_) DECLARE_WITH_TENSORS (ARCTANH_)
DECLARE_WITH_TENSORS (SIGMOID_) DECLARE_WITH_TENSORS (INV_SIGMOID_)
SOFTMAX_VEC_, SOFTMAX_PER_ROW_MAT_,
ERF_, ERFC_, GAUSS_P_, GAUSS_Q_, INV_GAUSS_Q_,
RANDOM_BERNOULLI_, RANDOM_BERNOULLI_VEC_,
RANDOM_POISSON_, TRANSPOSE_MAT_,
ROW_SUMS_VEC_, COLUMN_SUMS_VEC_,
DECLARE_WITH_TENSORS (LOG2_) DECLARE_WITH_TENSORS (LN_) DECLARE_WITH_TENSORS (LOG10_)
LN_GAMMA_,
HERTZ_TO_BARK_, BARK_TO_HERTZ_, PHON_TO_DIFFERENCE_LIMENS_, DIFFERENCE_LIMENS_TO_PHON_,
HERTZ_TO_MEL_, MEL_TO_HERTZ_, HERTZ_TO_SEMITONES_, SEMITONES_TO_HERTZ_,
ERB_, HERTZ_TO_ERB_, ERB_TO_HERTZ_,
SUM_, MEAN_, STDEV_, CENTER_,
EVALUATE_, EVALUATE_NOCHECK_, EVALUATE_STR_, EVALUATE_NOCHECK_STR_,
STRING_STR_, SLEEP_, UNICODE_, UNICODE_STR_,
#define HIGH_FUNCTION_1 UNICODE_STR_
/* Functions of 2 variables; if you add, update the #defines. */
#define LOW_FUNCTION_2 ARCTAN2_
ARCTAN2_, RANDOM_UNIFORM_, RANDOM_INTEGER_, RANDOM_GAUSS_, RANDOM_BINOMIAL_,
RANDOM_GAMMA_,
CHI_SQUARE_P_, CHI_SQUARE_Q_, INCOMPLETE_GAMMAP_,
INV_CHI_SQUARE_Q_, STUDENT_P_, STUDENT_Q_, INV_STUDENT_Q_,
BETA_, BETA2_, BESSEL_I_, BESSEL_K_, LN_BETA_,
SOUND_PRESSURE_TO_PHON_, OBJECTS_ARE_IDENTICAL_,
ROW_VEC_, COL_VEC_,
INNER_, OUTER_MAT_, MUL_VEC_, MUL_MAT_, MUL_FAST_MAT_, MUL_METAL_MAT_,
MUL_TN_MAT_, MUL_NT_MAT_, MUL_TT_MAT_, REPEAT_VEC_,
ROW_INNERS_VEC_, SOLVE_VEC_, SOLVE_MAT_,
#define HIGH_FUNCTION_2 SOLVE_MAT_
/* Functions of 3 variables; if you add, update the #defines. */
#define LOW_FUNCTION_3 FISHER_P_
FISHER_P_, FISHER_Q_, INV_FISHER_Q_,
BINOMIAL_P_, BINOMIAL_Q_, INCOMPLETE_BETA_, INV_BINOMIAL_P_, INV_BINOMIAL_Q_,
#define HIGH_FUNCTION_3 INV_BINOMIAL_Q_
/* Functions of 4 variables; if you add, update the #defines. */
#define LOW_FUNCTION_4 SOLVE_WEAKLYCONSTRAINED_VEC_
SOLVE_WEAKLYCONSTRAINED_VEC_,
#define HIGH_FUNCTION_4 SOLVE_WEAKLYCONSTRAINED_VEC_
/* Functions of a variable number of variables; if you add, update the #defines. */
#define LOW_FUNCTION_N DO_
DO_, DOSTR_,
WRITE_INFO_, WRITE_INFO_LINE_, APPEND_INFO_, APPEND_INFO_LINE_,
WRITE_FILE_, WRITE_FILE_LINE_, APPEND_FILE_, APPEND_FILE_LINE_,
PAUSE_SCRIPT_, EXIT_SCRIPT_, RUN_SCRIPT_, RUN_SYSTEM_, RUN_SYSTEM_NOCHECK_, RUN_SUBPROCESS_,
MIN_, MAX_, IMIN_, IMAX_, NORM_,
LEFT_STR_, RIGHT_STR_, MID_STR_,
SELECTED_, SELECTED_STR_, NUMBER_OF_SELECTED_, SELECTED_VEC_,
SELECT_OBJECT_, PLUS_OBJECT_, MINUS_OBJECT_, REMOVE_OBJECT_,
BEGIN_PAUSE_FORM_, PAUSE_FORM_ADD_REAL_, PAUSE_FORM_ADD_POSITIVE_, PAUSE_FORM_ADD_INTEGER_, PAUSE_FORM_ADD_NATURAL_,
PAUSE_FORM_ADD_WORD_, PAUSE_FORM_ADD_SENTENCE_, PAUSE_FORM_ADD_TEXT_, PAUSE_FORM_ADD_BOOLEAN_,
PAUSE_FORM_ADD_CHOICE_, PAUSE_FORM_ADD_OPTION_MENU_, PAUSE_FORM_ADD_OPTION_,
PAUSE_FORM_ADD_COMMENT_, END_PAUSE_FORM_,
CHOOSE_READ_FILE_STR_, CHOOSE_WRITE_FILE_STR_, CHOOSE_FOLDER_STR_, CHOOSE_DIRECTORY_STR_,
DEMO_WINDOW_TITLE_, DEMO_SHOW_, DEMO_WAIT_FOR_INPUT_, DEMO_PEEK_INPUT_, DEMO_INPUT_, DEMO_CLICKED_IN_,
DEMO_CLICKED_, DEMO_X_, DEMO_Y_, DEMO_KEY_PRESSED_, DEMO_KEY_,
DEMO_SHIFT_KEY_PRESSED_, DEMO_COMMAND_KEY_PRESSED_, DEMO_OPTION_KEY_PRESSED_,
ZERO_VEC_, ZERO_MAT_,
LINEAR_VEC_, LINEAR_MAT_, TO_VEC_, FROM_TO_VEC_, FROM_TO_BY_VEC_, FROM_TO_COUNT_VEC_, BETWEEN_BY_VEC_, BETWEEN_COUNT_VEC_,
SORT_VEC_, SHUFFLE_VEC_,
RANDOM_UNIFORM_VEC_, RANDOM_UNIFORM_MAT_,
RANDOM_INTEGER_VEC_, RANDOM_INTEGER_MAT_,
RANDOM_GAUSS_VEC_, RANDOM_GAUSS_MAT_,
RANDOM_GAMMA_VEC_, RANDOM_GAMMA_MAT_,
SOLVE_SPARSE_VEC_, SOLVE_NONNEGATIVE_VEC_,
PEAKS_MAT_,
SIZE_, NUMBER_OF_ROWS_, NUMBER_OF_COLUMNS_, COMBINE_VEC_, EDITOR_,
RANDOM__INITIALIZE_WITH_SEED_UNSAFELY_BUT_PREDICTABLY_, RANDOM__INITIALIZE_SAFELY_AND_UNPREDICTABLY_,
HASH_, HEX_STR_, UNHEX_STR_,
EMPTY_STRVEC_, READ_LINES_FROM_FILE_STRVEC_, FILE_NAMES_STRVEC_, FOLDER_NAMES_STRVEC_, SPLIT_BY_WHITESPACE_STRVEC_,
#define HIGH_FUNCTION_N SPLIT_BY_WHITESPACE_STRVEC_
/* String functions. */
#define LOW_STRING_FUNCTION LOW_FUNCTION_STR1
#define LOW_FUNCTION_STR1 LENGTH_
LENGTH_, STRING_TO_NUMBER_, FILE_READABLE_, TRY_TO_WRITE_FILE_, TRY_TO_APPEND_FILE_, DELETE_FILE_, CREATE_FOLDER_, CREATE_DIRECTORY_, VARIABLE_EXISTS_,
READ_FILE_, READ_FILE_STR_, UNICODE_TO_BACKSLASH_TRIGRAPHS_STR_, BACKSLASH_TRIGRAPHS_TO_UNICODE_STR_, ENVIRONMENT_STR_,
#define HIGH_FUNCTION_STR1 ENVIRONMENT_STR_
DATE_STR_, DATE_UTC_STR_, DATE_ISO_STR_, DATE_UTC_ISO_STR_, DATE_VEC_, DATE_UTC_VEC_, INFO_STR_, // TODO: two of those aren't really string functions
INDEX_, RINDEX_,
STARTS_WITH_, ENDS_WITH_, REPLACE_STR_, INDEX_REGEX_, RINDEX_REGEX_, REPLACE_REGEX_STR_,
EXTRACT_NUMBER_, EXTRACT_WORD_STR_, EXTRACT_LINE_STR_,
FIXED_STR_, PERCENT_STR_, HEXADECIMAL_STR_,
#define HIGH_STRING_FUNCTION HEXADECIMAL_STR_
/* Range functions. */
#define LOW_RANGE_FUNCTION SUM_OVER_
SUM_OVER_,
#define HIGH_RANGE_FUNCTION SUM_OVER_
#define LOW_FUNCTION LOW_FUNCTION_1
#define HIGH_FUNCTION HIGH_RANGE_FUNCTION
/* Membership operator. */
PERIOD_,
#define highestInputSymbol PERIOD_
/* Symbols introduced by the parser. */
TRUE_, FALSE_,
GOTO_, IFTRUE_, IFFALSE_, INCREMENT_GREATER_GOTO_,
LABEL_,
DECREMENT_AND_ASSIGN_, ADD_3DOWN_, POP_2_,
VEC_CELL_, MAT_CELL_, STRVEC_CELL_, VARIABLE_REFERENCE_,
TENSOR_LITERAL_,
SELF0_, SELFSTR0_, TO_OBJECT_,
OBJECT_XMIN_, OBJECT_XMAX_, OBJECT_YMIN_, OBJECT_YMAX_, OBJECT_NX_, OBJECT_NY_,
OBJECT_DX_, OBJECT_DY_, OBJECT_NROW_, OBJECT_NCOL_, OBJECT_ROW_STR_, OBJECT_COL_STR_,
OBJECTCELL0_, OBJECTCELL0_STR_, OBJECTCELL1_, OBJECTCELL1_STR_, OBJECTCELL2_, OBJECTCELL2_STR_,
OBJECTLOCATION0_, OBJECTLOCATION0_STR_, OBJECTLOCATION1_, OBJECTLOCATION1_STR_, OBJECTLOCATION2_, OBJECTLOCATION2_STR_,
SELFMATRIX1_, SELFMATRIX1_STR_, SELFMATRIX2_, SELFMATRIX2_STR_,
SELFFUNCTION1_, SELFFUNCTION1_STR_, SELFFUNCTION2_, SELFFUNCTION2_STR_,
MATRIX0_, MATRIX0_STR_, MATRIX1_, MATRIX1_STR_, MATRIX2_, MATRIX2_STR_,
FUNCTION0_, FUNCTION0_STR_, FUNCTION1_, FUNCTION1_STR_, FUNCTION2_, FUNCTION2_STR_,
SQR_,
/* Symbols introduced by lexical analysis. */
STRING_,
NUMERIC_VARIABLE_, NUMERIC_VECTOR_VARIABLE_, NUMERIC_MATRIX_VARIABLE_,
STRING_VARIABLE_, STRING_ARRAY_VARIABLE_,
VARIABLE_NAME_, INDEXED_NUMERIC_VARIABLE_, INDEXED_STRING_VARIABLE_,
END_
#define highestSymbol END_
};
/* The names that start with an underscore (_) do not occur in the formula text: */
/* they are used in error messages and in debugging (see Formula_print). */
static const conststring32 Formula_instructionNames [1 + highestSymbol] = { U"",
#define NAME_WITH_TENSORS(name) \
U"" #name, U"" #name "#", U"" #name "##",
U"if", U"then", U"else", U"(", U"[", U"{", U",", U":", U"from", U"to",
U"or", U"and", U"not", U"=", U"<>", U"<=", U"<", U">=", U">",
U"+", U"-", U"*", U"/", U"div", U"mod", U"^", U"_call", U"_neg",
U"endif", U"fi", U")", U"]", U"}",
U"a number", U"pi", U"e", U"undefined",
U"xmin", U"xmax", U"ymin", U"ymax", U"nx", U"ny", U"dx", U"dy",
U"row", U"col", U"nrow", U"ncol", U"row$", U"col$", U"y", U"x",
U"self", U"self$", U"object", U"object$", U"_matrix", U"_matrix$",
U"stopwatch",
NAME_WITH_TENSORS (abs)
NAME_WITH_TENSORS (round) NAME_WITH_TENSORS (floor) NAME_WITH_TENSORS (ceiling)
NAME_WITH_TENSORS (rectify)
NAME_WITH_TENSORS (sqrt)
NAME_WITH_TENSORS (sin) NAME_WITH_TENSORS (cos) NAME_WITH_TENSORS (tan)
NAME_WITH_TENSORS (arcsin) NAME_WITH_TENSORS (arccos) NAME_WITH_TENSORS (arctan)
U"sinc", U"sincpi",
NAME_WITH_TENSORS (exp)
NAME_WITH_TENSORS (sinh) NAME_WITH_TENSORS (cosh) NAME_WITH_TENSORS (tanh)
NAME_WITH_TENSORS (arcsinh) NAME_WITH_TENSORS (arccosh) NAME_WITH_TENSORS (arctanh)
NAME_WITH_TENSORS (sigmoid) NAME_WITH_TENSORS (invSigmoid)
U"softmax#", U"softmaxPerRow##",
U"erf", U"erfc", U"gaussP", U"gaussQ", U"invGaussQ",
U"randomBernoulli", U"randomBernoulli#",
U"randomPoisson", U"transpose##",
U"rowSums#", U"columnSums#",
NAME_WITH_TENSORS (log2) NAME_WITH_TENSORS (ln) NAME_WITH_TENSORS (log10)
U"lnGamma",
U"hertzToBark", U"barkToHertz", U"phonToDifferenceLimens", U"differenceLimensToPhon",
U"hertzToMel", U"melToHertz", U"hertzToSemitones", U"semitonesToHertz",
U"erb", U"hertzToErb", U"erbToHertz",
U"sum", U"mean", U"stdev", U"center",
U"evaluate", U"evaluate_nocheck", U"evaluate$", U"evaluate_nocheck$",
U"string$", U"sleep", U"unicode", U"unicode$",
U"arctan2", U"randomUniform", U"randomInteger", U"randomGauss", U"randomBinomial", U"randomGamma",
U"chiSquareP", U"chiSquareQ", U"incompleteGammaP", U"invChiSquareQ", U"studentP", U"studentQ", U"invStudentQ",
U"beta", U"beta2", U"besselI", U"besselK", U"lnBeta",
U"soundPressureToPhon", U"objectsAreIdentical",
U"row#", U"col#",
U"inner", U"outer##", U"mul#", U"mul##", U"mul_fast##", U"mul_metal##",
U"mul_tn##", U"mul_nt##", U"mul_tt##", U"repeat#",
U"rowInners#", U"solve#", U"solve##",
U"fisherP", U"fisherQ", U"invFisherQ",
U"binomialP", U"binomialQ", U"incompleteBeta", U"invBinomialP", U"invBinomialQ",
U"solveWeaklyConstrained#",
U"do", U"do$",
U"writeInfo", U"writeInfoLine", U"appendInfo", U"appendInfoLine",
U"writeFile", U"writeFileLine", U"appendFile", U"appendFileLine",
U"pauseScript", U"exitScript", U"runScript", U"runSystem", U"runSystem_nocheck", U"runSubprocess",
U"min", U"max", U"imin", U"imax", U"norm",
U"left$", U"right$", U"mid$",
U"selected", U"selected$", U"numberOfSelected", U"selected#",
U"selectObject", U"plusObject", U"minusObject", U"removeObject",
U"beginPause", U"real", U"positive", U"integer", U"natural",
U"word", U"sentence", U"text", U"boolean",
U"choice", U"optionMenu", U"option",
U"comment", U"endPause",
U"chooseReadFile$", U"chooseWriteFile$", U"chooseFolder$", U"chooseDirectory$",
U"demoWindowTitle", U"demoShow", U"demoWaitForInput", U"demoPeekInput", U"demoInput", U"demoClickedIn",
U"demoClicked", U"demoX", U"demoY", U"demoKeyPressed", U"demoKey$",
U"demoShiftKeyPressed", U"demoCommandKeyPressed", U"demoOptionKeyPressed",
U"zero#", U"zero##",
U"linear#", U"linear##", U"to#", U"from_to#", U"from_to_by#", U"from_to_count#", U"between_by#", U"between_count#",
U"sort#", U"shuffle#",
U"randomUniform#", U"randomUniform##",
U"randomInteger#", U"randomInteger##",
U"randomGauss#", U"randomGauss##",
U"randomGamma#", U"randomGamma##", U"solveSparse#", U"solveNonnegative#",
U"peaks##",
U"size", U"numberOfRows", U"numberOfColumns", U"combine#", U"editor",
U"random_initializeWithSeedUnsafelyButPredictably", U"random_initializeSafelyAndUnpredictably",
U"hash", U"hex$", U"unhex$",
U"empty$#", U"readLinesFromFile$#", U"fileNames$#", U"folderNames$#", U"splitByWhitespace$#",
U"length", U"number", U"fileReadable", U"tryToWriteFile", U"tryToAppendFile", U"deleteFile", U"createFolder", U"createDirectory", U"variableExists",
U"readFile", U"readFile$", U"unicodeToBackslashTrigraphs$", U"backslashTrigraphsToUnicode$", U"environment$",
U"date$", U"date_utc$", U"date_iso$", U"date_utc_iso$", U"date#", U"date_utc#", U"info$",
U"index", U"rindex",
U"startsWith", U"endsWith", U"replace$", U"index_regex", U"rindex_regex", U"replace_regex$",
U"extractNumber", U"extractWord$", U"extractLine$",
U"fixed$", U"percent$", U"hexadecimal$",
U"sumOver",
U".",
U"_true", U"_false",
U"_goto", U"_iftrue", U"_iffalse", U"_incrementGreaterGoto",
U"_label",
U"_decrementAndAssign", U"_add3Down", U"_pop2",
U"_numericVectorElement", U"_numericMatrixElement", U"_stringVectorElement", U"_variableReference",
U"_numericVectorLiteral",
U"_self0", U"_self0$", U"_toObject",
U"_object_xmin", U"_object_xmax", U"_object_ymin", U"_object_ymax", U"_object_nx", U"_object_ny",
U"_object_dx", U"_object_dy", U"_object_nrow", U"_object_ncol", U"_object_row$", U"_object_col$",
U"_objectcell0", U"_objectcell0$", U"_objectcell1", U"_objectcell1$", U"_objectcell2", U"_objectcell2$",
U"_objectlocation0", U"_objectlocation0$", U"_objectlocation1", U"_objectlocation1$", U"_objectlocation2", U"_objectlocation2$",
U"_selfmatrix1", U"_selfmatrix1$", U"_selfmatrix2", U"_selfmatrix2$",
U"_selffunction1", U"_selffunction1$", U"_selffunction2", U"_selffunction2$",
U"_matrix0", U"_matrix0$", U"_matrix1", U"_matrix1$", U"_matrix2", U"_matrix2$",
U"_function0", U"_function0$", U"_function1", U"_function1$", U"_function2", U"_function2$",
U"_square",
U"_string",
U"a numeric variable", U"a vector variable", U"a matrix variable",
U"a string variable", U"a string array variable",
U"a variable name", U"an indexed numeric variable", U"an indexed string variable",
U"the end of the formula"
};
#define newlabel (-- ilabel)
#define newread (lexan [++ ilexan]. symbol)
#define oldread (-- ilexan)
static void formulaError (conststring32 message, integer position) {
static MelderString truncatedExpression;
MelderString_ncopy (& truncatedExpression, theExpression, position + 1);
Melder_throw (message, U":\n« ", truncatedExpression.string);
}
static integer Formula_hasLanguageName (conststring32 f) {
static autoINTVEC index;
if (NUMisEmpty (index.get())) {
index = to_INTVEC (highestInputSymbol);
std::sort (index.begin(), index.end(),
[] (integer i, integer j) {
return str32cmp (Formula_instructionNames [i], Formula_instructionNames [j]) < 0;
}
);
}
constexpr integer sentinel = 0; // has to be different from the numbers 1 .. index.size
const integer * const found = std::lower_bound (index.begin(), index.end(), sentinel,
[f] (integer i, integer j) {
return str32cmp (
i == sentinel ? f : Formula_instructionNames [i],
j == sentinel ? f : Formula_instructionNames [j]
) < 0;
}
);
if (found != index.end() && Melder_equ (Formula_instructionNames [*found], f))
return *found;
return 0;
}
static void Formula_lexan () {
/*
Purpose:
translate the formula text into a series of symbols.
Return:
0 in case of error, otherwise 1.
Postcondition:
if result != 0, then the last symbol is L"END_".
Example:
the text L"x*7" yields 5 symbols:
lexan [0] is empty;
lexan [1]. symbol = X_;
lexan [2]. symbol = MUL_;
lexan [3]. symbol = NUMBER_;
lexan [3]. number = 7.00000000e+00;
lexan [4]. symbol = END_;
*/
char32 kar; /* The character most recently read from theExpression. */
integer ikar = -1; /* The position of that character in theExpression. */
#define newchar kar = theExpression [++ ikar]
#define oldchar -- ikar
integer itok = 0; /* Position of most recent symbol in "lexan". */
#define newtok(s) { lexan [++ itok]. symbol = s; lexan [itok]. position = ikar; }
#define toknumber(g) lexan [itok]. content.number = (g)
#define tokmatrix(m) lexan [itok]. content.object = (m)
static MelderString token; // string to collect a symbol name in
#define stringtokon MelderString_empty (& token);
#define stringtokchar { MelderString_appendCharacter (& token, kar); newchar; }
#define stringtokoff (void) 0
ilexan = iparse = ilabel = numberOfStringConstants = 0;
do {
newchar;
if (Melder_isHorizontalOrVerticalSpace (kar)) {
; // ignore spaces and tabs
} else if (kar == U'\0') {
newtok (END_)
} else if (Melder_isAsciiDecimalNumber (kar)) {
char32 saveKar = kar;
bool isHexadecimal = false;
if (kar == U'0') {
newchar;
if (kar == U'x') {
isHexadecimal = true;
newchar;
} else {
oldchar;
}
}
if (isHexadecimal) {
stringtokon;
do stringtokchar while (Melder_isHexadecimalDigit (kar));
stringtokoff;
oldchar;
newtok (NUMBER_)
toknumber (strtoull (Melder_peek32to8 (token.string), nullptr, 16));
} else {
kar = saveKar;
stringtokon;
do stringtokchar while (Melder_isAsciiDecimalNumber (kar));
if (kar == U'.')
do stringtokchar while (Melder_isAsciiDecimalNumber (kar));
if (kar == U'e' || kar == U'E') {
kar = U'e';
stringtokchar
if (kar == U'-')
stringtokchar
else if (kar == U'+')
newchar;
if (! Melder_isAsciiDecimalNumber (kar))
formulaError (U"Missing exponent", ikar);
do stringtokchar while (Melder_isAsciiDecimalNumber (kar));
}
if (kar == U'%')
stringtokchar
stringtokoff;
oldchar;
newtok (NUMBER_)
toknumber (Melder_atof (token.string));
}
} else if (Melder_isLetter (kar) && ! Melder_isUpperCaseLetter (kar) ||
(kar == U'.' && Melder_isLetter (theExpression [ikar + 1]) && ! Melder_isUpperCaseLetter (theExpression [ikar + 1])
&& (itok == 0 || (lexan [itok]. symbol != MATRIX_ && lexan [itok]. symbol != MATRIX_STR_
&& lexan [itok]. symbol != CLOSING_BRACKET_)))) {
integer tok;
bool isString = false;
int rank = 0;
stringtokon;
do stringtokchar while (Melder_isWordCharacter (kar) || kar == U'.');
if (kar == U'$') {
isString = true;
stringtokchar
if (kar == U'#') {
rank += 1;
stringtokchar
}
}
if (kar == U'#') {
rank += 1;
stringtokchar
if (kar == U'#') {
rank += 1;
stringtokchar
if (kar == U'#') {
rank += 1;
stringtokchar
if (kar == U'#') {
rank += 1;
stringtokchar
}
}
}
}
stringtokoff;
oldchar;
/*
`token` now contains a word, possibly ending in $, #, ## or $#;
it could be a variable name, a function name, both, or a procedure name.
Try a language or function name first.
*/
tok = Formula_hasLanguageName (token.string);
if (tok) {
/*
We have a language name or a function name. It MIGHT be meant to be a variable name, though,
regarding the large and expanding number of language names.
*/
/*
First the constants. They are reserved words and can never be variable names.
*/
if (tok == NUMBER_PI_) {
newtok (NUMBER_)
toknumber (NUMpi);
} else if (tok == NUMBER_E_) {
newtok (NUMBER_)
toknumber (NUMe);
} else if (tok == NUMBER_UNDEFINED_) {
newtok (NUMBER_)
toknumber (undefined);
/*
One very common language name must be converted to a synonym.
*/
} else if (tok == FI_) {
newtok (ENDIF_)
/*
Is it a function name? These may be ambiguous.
*/
} else if (tok >= LOW_FUNCTION && tok <= HIGH_FUNCTION) {
/*
Look ahead to find out whether the next token is a left parenthesis (or a colon).
*/
integer jkar;
jkar = ikar + 1;
while (Melder_isHorizontalSpace (theExpression [jkar]))
jkar ++;
if (theExpression [jkar] == U'(' || theExpression [jkar] == U':') {
newtok (tok) // this must be a function name
} else if (theExpression [jkar] == U'[' && rank == 0) {
if (isString) {
newtok (INDEXED_STRING_VARIABLE_)
} else {
newtok (INDEXED_NUMERIC_VARIABLE_)
}
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else {
/*
This could be a variable with the same name as a function.
*/
const InterpreterVariable var = Interpreter_hasVariable (theInterpreter, token.string);
if (! var) {
newtok (VARIABLE_NAME_)
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else {
if (rank == 0) {
if (isString) {
newtok (STRING_VARIABLE_)
} else {
newtok (NUMERIC_VARIABLE_)
}
} else if (rank == 1) {
if (isString) {
newtok (STRING_ARRAY_VARIABLE_)
} else {
newtok (NUMERIC_VECTOR_VARIABLE_)
}
} else if (rank == 2) {
if (isString) {
formulaError (U"String matrices not implemented.", ikar);
} else {
newtok (NUMERIC_MATRIX_VARIABLE_)
}
} else if (rank == 3) {
formulaError (U"Rank-3 tensors not implemented.", ikar);
} else {
formulaError (U"Rank-4 tensors not implemented.", ikar);
}
lexan [itok]. content.variable = var;
}
}
/*
Not a function name.
Must be a language name (if, then, else, endif, or, and, not, div, mod, x, ncol, stopwatch).
Some can be used as variable names (x, ncol...).
*/
} else if (tok >= LOW_ATTRIBUTE && tok <= HIGH_ATTRIBUTE) {
/*
Look back to find out whether this is an attribute.
*/
if (itok > 0 && lexan [itok]. symbol == PERIOD_) {
/*
This must be an attribute that follows a period.
*/
newtok (tok)
} else if (theSource) {
/*
Look for ambiguity.
*/
if (Interpreter_hasVariable (theInterpreter, token.string))
Melder_throw (
U"«", token.string,
U"» is ambiguous: a variable or an attribute of the current object. "
U"Please change variable name.");
if (tok == ROW_ || tok == COL_ || tok == X_ || tok == Y_) {
newtok (tok)
} else {
newtok (MATRIX_)
tokmatrix (theSource);
newtok (PERIOD_)
newtok (tok)
}
} else {
/*
This must be a variable, since there is no "current object" here.
*/
integer jkar = ikar + 1;
while (Melder_isHorizontalSpace (theExpression [jkar])) jkar ++;
if (theExpression [jkar] == U'[' && rank == 0) {
if (isString) {
newtok (INDEXED_STRING_VARIABLE_)
} else {
newtok (INDEXED_NUMERIC_VARIABLE_)
}
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else {
const InterpreterVariable var = Interpreter_hasVariable (theInterpreter, token.string);
if (! var) {
newtok (VARIABLE_NAME_)
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else {
if (rank == 0) {
if (isString) {
newtok (STRING_VARIABLE_)
} else {
newtok (NUMERIC_VARIABLE_)
}
} else if (rank == 1) {
if (isString) {
newtok (STRING_ARRAY_VARIABLE_)
} else {
newtok (NUMERIC_VECTOR_VARIABLE_)
}
} else if (rank == 2) {
if (isString) {
formulaError (U"String matrices not implemented.", ikar);
} else {
newtok (NUMERIC_MATRIX_VARIABLE_)
}
} else if (rank == 3) {
formulaError (U"Rank-3 tensors not implemented.", ikar);
} else {
formulaError (U"Rank-4 tensors not implemented.", ikar);
}
lexan [itok]. content.variable = var;
}
}
}
} else {
newtok (tok) // this must be a language name
}
} else {
/*
token.string is not a language name
*/
integer jkar = ikar + 1;
while (Melder_isHorizontalSpace (theExpression [jkar]))
jkar ++;
if (theExpression [jkar] == U'(' || theExpression [jkar] == U':') {
Melder_throw (
U"Unknown function «", token.string, U"» in formula.");
} else if (theExpression [jkar] == '[' && rank == 0) {
if (isString) {
newtok (INDEXED_STRING_VARIABLE_)
} else {
newtok (INDEXED_NUMERIC_VARIABLE_)
}
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else {
InterpreterVariable var = Interpreter_hasVariable (theInterpreter, token.string);
if (! var) {
newtok (VARIABLE_NAME_)
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else {
if (rank == 0) {
if (isString) {
newtok (STRING_VARIABLE_)
} else {
newtok (NUMERIC_VARIABLE_)
}
} else if (rank == 1) {
if (isString) {
newtok (STRING_ARRAY_VARIABLE_)
} else {
newtok (NUMERIC_VECTOR_VARIABLE_)
}
} else if (rank == 2) {
if (isString) {
formulaError (U"String matrices not implemented.", ikar);
} else {
newtok (NUMERIC_MATRIX_VARIABLE_)
}
} else if (rank == 3) {
formulaError (U"Rank-3 tensors not implemented.", ikar);
} else {
formulaError (U"Rank-4 tensors not implemented.", ikar);
}
lexan [itok]. content.variable = var;
}
}
}
} else if (kar >= U'A' && kar <= U'Z') {
bool endsInDollarSign = false;
stringtokon;
do stringtokchar while (Melder_isAlphanumeric (kar) || kar == U'_');
if (kar == U'$') {
stringtokchar
endsInDollarSign = true;
}
stringtokoff;
oldchar;
/*
* 'token' now contains a word that could be an object name.
*/
char32 *underscore = str32chr (token.string, '_');
if (str32equ (token.string, U"Self")) {
if (! theSource)
formulaError (U"Cannot use \"Self\" if there is no current object.", ikar);
newtok (MATRIX_)
tokmatrix (theSource);
} else if (str32equ (token.string, U"Self$")) {
if (! theSource)
formulaError (U"Cannot use \"Self$\" if there is no current object.", ikar);
newtok (MATRIX_STR_)
tokmatrix (theSource);
} else if (! underscore) {
Melder_throw (
U"Unknown symbol «", token.string, U"» in formula "
U"(variables start with nonupper case; object names contain an underscore).");
} else if (str32nequ (token.string, U"Object_", 7)) {
const integer uniqueID = Melder_atoi (token.string + 7);
integer i = theCurrentPraatObjects -> n;
while (i > 0 && uniqueID != theCurrentPraatObjects -> list [i]. id)
i --;
if (i == 0)
formulaError (U"No such object (note: variables start with nonupper case)", ikar);
newtok (endsInDollarSign ? MATRIX_STR_ : MATRIX_)
tokmatrix ((Daata) theCurrentPraatObjects -> list [i]. object);
} else {
integer i = theCurrentPraatObjects -> n;
*underscore = U' ';
if (endsInDollarSign)
token.string [-- token.length] = U'\0';
while (i > 0 && ! str32equ (token.string, theCurrentPraatObjects -> list [i]. name.get()))
i --;
if (i == 0)
formulaError (U"No such object (note: variables start with nonupper case)", ikar);
newtok (endsInDollarSign ? MATRIX_STR_ : MATRIX_)
tokmatrix ((Daata) theCurrentPraatObjects -> list [i]. object);
}
} else if (kar == U'(') {
newtok (OPENING_PARENTHESIS_)
} else if (kar == U')') {
newtok (CLOSING_PARENTHESIS_)
} else if (kar == U'+') {
newtok (ADD_)
} else if (kar == U'-') {
if (itok == 0 || lexan [itok]. symbol <= MINUS_) {
newtok (MINUS_)
} else {
newtok (SUB_)
}
} else if (kar == U'*') {
newchar;
if (kar == U'*') {
newtok (POWER_) /* "**" = "^" */
} else {
oldchar;
newtok (MUL_)
}
} else if (kar == U'/') {
newchar;
if (kar == U'=') {
newtok (NE_) /* "/=" = "<>" */
} else {
oldchar;
newtok (RDIV_)
}
} else if (kar == U'=') {
newtok (EQ_) /* "=" */
newchar;
if (kar != U'=') {
oldchar; /* "==" = "=" */
}
} else if (kar == U'>') {
newchar;
if (kar == U'=') {
newtok (GE_)
} else {
oldchar;
newtok (GT_)
}
} else if (kar == U'<') {
newchar;
if (kar == U'=') {
newtok (LE_)
} else if (kar == U'>') {
newtok (NE_)
} else {
oldchar;
newtok (LT_)
}
} else if (kar == U'!') {
newchar;
if (kar == U'=') {
newtok (NE_) /* "!=" = "<>" */
} else {
oldchar;
newtok (NOT_)
}
} else if (kar == U',') {
newtok (COMMA_)
} else if (kar == U':') {
newtok (COLON_)
} else if (kar == U';') {
newtok (END_)
} else if (kar == U'^') {
newtok (POWER_)
} else if (kar == U'@') {
do {
newchar;
} while (Melder_isHorizontalSpace (kar));
stringtokon;
do stringtokchar while (Melder_isWordCharacter (kar) || kar == U'.');
stringtokoff;
oldchar;
newtok (CALL_)
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else if (kar == U'\"') {
/*
String constant.
*/
newchar;
stringtokon;
for (;;) {
if (kar == U'\0')
formulaError (U"No closing quote in string constant", ikar);
if (kar == U'\"') {
newchar;
if (kar == U'\"')
stringtokchar
else break;
} else {
stringtokchar
}
}
stringtokoff;
oldchar;
newtok (STRING_)
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else if (kar == U'~') {
/*
The content of the remainder of the line,
including any leading and trailing space,
will become a string constant (this is good for formulas).
*/
newchar;
stringtokon;
for (;;) {
if (kar == U'\0')
break;
stringtokchar
}
stringtokoff;
oldchar;
newtok (STRING_)
lexan [itok]. content.string = Melder_dup_f (token.string).transfer();
numberOfStringConstants ++;
} else if (kar == U'|') {
newtok (OR_) /* "|" = "or" */
newchar;
if (kar != U'|') {
oldchar; /* "||" = "or" */
}
} else if (kar == U'&') {
newtok (AND_) /* "&" = "and" */
newchar;
if (kar != U'&') {
oldchar; /* "&&" = "and" */
}
} else if (kar == U'[') {
newtok (OPENING_BRACKET_)
} else if (kar == U']') {
newtok (CLOSING_BRACKET_)
} else if (kar == U'{') {
newtok (OPENING_BRACE_)
} else if (kar == U'}') {
newtok (CLOSING_BRACE_)
} else if (kar == U'.') {
newtok (PERIOD_)
} else {
formulaError (U"Unknown symbol", ikar);
}
} while (lexan [itok]. symbol != END_);
}
static void fit (integer symbol) {
if (symbol == newread) {
return; // success
} else {
const conststring32 symbolName1 = Formula_instructionNames [symbol];
const conststring32 symbolName2 = Formula_instructionNames [lexan [ilexan]. symbol];
const bool needQuotes1 = ! str32chr (symbolName1, U' ');
const bool needQuotes2 = ! str32chr (symbolName2, U' ');
static MelderString message;
MelderString_copy (& message,
U"Expected ", ( needQuotes1 ? U"\"" : nullptr ), symbolName1, ( needQuotes1 ? U"\"" : nullptr ),
U", but found ", ( needQuotes2 ? U"\"" : nullptr ), symbolName2, ( needQuotes2 ? U"\"" : nullptr ));
formulaError (message.string, lexan [ilexan]. position);
}
}
static bool fitArguments () {
const integer symbol = newread;
if (symbol == OPENING_PARENTHESIS_)
return true; // success: a function call like: myFunction (...)
if (symbol == COLON_)
return false; // success: a function call like: myFunction: ...
const conststring32 symbolName2 = Formula_instructionNames [lexan [ilexan]. symbol];
const bool needQuotes2 = ! str32chr (symbolName2, U' ');
static MelderString message;
MelderString_copy (& message,
U"Expected \"(\" or \":\", but found ", ( needQuotes2 ? U"\"" : nullptr ), symbolName2, ( needQuotes2 ? U"\"" : nullptr ));
formulaError (message.string, lexan [ilexan]. position);
return false; // will never occur
}
#define newparse(s) parse [++ iparse]. symbol = (s)
#define parsenumber(g) parse [iparse]. content.number = (g)
#define parselabel(l) parse [iparse]. content.label = (l)
static void parseExpression ();
static void parsePowerFactor () {
integer symbol = newread;
if (symbol >= LOW_VALUE && symbol <= HIGH_VALUE) {
newparse (symbol);
if (symbol == NUMBER_) parsenumber (lexan [ilexan]. content.number);
return;
}
if (symbol == STRING_) {
newparse (symbol);
parse [iparse]. content.string = lexan [ilexan]. content.string; // reference copy!
return;
}
if (symbol == NUMERIC_VARIABLE_ || symbol == STRING_VARIABLE_) {
newparse (symbol);
parse [iparse]. content.variable = lexan [ilexan]. content.variable;
return;
}
if (symbol == INDEXED_NUMERIC_VARIABLE_ || symbol == INDEXED_STRING_VARIABLE_) {
char32 *var = lexan [ilexan]. content.string; // Save before incrementing ilexan.
if (newread == OPENING_BRACKET_) {
int n = 0;
if (newread != CLOSING_BRACKET_) {
oldread;
parseExpression ();
n ++;
while (newread == COMMA_) {
parseExpression ();
n ++;
}
oldread;
fit (CLOSING_BRACKET_);
}
newparse (NUMBER_); parsenumber (n);
newparse (symbol);
} else {
Melder_fatal (U"Formula:parsePowerFactor (indexed variable): No '['; cannot happen.");
}
parse [iparse]. content.string = var;
return;
}
if (symbol == NUMERIC_VECTOR_VARIABLE_) {
const InterpreterVariable var = lexan [ilexan]. content.variable; // save before incrementing ilexan
if (newread == OPENING_BRACKET_) {
parseExpression ();
fit (CLOSING_BRACKET_);
newparse (VEC_CELL_);
} else {
oldread;
newparse (NUMERIC_VECTOR_VARIABLE_);