Debian Codegraph @

sys/Interpreter.cpp

raw symbols SCIP
1 /* Interpreter.cpp
2 *
3 * Copyright (C) 1993-2026 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Interpreter.h"cxx . . $ `<file>/sys/Interpreter.h`/
20 #include "praatP.h"cxx . . $ `<file>/sys/praatP.h`/
21 #include "praat_script.h"cxx . . $ `<file>/sys/praat_script.h`/
22 #include "UiPause.h"cxx . . $ `<file>/sys/UiPause.h`/
23 #include "DemoEditor.h"cxx . . $ `<file>/sys/DemoEditor.h`/
24 #include "Formula.h"cxx . . $ `<file>/sys/Formula.h`/
25 #include "Notebook.h"cxx . . $ `<file>/sys/Notebook.h`/
26 #include "../kar/UnicodeData.h"cxx . . $ `<file>/kar/UnicodeData.h`/
27
28 #include "../fon/Vector.h"cxx . . $ `<file>/fon/Vector.h`/
29 #include "../dwsys/NUMsorting.h"cxx . . $ `<file>/dwsys/NUMsorting.h`/
30
31 #define Interpreter_WORDcxx . . $ `sys/Interpreter.cpp:31:9`! 1
32 #define Interpreter_SENTENCEcxx . . $ `sys/Interpreter.cpp:32:9`! 2
33 #define Interpreter_TEXTcxx . . $ `sys/Interpreter.cpp:33:9`! 3
34 #define Interpreter_INFILEcxx . . $ `sys/Interpreter.cpp:34:9`! 4
35 #define Interpreter_OUTFILEcxx . . $ `sys/Interpreter.cpp:35:9`! 5
36 #define Interpreter_FOLDERcxx . . $ `sys/Interpreter.cpp:36:9`! 6
37
38 #define Interpreter_REALcxx . . $ `sys/Interpreter.cpp:38:9`! 7
39 #define Interpreter_NONNEGATIVEcxx . . $ `sys/Interpreter.cpp:39:9`! 8
40 #define Interpreter_POSITIVEcxx . . $ `sys/Interpreter.cpp:40:9`! 9
41 #define Interpreter_INTEGERcxx . . $ `sys/Interpreter.cpp:41:9`! 10
42 #define Interpreter_NATURAL0cxx . . $ `sys/Interpreter.cpp:42:9`! 11
43 #define Interpreter_NATURAL1cxx . . $ `sys/Interpreter.cpp:43:9`! 12
44 #define Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`! 13
45 #define Interpreter_MINIMUM_TYPE_FOR_NUMERIC_VARIABLEcxx . . $ `sys/Interpreter.cpp:45:9`! Interpreter_REALcxx . . $ `sys/Interpreter.cpp:38:9`!
46 #define Interpreter_MAXIMUM_TYPE_FOR_NUMERIC_VARIABLEcxx . . $ `sys/Interpreter.cpp:46:9`! Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`!
47
48 #define Interpreter_REALVECTORcxx . . $ `sys/Interpreter.cpp:48:9`! 14
49 #define Interpreter_NONNEGATIVEVECTORcxx . . $ `sys/Interpreter.cpp:49:9`! 15
50 #define Interpreter_POSITIVEVECTORcxx . . $ `sys/Interpreter.cpp:50:9`! 16
51 #define Interpreter_INTEGERVECTORcxx . . $ `sys/Interpreter.cpp:51:9`! 17
52 #define Interpreter_NATURAL0VECTORcxx . . $ `sys/Interpreter.cpp:52:9`! 18
53 #define Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`! 19
54 #define Interpreter_MINIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:54:9`! Interpreter_REALVECTORcxx . . $ `sys/Interpreter.cpp:48:9`!
55 #define Interpreter_MAXIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:55:9`! Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`!
56
57 #define Interpreter_REALMATRIXcxx . . $ `sys/Interpreter.cpp:57:9`! 20
58 #define Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`! 21
59 #define Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`! 22
60 #define Interpreter_MAXIMUM_TYPE_WITH_VARIABLE_NAMEcxx . . $ `sys/Interpreter.cpp:60:9`! Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!
61
62 #define Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`! 23
63 #define Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`! 24
64 #define Interpreter_HEADINGcxx . . $ `sys/Interpreter.cpp:64:9`! 25
65 #define Interpreter_COMMENTcxx . . $ `sys/Interpreter.cpp:65:9`! 26
66 #define Interpreter_CAPTIONcxx . . $ `sys/Interpreter.cpp:66:9`! 27
67
68 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (InterpreterVariable, SimpleString, 0);
69
70 static autoInterpreterVariablecxx . . $ autoInterpreterVariable# InterpreterVariable_createcxx . . $ InterpreterVariable_create(37a296c0d921936f). (conststring32cxx . . $ conststring32# key) {
71 try {
72 if (key [0] == U'e' && key [1] == U'\0')
73 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot use “e” as the name of a variable (e is the constant 2.71...).");
74 if (key [0] == U'p' && key [1] == U'i' && key [2] == U'\0')
75 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot use “pi” as the name of a variable (pi is the constant 3.14...).");
76 if (key [0] == U'u' && key [1] == U'n' && key [2] == U'd' && key [3] == U'e' && key [4] == U'f' && key [5] == U'i' &&
77 key [6] == U'n' && key [7] == U'e' && key [8] == U'd' && key [9] == U'\0')
78 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot use “undefined” as the name of a variable.");
79 if (key [0] == U's' && key [1] == U't' && key [2] == U'o' && key [3] == U'p' && key [4] == U'w' && key [5] == U'a' &&
80 key [6] == U't' && key [7] == U'c' && key [8] == U'h' && key [9] == U'\0')
81 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot use “stopwatch” as the name of a variable.");
82 autoInterpreterVariablecxx . . $ autoInterpreterVariable# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (InterpreterVariable);
83 mycxx . . $ `melder/melder.h:44:9`! stringcxx . . $ structSimpleString#string. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (key);
84 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
85 } catch (MelderErrorcxx . . $ MelderError#) {
86 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Interpreter variable not created.");
87 }
88 }
89
90 conststring32cxx . . $ conststring32# kInterpreter_ReturnType_errorMessagecxx . . $ kInterpreter_ReturnType_errorMessage(bccbfafe1c371207). (kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType# returnType, conststring32cxx . . $ conststring32# command) {
91 switch (returnType) {
92 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::VOID_cxx . . $ kInterpreter_ReturnType#VOID_.:
93 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" does not return anything");
94 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::OBJECT_cxx . . $ kInterpreter_ReturnType#OBJECT_.:
95 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" returns an object");
96 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REAL_cxx . . $ kInterpreter_ReturnType#REAL_.:
97 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::INTEGER_cxx . . $ kInterpreter_ReturnType#INTEGER_.:
98 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" returns a number or a string");
99 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::STRING_cxx . . $ kInterpreter_ReturnType#STRING_.:
100 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" returns a string");
101 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REALVECTOR_cxx . . $ kInterpreter_ReturnType#REALVECTOR_.:
102 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::INTEGERVECTOR_cxx . . $ kInterpreter_ReturnType#INTEGERVECTOR_.:
103 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" returns a vector");
104 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REALMATRIX_cxx . . $ kInterpreter_ReturnType#REALMATRIX_.:
105 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" returns a matrix");
106 case kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::STRINGARRAY_cxx . . $ kInterpreter_ReturnType#STRINGARRAY_.:
107 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" returns a string array");
108 default:
109 return Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (U"The command \"", command, U"\" has an unknown return type");
110 }
111 }
112
113 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Interpreter, Thing, 0);
114
115 static CollectionOfcxx . . $ CollectionOf# <structInterpretercxx . . $ structInterpreter#> theReferencesToAllLivingInterpreterscxx . . $ theReferencesToAllLivingInterpreters.;
116
117 /* global */ structInterpreterStackcxx . . $ structInterpreterStack# theInterpreterStackcxx . . $ theInterpreterStack.;
118
119 void structInterpretercxx . . $ structInterpreter# :: v9_destroycxx . . $ structInterpreter#v9_destroy(ced63f7c635d850d). () noexcept {
120 theReferencesToAllLivingInterpreterscxx . . $ theReferencesToAllLivingInterpreters.. undangleItemcxx . . $ CollectionOf#undangleItem(97cddd01752945f6). (this);
121 UiPause_interpreterGoesAwaycxx . . $ UiPause_interpreterGoesAway(448c181fe9dacca8). (this);
122 Demo_interpreterGoesAwaycxx . . $ Demo_interpreterGoesAway(448c181fe9dacca8). (this);
123 ourcxx . . $ `melder/melder.h:42:9`! Interpreter_Parentcxx . . $ Interpreter_Parent# :: v9_destroycxx . . $ structThing#v9_destroy(ced63f7c635d850d). ();
124 }
125
126 autoInterpretercxx . . $ autoInterpreter# Interpreter_createFromEnvironmentcxx . . $ Interpreter_createFromEnvironment(2a446a9b6f15a803). (InterpreterStackcxx . . $ InterpreterStack# interpreterStack, Editorcxx . . $ Editor# optionalInterpreterOwningEditor, MelderFilecxx . . $ MelderFile# optionalFile) {
127 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (interpreterStack);
128 try {
129 autoInterpretercxx . . $ autoInterpreter# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Interpreter);
130 mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. = interpreterStack;
131 if (optionalFile) {
132 MelderFile_copycxx . . $ MelderFile_copy(b298201f6d539a65). (optionalFile, & mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structInterpreter#file.);
133 /*
134 As for the working directory, put it in canonical form, i.e. don't use only MelderFile_getParentFolder(). TODO: make MelderFile_getParentFolder canonical
135 */
136 {// scope
137 autoMelderFileSetCurrentFoldercxx . . $ autoMelderFileSetCurrentFolder# foldercxx . . $ autoMelderFileSetCurrentFolder#autoMelderFileSetCurrentFolder(1145552d769d7b5d). (& mycxx . . $ `melder/melder.h:44:9`! filecxx . . $ structInterpreter#file.);
138 Melder_getCurrentFoldercxx . . $ Melder_getCurrentFolder(63f38d3b6b86d1dc). (& mycxx . . $ `melder/melder.h:44:9`! workingDirectorycxx . . $ structInterpreter#workingDirectory.);
139 }
140 } else {
141 Melder_getCurrentFoldercxx . . $ Melder_getCurrentFolder(63f38d3b6b86d1dc). (& mycxx . . $ `melder/melder.h:44:9`! workingDirectorycxx . . $ structInterpreter#workingDirectory.); // last resort; TODO: figure out how useful this is
142 }
143 mycxx . . $ `melder/melder.h:44:9`! setOwningEditorEnvironmentFromOptionalEditorcxx . . $ structInterpreter#setOwningEditorEnvironmentFromOptionalEditor(804f629ae7a06da5). (optionalInterpreterOwningEditor);
144 mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap.. max_load_factorcxx . . $ std/unordered_map#max_load_factor(9364e6e7bff7660). (0.65f);
145 theReferencesToAllLivingInterpreterscxx . . $ theReferencesToAllLivingInterpreters.. addItem_refcxx . . $ CollectionOf#addItem_ref(ebd0a1552f8ce24f). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
146 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
147 } catch (MelderErrorcxx . . $ MelderError#) {
148 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Interpreter not created.");
149 }
150 }
151
152 void Interpreters_undangleEnvironmentcxx . . $ Interpreters_undangleEnvironment(804f629ae7a06da5). (Editorcxx . . $ Editor# environment) noexcept {
153 for (integercxx . . $ integer# i = 1; i <= theReferencesToAllLivingInterpreterscxx . . $ theReferencesToAllLivingInterpreters..sizecxx . . $ CollectionOf#size.; i ++) {
154 const Interpretercxx . . $ Interpreter# interpreter = theReferencesToAllLivingInterpreterscxx . . $ theReferencesToAllLivingInterpreters..atcxx . . $ CollectionOf#at. [cxx . . $ ArrayOf#`operator[]`(a7f36fee1ae21897).i];
155 if (interpreter -> optionalOwningEnvironmentEditorcxx . . $ structInterpreter#optionalOwningEnvironmentEditor(480fba2ddcd094f3).() == environment)
156 interpreter -> undangleOwningEditorcxx . . $ structInterpreter#undangleOwningEditor(ced63f7c635d850d).();
157 if (interpreter -> optionalDynamicEnvironmentEditorcxx . . $ structInterpreter#optionalDynamicEnvironmentEditor(480fba2ddcd094f3).() == environment)
158 interpreter -> undangleDynamicEditorcxx . . $ structInterpreter#undangleDynamicEditor(ced63f7c635d850d).();
159 }
160 }
161
162 void Interpreter_rememberScriptcxx . . $ Interpreter_rememberScript(a0c4c87353b136f2). (Interpretercxx . . $ Interpreter# me, MelderFilecxx . . $ MelderFile# scriptFile, const bool fullTrust) {
163 if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (scriptFile))
164 return;
165 autoScriptcxx . . $ autoScript# script = Script_createFromFilecxx . . $ Script_createFromFile(bd133301ef0e84d8). (scriptFile);
166 Script_rememberDuringThisAppSession_movecxx . . $ Script_rememberDuringThisAppSession_move(76c604abe5acc916). (scriptcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
167 mycxx . . $ `melder/melder.h:44:9`! scriptReferencecxx . . $ structInterpreter#scriptReference. = Script_findcxx . . $ Script_find(121335aa8b01ec30). (MelderFile_peekPathcxx . . $ MelderFile_peekPath(d9f043369fa9b55b). (scriptFile));
168 mycxx . . $ `melder/melder.h:44:9`! scriptReferencecxx . . $ structInterpreter#scriptReference. -> trustedcxx . . $ structScript#trusted. |= fullTrust;
169 }
170 void Interpreter_rememberScript_overridecxx . . $ Interpreter_rememberScript_override(a0c4c87353b136f2). (Interpretercxx . . $ Interpreter# me, MelderFilecxx . . $ MelderFile# scriptFile, const bool fullTrust) {
171 if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (scriptFile))
172 return;
173 autoScriptcxx . . $ autoScript# script = Script_createFromFilecxx . . $ Script_createFromFile(bd133301ef0e84d8). (scriptFile);
174 Script_rememberDuringThisAppSession_movecxx . . $ Script_rememberDuringThisAppSession_move(76c604abe5acc916). (scriptcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
175 mycxx . . $ `melder/melder.h:44:9`! scriptReferencecxx . . $ structInterpreter#scriptReference. = Script_findcxx . . $ Script_find(121335aa8b01ec30). (MelderFile_peekPathcxx . . $ MelderFile_peekPath(d9f043369fa9b55b). (scriptFile));
176 mycxx . . $ `melder/melder.h:44:9`! scriptReferencecxx . . $ structInterpreter#scriptReference. -> trustedcxx . . $ structScript#trusted. = fullTrust;
177 }
178
179 void Interpreter_rememberNotebookcxx . . $ Interpreter_rememberNotebook(a0c4c87353b136f2). (Interpretercxx . . $ Interpreter# me, MelderFilecxx . . $ MelderFile# notebookFile, const bool fullTrust) {
180 TRACEcxx . . $ `melder/melder_debug.h:54:9`!
181 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Remembering notebook file ", notebookFile);
182 if (MelderFile_isNullcxx . . $ MelderFile_isNull(8f92cdf95b27d908). (notebookFile))
183 return;
184 autoNotebookcxx . . $ autoNotebook# notebook = Notebook_createFromFilecxx . . $ Notebook_createFromFile(64697f3e1bb41e11). (notebookFile);
185 Notebook_rememberDuringThisAppSession_movecxx . . $ Notebook_rememberDuringThisAppSession_move(c9c21ebc9b8f53bb). (notebookcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f)..movecxx . . $ autoSomeThing#move(25acc3554b7d1642).());
186 mycxx . . $ `melder/melder.h:44:9`! notebookReferencecxx . . $ structInterpreter#notebookReference. = Notebook_findcxx . . $ Notebook_find(e3de9a51e4137ebd). (MelderFile_peekPathcxx . . $ MelderFile_peekPath(d9f043369fa9b55b). (notebookFile));
187 mycxx . . $ `melder/melder.h:44:9`! notebookReferencecxx . . $ structInterpreter#notebookReference. -> trustedcxx . . $ structNotebook#trusted. |= fullTrust;
188 }
189
190 static bool Melder_scriptTextIsNotebookTextcxx . . $ Melder_scriptTextIsNotebookText(2df281243f91fe91). (conststring32cxx . . $ conststring32# text) {
191 /*
192 Notebooks start with a opening double quote.
193 Alternatively, notebooks tend to contain opening and closing braces
194 in the first position of some line,
195 but that cue is not reliable,
196 because some notebooks contain no code chunks at all.
197 */
198 return text [0] == U'"';
199 }
200
201 void Melder_includeIncludeFilescxx . . $ Melder_includeIncludeFiles(2d5e149ff849c92b). (autostring32cxx . . $ autostring32# *inout_text, bool onlyInCodeChunks) {
202 for (int depth = 0; ; depth ++) {
203 char32cxx . . $ char32# *head = inout_text->getcxx . . $ _autostring#get(5a2a78a048fb49a8).();
204 integercxx . . $ integer# numberOfIncludes = 0;
205 if (depth > 10)
206 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Include files nested too deep. Probably cyclic.");
207 for (;;) {
208 char32cxx . . $ char32# *includeLocation, *includeFileName, *tail;
209 /*
210 Look for an include statement. If not found, we have finished.
211 */
212 includeLocation = ( str32nequcxx . . $ `melder/melder_str32.h:123:9`! (head, U"include ", 8) ? head : str32strcxx . . $ str32str(2de17cd8f7c584a6). (head, U"\ninclude ") );
213 if (! includeLocation)
214 break;
215 if (includeLocation != head)
216 includeLocation += 1;
217 if (onlyInCodeChunks) {
218 if (includeLocation == head)
219 continue; // if the text starts with "include", it cannot be within a code chunk
220 integercxx . . $ integer# braceDepth = 0;
221 for (const char32cxx . . $ char32# *p = head; p != includeLocation; p ++)
222 if (Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (*p)) {
223 if (p [1] == U'{') {
224 if (braceDepth > 0)
225 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Opening brace within a code chunk. Don't know whether or not to include an include file.");
226 braceDepth += 1;
227 } else if (p [1] == U'}') {
228 if (braceDepth <= 0)
229 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Closing brace outside a code chunk. Don't know whether or not to include an include file.");
230 braceDepth -= 1;
231 }
232 }
233 if (braceDepth == 0) {
234 head = includeLocation + 8;
235 continue;
236 }
237 }
238 numberOfIncludes += 1;
239 /*
240 Separate out the head.
241 */
242 *includeLocation = U'\0';
243 /*
244 Separate out the name of the include file.
245 */
246 includeFileName = includeLocation + 8;
247 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& includeFileName);
248 tail = includeFileName;
249 while (Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*tail))
250 tail ++;
251 if (*tail != U'\0') {
252 *tail = U'\0';
253 tail += 1;
254 }
255 /*
256 Get the contents of the include file.
257 */
258 structMelderFilecxx . . $ structMelderFile# includeFile { };
259 Melder_relativePathToFilecxx . . $ Melder_relativePathToFile(82691f2ee21fbb13). (includeFileName, & includeFile);
260 autostring32cxx . . $ autostring32# includeTextcxx . . $ _autostring#_autostring(49f6e7a06ebc5aa8).;
261 try {
262 includeText =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). MelderFile_readTextcxx . . $ MelderFile_readText(2312d39ae70aea26). (& includeFile);
263 } catch (MelderErrorcxx . . $ MelderError#) {
264 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Include file ", & includeFile, U" not read.");
265 }
266 /*
267 Construct the new text.
268 */
269 const integercxx . . $ integer# headLength = (head - inout_text->getcxx . . $ _autostring#get(5a2a78a048fb49a8).()) + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (head);
270 const integercxx . . $ integer# includeTextLength = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (includeText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
271 const integercxx . . $ integer# newLength = headLength + includeTextLength + 1 + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (tail);
272 autostring32cxx . . $ autostring32# newTextcxx . . $ _autostring#_autostring(f153f132b2bc41c2). (newLength);
273 str32cpycxx . . $ str32cpy(6ab934322573b179). (newText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), inout_text->getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
274 str32cpycxx . . $ str32cpy(6ab934322573b179). (newText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + headLength, includeText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
275 str32cpycxx . . $ str32cpy(6ab934322573b179). (newText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + headLength + includeTextLength, U"\n");
276 str32cpycxx . . $ str32cpy(6ab934322573b179). (newText.getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + headLength + includeTextLength + 1, tail);
277 /*
278 Replace the old text with the new. This will work even within an autostring.
279 */
280 *inout_text =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). newText.movecxx . . $ _autostring#move(bd43c759570f178f).();
281 /*
282 Cycle.
283 */
284 head = inout_text->getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + headLength + includeTextLength + 1;
285 }
286 if (numberOfIncludes == 0)
287 break;
288 }
289 }
290
291 static bool parameterMatchesLabelcxx . . $ parameterMatchesLabel(1652f10ed0f82783). (conststring32cxx . . $ conststring32# parameter, conststring32cxx . . $ conststring32# label) {
292 /*
293 A parameter matches a label if they are equal or if
294 the label has an additional opening parenthesis, optionally preceded by a space.
295 For example, the parameter "Pitch ceiling" matches the label "Pitch ceiling (Hz)".
296 */
297 for (; *parameter != U'\0' && *label != U'\0'; parameter ++, label ++)
298 if (*parameter != *label)
299 return false;
300 if (*parameter == U'\0')
301 if (*label == U'\0' || *label == U'(' || *label == U' ' && label [1] == U'(')
302 return true;
303 return false;
304 }
305
306 integercxx . . $ integer# Interpreter_readParameterscxx . . $ Interpreter_readParameters(9dd4ed1655057857). (Interpretercxx . . $ Interpreter# me, mutablestring32cxx . . $ mutablestring32# text) {
307 const bool scriptTextIsNotebookText = Melder_scriptTextIsNotebookTextcxx . . $ Melder_scriptTextIsNotebookText(2df281243f91fe91). (text);
308 char32cxx . . $ char32# *formLocation = nullptr;
309 integercxx . . $ integer# npar = 0;
310 mycxx . . $ `melder/melder.h:44:9`! dialogTitlecxx . . $ structInterpreter#dialogTitle.. resetcxx . . $ _autostring#reset(49f6e7a06ebc5aa8).();
311 autoMelderStringcxx . . $ autoMelderString# stringcxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
312 /*
313 Look for a "form" line.
314 */
315 {// scope
316 integercxx . . $ integer# braceDepth = 0;
317 char32cxx . . $ char32# *p = & text [0];
318 for (;;) {
319 /*
320 Check invariant here: we are at the beginning of a line.
321 */
322 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (p == text || Melder_isEndOfLine (p [-1]));
323
324 if (scriptTextIsNotebookText) {
325 if (*p == U'{') {
326 if (braceDepth > 0)
327 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Opening brace within a code chunk. Don't know how to look for a `form`.");
328 braceDepth += 1;
329 } else if (*p == U'}') {
330 if (braceDepth <= 0)
331 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Closing brace outside a code chunk. Don't know how to look for a `form`.");
332 braceDepth -= 1;
333 }
334 if (braceDepth > 0) {
335 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
336 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (p, U"form", 4) && (p [4] == U':' || Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (p [4]))) {
337 formLocation = p;
338 break;
339 }
340 }
341 } else {
342 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
343 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (p, U"form", 4) && (p [4] == U':' || Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (p [4]))) {
344 formLocation = p;
345 break;
346 }
347 }
348 Melder_skipToEndOfLinecxx . . $ Melder_skipToEndOfLine(28edbb7a9cd1ae27). (& p);
349 if (*p == U'\0')
350 break;
351 p ++; // skip newline symbol
352 }
353 }
354 /*
355 If there is no "form" line, there are no parameters.
356 */
357 if (formLocation) {
358 char32cxx . . $ char32# *dialogTitle = Melder_findEndOfHorizontalSpacecxx . . $ Melder_findEndOfHorizontalSpace(732f4804158f7631).
359 (formLocation [4] == U':' ? formLocation + 5 : formLocation + 4);
360 char32cxx . . $ char32# *endOfLine = Melder_findEndOfLinecxx . . $ Melder_findEndOfLine(732f4804158f7631). (dialogTitle);
361 if (*endOfLine == U'\0')
362 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unfinished form (only a “form” line).");
363 if (formLocation [4] == U':') {
364 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& string);
365 if (dialogTitle [0] != U'"')
366 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The title of a form should start with a double quote character (\").");
367 char32cxx . . $ char32#* p = dialogTitle + 1; // BUG: could be const (change Melder_skipHorizontalSpace())
368 for (; p < endOfLine; p ++) {
369 if (*p == U'"') {
370 if (p [1] == U'"') {
371 p ++;
372 continue;
373 } else
374 break;
375 }
376 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& string, *p);
377 }
378 if (*p != U'"')
379 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing quote character in the title of the form.");
380 p ++; // skip closing quote
381 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
382 if (! Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (*p) && *p != U';')
383 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray characters after closing quote in form title.");
384 mycxx . . $ `melder/melder.h:44:9`! dialogTitlecxx . . $ structInterpreter#dialogTitle. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (string.stringcxx . . $ MelderString#string.);
385 } else {
386 mycxx . . $ `melder/melder.h:44:9`! dialogTitlecxx . . $ structInterpreter#dialogTitle. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_ndupcxx . . $ Melder_ndup(c02f217f21fae7fe). (dialogTitle, endOfLine - dialogTitle);
387 }
388 mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters. = 0;
389 while (true) {
390 int type = 0;
391 char32cxx . . $ char32# *startOfLine = Melder_findEndOfHorizontalSpacecxx . . $ Melder_findEndOfHorizontalSpace(732f4804158f7631). (endOfLine + 1);
392 /*
393 Skip empty lines and lines with comments.
394 */
395 while (*startOfLine == U'#' || *startOfLine == U';' || *startOfLine == U'!' || Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (*startOfLine)) {
396 endOfLine = Melder_findEndOfLinecxx . . $ Melder_findEndOfLine(732f4804158f7631). (startOfLine);
397 if (Melder_isEndOfTextcxx . . $ Melder_isEndOfText(b8d0204ce8416907). (*endOfLine))
398 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unfinished form (missing “endform”).");
399 startOfLine = Melder_findEndOfHorizontalSpacecxx . . $ Melder_findEndOfHorizontalSpace(732f4804158f7631). (endOfLine + 1);
400 }
401 endOfLine = Melder_findEndOfLinecxx . . $ Melder_findEndOfLine(732f4804158f7631). (startOfLine);
402 /*
403 Break on endform.
404 */
405 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"endform", 7) && Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (startOfLine [7]))
406 break;
407 /*
408 Recognize parameter name, argument value,
409 and perhaps format name and/or number of lines.
410 */
411 char32cxx . . $ char32# *p = nullptr;
412 bool hasColon = false;
413 auto isEndOfInkOrColon = [] (const char32cxx . . $ char32# kar) { return kar == U':' || Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (kar); };
414 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"word", 4) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [4])) {
415 type = Interpreter_WORDcxx . . $ `sys/Interpreter.cpp:31:9`!;
416 hasColon = ( startOfLine [4] == U':' );
417 p = startOfLine + 4 + hasColon;
418 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"sentence", 8) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [8])) {
419 type = Interpreter_SENTENCEcxx . . $ `sys/Interpreter.cpp:32:9`!;
420 hasColon = ( startOfLine [8] == U':' );
421 p = startOfLine + 8 + hasColon;
422 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"infile", 6) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [6])) {
423 type = Interpreter_INFILEcxx . . $ `sys/Interpreter.cpp:34:9`!;
424 hasColon = ( startOfLine [6] == U':' );
425 p = startOfLine + 6 + hasColon;
426 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"outfile", 7) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [7])) {
427 type = Interpreter_OUTFILEcxx . . $ `sys/Interpreter.cpp:35:9`!;
428 hasColon = ( startOfLine [7] == U':' );
429 p = startOfLine + 7 + hasColon;
430 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"folder", 6) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [6])) {
431 type = Interpreter_FOLDERcxx . . $ `sys/Interpreter.cpp:36:9`!;
432 hasColon = ( startOfLine [6] == U':' );
433 p = startOfLine + 6 + hasColon;
434 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"text", 4) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [4])) {
435 type = Interpreter_TEXTcxx . . $ `sys/Interpreter.cpp:33:9`!;
436 hasColon = ( startOfLine [4] == U':' );
437 p = startOfLine + 4 + hasColon;
438 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"real", 4) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [4])) {
439 type = Interpreter_REALcxx . . $ `sys/Interpreter.cpp:38:9`!;
440 hasColon = ( startOfLine [4] == U':' );
441 p = startOfLine + 4 + hasColon;
442 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"nonnegative", 11) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [11])) {
443 type = Interpreter_NONNEGATIVEcxx . . $ `sys/Interpreter.cpp:39:9`!;
444 hasColon = ( startOfLine [11] == U':' );
445 p = startOfLine + 11 + hasColon;
446 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"positive", 8) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [8])) {
447 type = Interpreter_POSITIVEcxx . . $ `sys/Interpreter.cpp:40:9`!;
448 hasColon = ( startOfLine [8] == U':' );
449 p = startOfLine + 8 + hasColon;
450 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"integer", 7) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [7])) {
451 type = Interpreter_INTEGERcxx . . $ `sys/Interpreter.cpp:41:9`!;
452 hasColon = ( startOfLine [7] == U':' );
453 p = startOfLine + 7 + hasColon;
454 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"natural0", 8) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [8])) {
455 type = Interpreter_NATURAL0cxx . . $ `sys/Interpreter.cpp:42:9`!;
456 hasColon = ( startOfLine [8] == U':' );
457 p = startOfLine + 8 + hasColon;
458 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"natural1", 8) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [8])) {
459 type = Interpreter_NATURAL1cxx . . $ `sys/Interpreter.cpp:43:9`!;
460 hasColon = ( startOfLine [8] == U':' );
461 p = startOfLine + 8 + hasColon;
462 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"natural", 7) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [7])) {
463 type = Interpreter_NATURAL1cxx . . $ `sys/Interpreter.cpp:43:9`!;
464 hasColon = ( startOfLine [7] == U':' );
465 p = startOfLine + 7 + hasColon;
466 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"boolean", 7) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [7])) {
467 type = Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`!;
468 hasColon = ( startOfLine [7] == U':' );
469 p = startOfLine + 7 + hasColon;
470 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"realvector", 10) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [10])) {
471 type = Interpreter_REALVECTORcxx . . $ `sys/Interpreter.cpp:48:9`!;
472 hasColon = ( startOfLine [10] == U':' );
473 p = startOfLine + 10 + hasColon;
474 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"nonnegativevector", 17) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [17])) {
475 type = Interpreter_NONNEGATIVEVECTORcxx . . $ `sys/Interpreter.cpp:49:9`!;
476 hasColon = ( startOfLine [17] == U':' );
477 p = startOfLine + 17 + hasColon;
478 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"positivevector", 14) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [14])) {
479 type = Interpreter_POSITIVEVECTORcxx . . $ `sys/Interpreter.cpp:50:9`!;
480 hasColon = ( startOfLine [14] == U':' );
481 p = startOfLine + 14 + hasColon;
482 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"integervector", 13) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [13])) {
483 type = Interpreter_INTEGERVECTORcxx . . $ `sys/Interpreter.cpp:51:9`!;
484 hasColon = ( startOfLine [13] == U':' );
485 p = startOfLine + 13 + hasColon;
486 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"natural0vector", 14) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [14])) {
487 type = Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`!;
488 hasColon = ( startOfLine [14] == U':' );
489 p = startOfLine + 14 + hasColon;
490 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"natural1vector", 14) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [14])) {
491 type = Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`!;
492 hasColon = ( startOfLine [14] == U':' );
493 p = startOfLine + 14 + hasColon;
494 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"naturalvector", 13) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [13])) {
495 type = Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`!;
496 hasColon = ( startOfLine [13] == U':' );
497 p = startOfLine + 13 + hasColon;
498 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"realmatrix", 10) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [10])) {
499 type = Interpreter_REALMATRIXcxx . . $ `sys/Interpreter.cpp:57:9`!;
500 hasColon = ( startOfLine [10] == U':' );
501 p = startOfLine + 10 + hasColon;
502 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"choice", 6) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [6])) {
503 type = Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`!;
504 hasColon = ( startOfLine [6] == U':' );
505 p = startOfLine + 6 + hasColon;
506 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"optionmenu", 10) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [10])) {
507 type = Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!;
508 hasColon = ( startOfLine [10] == U':' );
509 p = startOfLine + 10 + hasColon;
510 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"button", 6) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [6])) {
511 type = Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`!;
512 hasColon = ( startOfLine [6] == U':' );
513 p = startOfLine + 6 + hasColon;
514 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"option", 6) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [6])) {
515 type = Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`!;
516 hasColon = ( startOfLine [6] == U':' );
517 p = startOfLine + 6 + hasColon;
518 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (startOfLine, U"comment", 7) && isEndOfInkOrColon (cxx . . $ Interpreter_readParameters(9dd4ed1655057857).$anonymous_type_0#`operator()`(81c042403a1a357c).startOfLine [7])) {
519 type = Interpreter_COMMENTcxx . . $ `sys/Interpreter.cpp:65:9`!;
520 hasColon = ( startOfLine [7] == U':' );
521 p = startOfLine + 7 + hasColon;
522 } else {
523 *endOfLine = U'\0'; // destroy input in order to limit printing of parameter type
524 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown parameter type inside form:\n“", startOfLine, U"”.");
525 }
526 /*
527 Example:
528 form: "Something"
529 real: "Time (s)", "3.14 (= pi)"
530 choice: "Colour", 2
531 button: "Red"
532 button: "Green"
533 button: "Blue"
534 endform
535 my parameters [1] := "Time (s)"
536 my parameters [2] := "Colour"
537 my parameters [3] := ""
538 my parameters [4] := ""
539 my parameters [5] := ""
540 my arguments [1] := "3.14 (= pi)"
541 my arguments [2] := "2"
542 my arguments [3] := "Red" (funny, but needed in Interpreter_getArgumentsFromString)
543 my arguments [4] := "Green"
544 my arguments [5] := "Blue"
545 (last checked 2023-01-21)
546 */
547 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (p);
548 const mutablestring32cxx . . $ mutablestring32# parameter = mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [++ mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.];
549 if (type <= Interpreter_MAXIMUM_TYPE_WITH_VARIABLE_NAMEcxx . . $ `sys/Interpreter.cpp:60:9`!) {
550 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
551 if (Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (*p)) {
552 *p = U'\0'; // destroy input in order to limit printing of line
553 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing parameter:\n“", startOfLine, U"”.");
554 }
555 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& string);
556 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.] = 0;
557 if (hasColon) {
558 /*
559 Parse optional number-of-lines (including final comma).
560 */
561 if (Melder_isAsciiDecimalNumbercxx . . $ Melder_isAsciiDecimalNumber(b8d0204ce8416907). (*p)) {
562 if (!(
563 type == Interpreter_TEXTcxx . . $ `sys/Interpreter.cpp:33:9`! ||
564 type == Interpreter_INFILEcxx . . $ `sys/Interpreter.cpp:34:9`! || type == Interpreter_OUTFILEcxx . . $ `sys/Interpreter.cpp:35:9`! || type == Interpreter_FOLDERcxx . . $ `sys/Interpreter.cpp:36:9`! ||
565 type >= Interpreter_MINIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:54:9`! &&
566 type <= Interpreter_MAXIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:55:9`!
567 )) {
568 *(p + 1) = U'\0';
569 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Only “text”, “infile”, “outfile”, “folder” and vector and matrix types "
570 "support setting the number of lines in a form.");
571 }
572 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.] = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (p);
573 p ++;
574 while (Melder_isAsciiDecimalNumbercxx . . $ Melder_isAsciiDecimalNumber(b8d0204ce8416907). (*p))
575 p ++;
576 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
577 if (*p != U',') {
578 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
579 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing comma after number of lines:\n", startOfLine);
580 }
581 p ++; // skip comma
582 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
583 }
584 /*
585 Parse obligatory variable name (including final comma).
586 */
587 if (*p != U'"') {
588 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
589 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing opening quote for parameter name in form field:\n", startOfLine);
590 }
591 p ++; // skip opening quote
592 for (; p < endOfLine; p ++) {
593 if (*p == U'"') {
594 if (p [1] == U'"') { // look ahead
595 p ++;
596 continue;
597 } else
598 break;
599 }
600 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& string, *p);
601 }
602 if (*p != U'"') {
603 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
604 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing quote character in parameter name:\n", startOfLine);
605 }
606 p ++; // skip closing quote
607 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
608 if (*p != U',') {
609 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
610 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing comma after parameter name:\n", startOfLine);
611 }
612 p ++; // skip comma
613 } else {
614 while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*p))
615 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& string, *(p ++));
616 }
617 MelderString_truncatecxx . . $ MelderString_truncate(dd386fb870eabd46). (& string, Interpreter_MAX_PARAMETER_LENGTHcxx . . $ `sys/Interpreter.h:40:9`!);
618 str32cpycxx . . $ str32cpy(6ab934322573b179). (parameter, string.stringcxx . . $ MelderString#string.);
619 parameter [string.lengthcxx . . $ MelderString#length.] = U'\0';
620 npar ++;
621 } else {
622 parameter [0] = U'\0';
623 }
624 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
625 /*
626 Parse format type.
627 */
628 if (type >= Interpreter_MINIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:54:9`! && type <= Interpreter_MAXIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:55:9`!) {
629 if (! hasColon) {
630 *p = U'\0';
631 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Vector fields in forms are available only if immediately followed by a colon:\n", startOfLine);
632 }
633 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& string);
634 if (Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (*p)) {
635 *p = U'\0'; // destroy input in order to limit printing of line
636 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing format:\n“", startOfLine, U"”.");
637 }
638 if (*p != U'"') {
639 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
640 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing opening quote for vector format:\n", startOfLine);
641 }
642 p ++; // skip opening quote
643 for (; p < endOfLine; p ++) {
644 if (*p == U'"') {
645 if (p [1] == U'"') { // look ahead
646 p ++;
647 continue;
648 } else
649 break;
650 }
651 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& string, *p);
652 }
653 if (*p != U'"') {
654 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
655 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing quote for vector format:\n", startOfLine);
656 }
657 p ++; // skip closing quote
658 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
659 if (*p != U',') {
660 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
661 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing comma after vector format:\n", startOfLine);
662 }
663 p ++; // skip comma
664 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
665 /*
666 Install format type.
667 */
668 MelderString_truncatecxx . . $ MelderString_truncate(dd386fb870eabd46). (& string, Interpreter_MAX_FORMAT_LENGTHcxx . . $ `sys/Interpreter.h:41:9`!);
669 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.], string.stringcxx . . $ MelderString#string.);
670 mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.] [string.lengthcxx . . $ MelderString#length.] = U'\0';
671 }
672 /*
673 Parse obligatory content of argument.
674 */
675 if (hasColon) {
676 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& string);
677 if (Melder_isAsciiDecimalNumbercxx . . $ Melder_isAsciiDecimalNumber(b8d0204ce8416907). (*p)) {
678 if (type != Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`! && type != Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`! && type != Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`!) {
679 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
680 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Only “choice”, “optionmenu” and “boolean” fields can take a number:\n", startOfLine);
681 }
682 const integercxx . . $ integer# value = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (p);
683 if (type == Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`! || type == Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!)
684 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& string, value);
685 else
686 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& string, value != 0 ? U'1' : U'0');
687 p ++; // skip first digit
688 while (Melder_isAsciiDecimalNumbercxx . . $ Melder_isAsciiDecimalNumber(b8d0204ce8416907). (*p))
689 p ++; // skip next digit
690 } else {
691 if (*p != U'"') {
692 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
693 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing opening quote after comma in form field:\n", startOfLine);
694 }
695 if (type == Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`! || type == Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!) {
696 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
697 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A “choice” field can take only a number, not a string:\n", startOfLine);
698 }
699 p ++; // skip opening quote
700 for (; p < endOfLine; p ++) {
701 if (*p == U'"') {
702 if (p [1] == U'"') {
703 p ++;
704 continue;
705 } else
706 break;
707 }
708 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& string, *p);
709 }
710 if (*p != U'"') {
711 *(p + 1) = U'\0'; // destroy input in order to limit printing of line
712 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing quote character in default argument:\n", startOfLine);
713 }
714 p ++; // skip closing quote
715 }
716 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
717 if (! Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (*p) && *p != U';')
718 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray characters after default argument in form title:\n", startOfLine);
719 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (string.stringcxx . . $ MelderString#string.);
720 } else {
721 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_ndupcxx . . $ Melder_ndup(c02f217f21fae7fe). (p, endOfLine - p);
722 }
723 mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.] = type;
724 if (Melder_isEndOfTextcxx . . $ Melder_isEndOfText(b8d0204ce8416907). (*endOfLine))
725 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unfinished form (missing “endform”).");
726 }
727 } else {
728 npar = mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters. = 0;
729 }
730 return npar;
731 }
732
733 static void tidyUpParameterNamescxx . . $ tidyUpParameterNames(a0a95604869f3378). (Interpretercxx . . $ Interpreter# me, integercxx . . $ integer# size) {
734 for (integercxx . . $ integer# ipar = 1; ipar <= size; ipar ++) {
735 mutablestring32cxx . . $ mutablestring32# p = mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar];
736 /*
737 Ignore buttons and comments again (after `size` was
738 made smaller than my numberOfParameters).
739 */
740 if (! *p)
741 continue;
742 /*
743 Change spaces to underscores.
744 This has to come before stripping.
745 */
746 for (p = mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar]; *p != U'\0'; p ++)
747 if (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*p))
748 *p = U'_';
749 /*
750 Strip parentheses off parameter name.
751 */
752 p = mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar];
753 if ((p = str32chrcxx . . $ str32chr(328a9ede0fba853a). (p, U'(')) != nullptr) {
754 *p = U'\0';
755 if (p - mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar] > 0 && p [-1] == U'_')
756 p [-1] = U'\0';
757 }
758 /*
759 Strip colon off parameter name.
760 */
761 p = mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar];
762 if (*p != U'\0' && p [Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (p) - 1] == U':')
763 p [Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (p) - 1] = U'\0';
764 }
765 }
766
767 autoUiFormcxx . . $ autoUiForm# Interpreter_createFormcxx . . $ Interpreter_createForm(cb75ceafc4a9bd55). (Interpretercxx . . $ Interpreter# me, GuiWindowcxx . . $ GuiWindow# parent, Editorcxx . . $ Editor# optionalEditor, conststring32cxx . . $ conststring32# path,
768 void (*okCallback) (UiFormcxx . . $ UiForm#, integercxx . . $ integer#, Stackelcxx . . $ Stackel#, conststring32cxx . . $ conststring32#, Interpretercxx . . $ Interpreter#, conststring32cxx . . $ conststring32#, bool, void *, Editorcxx . . $ Editor#), void *okClosure,
769 bool selectionOnly)
770 {
771 autoUiFormcxx . . $ autoUiForm# form = UiForm_createcxx . . $ UiForm_create(b3c832b012a1002d). (parent, optionalEditor,
772 Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (selectionOnly ? U"Run script (selection only): " : U"Run script: ", mycxx . . $ `melder/melder.h:44:9`! dialogTitlecxx . . $ structInterpreter#dialogTitle..getcxx . . $ _autostring#get(5a2a78a048fb49a8).()),
773 okCallback, okClosure, nullptr, nullptr
774 );
775 if (path)
776 form ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). scriptFilePathcxx . . $ structUiForm#scriptFilePath. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (path);
777 for (int ipar = 1; ipar <= mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.; ipar ++) {
778 /*
779 Convert underscores to spaces.
780 */
781 char32cxx . . $ char32# parameter [100], *p = & parameter [0];
782 str32cpycxx . . $ str32cpy(6ab934322573b179). (parameter, mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar]);
783 while (*p) {
784 if (*p == U'_')
785 *p = U' ';
786 p ++;
787 }
788 switch (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar]) {
789 case Interpreter_WORDcxx . . $ `sys/Interpreter.cpp:31:9`!: {
790 UiForm_addWordcxx . . $ UiForm_addWord(5d4a87e816a21170). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
791 } break; case Interpreter_SENTENCEcxx . . $ `sys/Interpreter.cpp:32:9`!: {
792 UiForm_addSentencecxx . . $ UiForm_addSentence(5d4a87e816a21170). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
793 } break; case Interpreter_TEXTcxx . . $ `sys/Interpreter.cpp:33:9`!: {
794 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
795 UiForm_addTextcxx . . $ UiForm_addText(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
796 else
797 UiForm_addTextcxx . . $ UiForm_addText(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
798 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
799 } break; case Interpreter_INFILEcxx . . $ `sys/Interpreter.cpp:34:9`!: {
800 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
801 UiForm_addInfilecxx . . $ UiForm_addInfile(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
802 else
803 UiForm_addInfilecxx . . $ UiForm_addInfile(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
804 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
805 } break; case Interpreter_OUTFILEcxx . . $ `sys/Interpreter.cpp:35:9`!: {
806 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
807 UiForm_addOutfilecxx . . $ UiForm_addOutfile(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
808 else
809 UiForm_addOutfilecxx . . $ UiForm_addOutfile(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
810 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
811 } break; case Interpreter_FOLDERcxx . . $ `sys/Interpreter.cpp:36:9`!: {
812 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
813 UiForm_addFoldercxx . . $ UiForm_addFolder(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
814 else
815 UiForm_addFoldercxx . . $ UiForm_addFolder(25528465ffb71beb). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
816 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
817 } break; case Interpreter_REALcxx . . $ `sys/Interpreter.cpp:38:9`!: {
818 UiForm_addRealcxx . . $ UiForm_addReal(d7880526ba4e7a26). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()); // TODO: an address of a real variable
819 } break; case Interpreter_NONNEGATIVEcxx . . $ `sys/Interpreter.cpp:39:9`!: {
820 UiForm_addNonnegativecxx . . $ UiForm_addNonnegative(d7880526ba4e7a26). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
821 } break; case Interpreter_POSITIVEcxx . . $ `sys/Interpreter.cpp:40:9`!: {
822 UiForm_addPositivecxx . . $ UiForm_addPositive(d7880526ba4e7a26). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
823 } break; case Interpreter_INTEGERcxx . . $ `sys/Interpreter.cpp:41:9`!: {
824 UiForm_addIntegercxx . . $ UiForm_addInteger(b8ca5bf767b50516). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
825 } break; case Interpreter_NATURAL0cxx . . $ `sys/Interpreter.cpp:42:9`!: {
826 UiForm_addNatural0cxx . . $ UiForm_addNatural0(b8ca5bf767b50516). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
827 } break; case Interpreter_NATURAL1cxx . . $ `sys/Interpreter.cpp:43:9`!: {
828 UiForm_addNatural1cxx . . $ UiForm_addNatural1(b8ca5bf767b50516). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
829 } break; case Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`!: {
830 mutablestring32cxx . . $ mutablestring32# arg = & mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0];
831 if (
832 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"1") ||
833 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"yes") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"on") ||
834 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"Yes") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"On") ||
835 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"YES") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"ON")
836 ) {
837 str32cpycxx . . $ str32cpy(6ab934322573b179). (arg, U"1");
838 } else if (
839 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"0") ||
840 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"no") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"off") ||
841 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"No") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"Off") ||
842 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"NO") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"OFF")
843 ) {
844 str32cpycxx . . $ str32cpy(6ab934322573b179). (arg, U"0");
845 } else {
846 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown value “", arg, U"” for boolean “", mycxx . . $ `melder/melder.h:44:9`! parameters [ipar], U"”.");
847 }
848 UiForm_addBooleancxx . . $ UiForm_addBoolean(b90450cfcf0b1b39). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0] == U'1');
849 } break; case Interpreter_REALVECTORcxx . . $ `sys/Interpreter.cpp:48:9`!: {
850 kUi_realVectorFormatcxx . . $ kUi_realVectorFormat# format = kUi_realVectorFormat_getValuecxx . . $ kUi_realVectorFormat_getValue(4ba8bb6d771ea220). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]);
851 if (format == kUi_realVectorFormatcxx . . $ kUi_realVectorFormat#::UNDEFINEDcxx . . $ kUi_realVectorFormat#UNDEFINED.)
852 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Undefined real vector format “", mycxx . . $ `melder/melder.h:44:9`! formats [ipar], U"”.");
853 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
854 UiForm_addRealVectorcxx . . $ UiForm_addRealVector(5c557c1a40061fd6). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
855 else
856 UiForm_addRealVectorcxx . . $ UiForm_addRealVector(5c557c1a40061fd6). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
857 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
858 } break; case Interpreter_NONNEGATIVEVECTORcxx . . $ `sys/Interpreter.cpp:49:9`!: {
859 kUi_realVectorFormatcxx . . $ kUi_realVectorFormat# format = kUi_realVectorFormat_getValuecxx . . $ kUi_realVectorFormat_getValue(4ba8bb6d771ea220). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]);
860 if (format == kUi_realVectorFormatcxx . . $ kUi_realVectorFormat#::UNDEFINEDcxx . . $ kUi_realVectorFormat#UNDEFINED.)
861 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Undefined nonnegative vector format “", mycxx . . $ `melder/melder.h:44:9`! formats [ipar], U"”.");
862 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
863 UiForm_addNonnegativeVectorcxx . . $ UiForm_addNonnegativeVector(5c557c1a40061fd6). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
864 else
865 UiForm_addNonnegativeVectorcxx . . $ UiForm_addNonnegativeVector(5c557c1a40061fd6). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
866 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
867 } break; case Interpreter_POSITIVEVECTORcxx . . $ `sys/Interpreter.cpp:50:9`!: {
868 kUi_realVectorFormatcxx . . $ kUi_realVectorFormat# format = kUi_realVectorFormat_getValuecxx . . $ kUi_realVectorFormat_getValue(4ba8bb6d771ea220). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]);
869 if (format == kUi_realVectorFormatcxx . . $ kUi_realVectorFormat#::UNDEFINEDcxx . . $ kUi_realVectorFormat#UNDEFINED.)
870 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Undefined positive vector format “", mycxx . . $ `melder/melder.h:44:9`! formats [ipar], U"”.");
871 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
872 UiForm_addPositiveVectorcxx . . $ UiForm_addPositiveVector(5c557c1a40061fd6). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
873 else
874 UiForm_addPositiveVectorcxx . . $ UiForm_addPositiveVector(5c557c1a40061fd6). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
875 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
876 } break; case Interpreter_INTEGERVECTORcxx . . $ `sys/Interpreter.cpp:51:9`!: {
877 kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat# format = kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]);
878 if (format == kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat#::UNDEFINEDcxx . . $ kUi_integerVectorFormat#UNDEFINED.)
879 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Undefined integer vector format “", mycxx . . $ `melder/melder.h:44:9`! formats [ipar], U"”.");
880 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
881 UiForm_addIntegerVectorcxx . . $ UiForm_addIntegerVector(2672c3a1aac61713). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
882 else
883 UiForm_addIntegerVectorcxx . . $ UiForm_addIntegerVector(2672c3a1aac61713). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, format, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
884 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]);
885 } break; case Interpreter_NATURAL0VECTORcxx . . $ `sys/Interpreter.cpp:52:9`!: {
886 kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat# format = kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]);
887 if (format == kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat#::UNDEFINEDcxx . . $ kUi_integerVectorFormat#UNDEFINED.)
888 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Undefined natural vector format “", mycxx . . $ `melder/melder.h:44:9`! formats [ipar], U"”.");
889 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
890 UiForm_addNatural0Vectorcxx . . $ UiForm_addNatural0Vector(2672c3a1aac61713). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter,
891 kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]), mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()
892 );
893 else
894 UiForm_addNatural0Vectorcxx . . $ UiForm_addNatural0Vector(2672c3a1aac61713). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter,
895 kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]), mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
896 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]
897 );
898 } break; case Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`!: {
899 kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat# format = kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]);
900 if (format == kUi_integerVectorFormatcxx . . $ kUi_integerVectorFormat#::UNDEFINEDcxx . . $ kUi_integerVectorFormat#UNDEFINED.)
901 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Undefined natural vector format “", mycxx . . $ `melder/melder.h:44:9`! formats [ipar], U"”.");
902 if (mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar] == 0)
903 UiForm_addNatural1Vectorcxx . . $ UiForm_addNatural1Vector(2672c3a1aac61713). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter,
904 kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]), mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()
905 );
906 else
907 UiForm_addNatural1Vectorcxx . . $ UiForm_addNatural1Vector(2672c3a1aac61713). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter,
908 kUi_integerVectorFormat_getValuecxx . . $ kUi_integerVectorFormat_getValue(84fcc95e9379afcd). (mycxx . . $ `melder/melder.h:44:9`! formatscxx . . $ structInterpreter#formats. [ipar]), mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),
909 mycxx . . $ `melder/melder.h:44:9`! numbersOfLinescxx . . $ structInterpreter#numbersOfLines. [ipar]
910 );
911 } break; case Interpreter_REALMATRIXcxx . . $ `sys/Interpreter.cpp:57:9`!: {
912 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot handle matrices in forms yet."); // TODO
913 // UiForm_addRealMatrix (form.get(), nullptr, nullptr, parameter, my arguments [ipar].get());
914 } break; case Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`!: {
915 UiForm_addChoicecxx . . $ UiForm_addChoice(d89e2083c962d687). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, nullptr, parameter, (int) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()), 1);
916 } break; case Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!: {
917 UiForm_addOptionMenucxx . . $ UiForm_addOptionMenu(d89e2083c962d687). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, nullptr, parameter, (int) Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()), 1);
918 } break; case Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`!: {
919 UiForm_addOptioncxx . . $ UiForm_addOption(fb534d753ea2b6de). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
920 } break; case Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`!: {
921 UiForm_addOptioncxx . . $ UiForm_addOption(fb534d753ea2b6de). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
922 } break; case Interpreter_HEADINGcxx . . $ `sys/Interpreter.cpp:64:9`!: {
923 UiForm_addHeadingcxx . . $ UiForm_addHeading(6d0ce7320d446690). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
924 } break; case Interpreter_COMMENTcxx . . $ `sys/Interpreter.cpp:65:9`!: {
925 UiForm_addCommentcxx . . $ UiForm_addComment(6d0ce7320d446690). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
926 } break; case Interpreter_CAPTIONcxx . . $ `sys/Interpreter.cpp:66:9`!: {
927 UiForm_addCaptioncxx . . $ UiForm_addCaption(6d0ce7320d446690). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
928 } break; default: {
929 UiForm_addWordcxx . . $ UiForm_addWord(5d4a87e816a21170). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), nullptr, nullptr, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
930 }
931 }
932 }
933 tidyUpParameterNamescxx . . $ tidyUpParameterNames(a0a95604869f3378). (me, mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.);
934 UiForm_finishcxx . . $ UiForm_finish(b4388889c5fb10c0). (form.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
935 return formcxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
936 }
937
938 void Interpreter_getArgumentsFromDialogcxx . . $ Interpreter_getArgumentsFromDialog(d4b141834b28b228). (Interpretercxx . . $ Interpreter# me, UiFormcxx . . $ UiForm# dialog) {
939 tidyUpParameterNamescxx . . $ tidyUpParameterNames(a0a95604869f3378). (me, mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.);
940 for (int ipar = 1; ipar <= mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.; ipar ++) {
941 char32cxx . . $ char32# parameter [1+Interpreter_MAX_PARAMETER_LENGTHcxx . . $ `sys/Interpreter.h:40:9`!];
942 /*
943 Convert underscores to spaces.
944 */
945 str32cpycxx . . $ str32cpy(6ab934322573b179). (parameter, mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar]);
946 char32cxx . . $ char32# *p = & parameter [0];
947 while (*p) {
948 if (*p == U'_')
949 *p = U' ';
950 p ++;
951 }
952 switch (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar]) {
953 case Interpreter_WORDcxx . . $ `sys/Interpreter.cpp:31:9`!:
954 case Interpreter_SENTENCEcxx . . $ `sys/Interpreter.cpp:32:9`!:
955 case Interpreter_TEXTcxx . . $ `sys/Interpreter.cpp:33:9`!:
956 {
957 const conststring32cxx . . $ conststring32# value = UiForm_getStringcxx . . $ UiForm_getString(dbfe1f22119c140b). (dialog, parameter);
958 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (value);
959 break;
960 }
961 case Interpreter_INFILEcxx . . $ `sys/Interpreter.cpp:34:9`!:
962 case Interpreter_OUTFILEcxx . . $ `sys/Interpreter.cpp:35:9`!:
963 case Interpreter_FOLDERcxx . . $ `sys/Interpreter.cpp:36:9`!:
964 {
965 const conststring32cxx . . $ conststring32# value = UiForm_getStringcxx . . $ UiForm_getString(dbfe1f22119c140b). (dialog, parameter);
966 structMelderFilecxx . . $ structMelderFile# file { };
967 Melder_relativePathToFilecxx . . $ Melder_relativePathToFile(82691f2ee21fbb13). (value, & file); // the working directory should have been set to the script file path TODO: check
968 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (MelderFile_peekPathcxx . . $ MelderFile_peekPath(d9f043369fa9b55b). (& file));
969 break;
970 }
971 case Interpreter_REALcxx . . $ `sys/Interpreter.cpp:38:9`!:
972 case Interpreter_NONNEGATIVEcxx . . $ `sys/Interpreter.cpp:39:9`!:
973 case Interpreter_POSITIVEcxx . . $ `sys/Interpreter.cpp:40:9`!:
974 {
975 const double value = UiForm_getReal_checkcxx . . $ UiForm_getReal_check(90f0f90face616f6). (dialog, parameter);
976 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). autostring32cxx . . $ _autostring#_autostring(f153f132b2bc41c2). (40, true);
977 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),40+1, value);
978 break;
979 }
980 case Interpreter_INTEGERcxx . . $ `sys/Interpreter.cpp:41:9`!:
981 case Interpreter_NATURAL0cxx . . $ `sys/Interpreter.cpp:42:9`!:
982 case Interpreter_NATURAL1cxx . . $ `sys/Interpreter.cpp:43:9`!:
983 case Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`!:
984 {
985 const integercxx . . $ integer# value = UiForm_getIntegercxx . . $ UiForm_getInteger(a2a8d8679a0481d3). (dialog, parameter);
986 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). autostring32cxx . . $ _autostring#_autostring(f153f132b2bc41c2). (40, true);
987 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),40+1, value);
988 break;
989 }
990 case Interpreter_REALVECTORcxx . . $ `sys/Interpreter.cpp:48:9`!:
991 case Interpreter_NONNEGATIVEVECTORcxx . . $ `sys/Interpreter.cpp:49:9`!:
992 case Interpreter_POSITIVEVECTORcxx . . $ `sys/Interpreter.cpp:50:9`!:
993 {
994 const VECcxx . . $ VEC# realVectorValue = UiForm_getRealVectorcxx . . $ UiForm_getRealVector(c0137ef95408d49b). (dialog, parameter);
995 autoMelderStringcxx . . $ autoMelderString# buffercxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
996 for (integercxx . . $ integer# i = 1; i <= realVectorValue.sizecxx . . $ vector#size.; i ++) {
997 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& buffer, realVectorValue [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]);
998 if (i < realVectorValue.sizecxx . . $ vector#size.)
999 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& buffer, U' ');
1000 }
1001 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (buffer.stringcxx . . $ MelderString#string.);
1002 break;
1003 }
1004 case Interpreter_INTEGERVECTORcxx . . $ `sys/Interpreter.cpp:51:9`!:
1005 case Interpreter_NATURAL0VECTORcxx . . $ `sys/Interpreter.cpp:52:9`!:
1006 case Interpreter_NATURAL1VECTORcxx . . $ `sys/Interpreter.cpp:53:9`!:
1007 {
1008 const INTVECcxx . . $ INTVEC# integerVectorValue = UiForm_getIntegerVectorcxx . . $ UiForm_getIntegerVector(95a73fa817562995). (dialog, parameter);
1009 autoMelderStringcxx . . $ autoMelderString# buffercxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
1010 for (integercxx . . $ integer# i = 1; i <= integerVectorValue.sizecxx . . $ vector#size.; i ++) {
1011 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& buffer, integerVectorValue [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).i]);
1012 if (i < integerVectorValue.sizecxx . . $ vector#size.)
1013 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& buffer, U' ');
1014 }
1015 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (buffer.stringcxx . . $ MelderString#string.);
1016 break;
1017 }
1018 case Interpreter_REALMATRIXcxx . . $ `sys/Interpreter.cpp:57:9`!:
1019 {
1020 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot handle matrices in forms yet");
1021 break;
1022 }
1023 case Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`!:
1024 case Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!: {
1025 const integercxx . . $ integer# integerValue = UiForm_getIntegercxx . . $ UiForm_getInteger(a2a8d8679a0481d3). (dialog, parameter);
1026 const conststring32cxx . . $ conststring32# stringValue = UiForm_getStringcxx . . $ UiForm_getString(dbfe1f22119c140b). (dialog, parameter);
1027 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). autostring32cxx . . $ _autostring#_autostring(f153f132b2bc41c2). (40, true);
1028 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(),40+1, integerValue);
1029 Melder_sprintcxx . . $ Melder_sprint(2b992b0fb5123bdf). (mycxx . . $ `melder/melder.h:44:9`! choiceArgumentscxx . . $ structInterpreter#choiceArguments. [ipar],100, stringValue);
1030 break;
1031 }
1032 case Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`!:
1033 case Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`!:
1034 case Interpreter_COMMENTcxx . . $ `sys/Interpreter.cpp:65:9`!:
1035 break;
1036 default:
1037 Melder_crashcxx . . $ `melder/melder_error.h:98:9`! (U"Unhandled parameter type ", mycxx . . $ `melder/melder.h:44:9`! types [ipar]);
1038 }
1039 }
1040 }
1041
1042 static void convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePathscxx . . $ convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePaths(a0a95604869f3378). (Interpretercxx . . $ Interpreter# me, integercxx . . $ integer# size) {
1043 for (integercxx . . $ integer# ipar = 1; ipar <= size; ipar ++) {
1044 if (
1045 mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar] == Interpreter_INFILEcxx . . $ `sys/Interpreter.cpp:34:9`! ||
1046 mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar] == Interpreter_OUTFILEcxx . . $ `sys/Interpreter.cpp:35:9`! ||
1047 mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar] == Interpreter_FOLDERcxx . . $ `sys/Interpreter.cpp:36:9`!
1048 ) {
1049 structMelderFilecxx . . $ structMelderFile# file { };
1050 Melder_relativePathToFilecxx . . $ Melder_relativePathToFile(82691f2ee21fbb13). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), & file);
1051 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (MelderFile_peekPathcxx . . $ MelderFile_peekPath(d9f043369fa9b55b). (& file));
1052 } else if (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar] == Interpreter_BOOLEANcxx . . $ `sys/Interpreter.cpp:44:9`!) {
1053 mutablestring32cxx . . $ mutablestring32# arg = & mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0];
1054 if (
1055 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"1") ||
1056 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"yes") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"on") ||
1057 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"Yes") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"On") ||
1058 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"YES") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"ON")
1059 ) {
1060 str32cpycxx . . $ str32cpy(6ab934322573b179). (arg, U"1");
1061 } else if (
1062 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"0") ||
1063 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"no") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"off") ||
1064 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"No") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"Off") ||
1065 str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"NO") || str32equcxx . . $ `melder/melder_str32.h:122:9`! (arg, U"OFF")
1066 ) {
1067 str32cpycxx . . $ str32cpy(6ab934322573b179). (arg, U"0");
1068 } else {
1069 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown value \"", arg, U"\" for boolean \"", mycxx . . $ `melder/melder.h:44:9`! parameters [ipar], U"\".");
1070 }
1071 } else if (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar] == Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`!) {
1072 integercxx . . $ integer# jpar;
1073 mutablestring32cxx . . $ mutablestring32# arg = & mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0];
1074 for (jpar = ipar + 1; jpar <= mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.; jpar ++) {
1075 if (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [jpar] != Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`! && mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [jpar] != Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`!)
1076 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown value \"", arg, U"\" for choice \"", mycxx . . $ `melder/melder.h:44:9`! parameters [ipar], U"\".");
1077 if (str32equcxx . . $ `melder/melder_str32.h:122:9`! (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [jpar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), arg)) { // the button labels are in the arguments; see Interpreter_readParameters
1078 str32cpycxx . . $ str32cpy(6ab934322573b179). (arg, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (jpar - ipar));
1079 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! choiceArgumentscxx . . $ structInterpreter#choiceArguments. [ipar], mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [jpar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
1080 break;
1081 }
1082 }
1083 if (jpar > mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.)
1084 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown value \"", arg, U"\" for choice \"", mycxx . . $ `melder/melder.h:44:9`! parameters [ipar], U"\".");
1085 } else if (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar] == Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!) {
1086 integercxx . . $ integer# jpar;
1087 mutablestring32cxx . . $ mutablestring32# arg = & mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0];
1088 for (jpar = ipar + 1; jpar <= mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.; jpar ++) {
1089 if (mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [jpar] != Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`! && mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [jpar] != Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`!)
1090 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown value \"", arg, U"\" for option menu \"", mycxx . . $ `melder/melder.h:44:9`! parameters [ipar], U"\".");
1091 if (str32equcxx . . $ `melder/melder_str32.h:122:9`! (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [jpar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), arg)) {
1092 str32cpycxx . . $ str32cpy(6ab934322573b179). (arg, Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (jpar - ipar));
1093 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! choiceArgumentscxx . . $ structInterpreter#choiceArguments. [ipar], mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [jpar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
1094 break;
1095 }
1096 }
1097 if (jpar > mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.)
1098 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown value \"", arg, U"\" for option menu \"", mycxx . . $ `melder/melder.h:44:9`! parameters [ipar], U"\".");
1099 }
1100 }
1101 }
1102
1103 void Interpreter_getArgumentsFromStringcxx . . $ Interpreter_getArgumentsFromString(c79bee1e2231f904). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# arguments) {
1104 int size = mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.;
1105 const integercxx . . $ integer# length = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (arguments);
1106 while (size >= 1 && mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [size] [0] == U'\0')
1107 size --; /* Ignore fields without a variable name (button, comment). */
1108 tidyUpParameterNamescxx . . $ tidyUpParameterNames(a0a95604869f3378). (me, size);
1109 for (int ipar = 1; ipar < size; ipar ++) {
1110 int ichar = 0;
1111 /*
1112 Ignore buttons and comments again. The buttons will keep their labels as "arguments".
1113 */
1114 if (mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar] [0] == U'\0')
1115 continue;
1116 /*
1117 Erase the current values, probably the default values,
1118 and replace with the actual arguments.
1119 */
1120 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). autostring32cxx . . $ autostring32# (length);
1121 /*
1122 Skip spaces until next argument.
1123 */
1124 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(1babf4dbe7380927). (& arguments);
1125 /*
1126 The argument is everything up to the next space, or, if it starts with a double quote,
1127 everything between this quote and the matching double quote;
1128 in this case, the argument can represent a double quote by a sequence of two double quotes.
1129 Example: the string
1130 "I said ""hello"""
1131 will be passed to the dialog as a single argument containing the text
1132 I said "hello"
1133 */
1134 if (*arguments == U'\"') {
1135 arguments ++; // do not include leading double quote
1136 for (;;) {
1137 if (*arguments == U'\0')
1138 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing matching quote.");
1139 if (*arguments == U'\"' && * ++ arguments != U'\"')
1140 break; // remember second quote
1141 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).ichar ++] = *arguments ++;
1142 }
1143 } else {
1144 while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*arguments))
1145 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).ichar ++] = *arguments ++;
1146 }
1147 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).ichar] = U'\0'; // trailing null byte
1148 }
1149 /*
1150 The last item is handled separately, because it consists of the rest of the line.
1151 Leading spaces are skipped, but trailing spaces are included.
1152 */
1153 if (size > 0) {
1154 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(1babf4dbe7380927). (& arguments);
1155 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [size] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (arguments);
1156 }
1157 convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePathscxx . . $ convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePaths(a0a95604869f3378). (me, size);
1158 }
1159
1160 void Interpreter_getArgumentsFromArgscxx . . $ Interpreter_getArgumentsFromArgs(2d2c4569794feab0). (Interpretercxx . . $ Interpreter# me, integercxx . . $ integer# narg, Stackelcxx . . $ Stackel# args) {
1161 tracecxx . . $ `melder/melder_debug.h:60:10`! (narg, U" arguments");
1162 integercxx . . $ integer# size = mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.;
1163 while (size >= 1 && mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [size] [0] == U'\0')
1164 size --; // ignore trailing fields without a variable name (button, comment)
1165 tidyUpParameterNamescxx . . $ tidyUpParameterNames(a0a95604869f3378). (me, size);
1166 integercxx . . $ integer# iarg = 0;
1167 for (integercxx . . $ integer# ipar = 1; ipar <= size; ipar ++) {
1168 /*
1169 Ignore buttons and comments again. The buttons will keep their labels as "arguments".
1170 */
1171 if (mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar] [0] == U'\0')
1172 continue;
1173 /*
1174 Erase the current values, probably the default values...
1175 */
1176 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar]. resetcxx . . $ _autostring#reset(49f6e7a06ebc5aa8).(); //
1177 if (iarg == narg)
1178 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Found ", narg, U" arguments but expected more.");
1179 Stackelcxx . . $ Stackel# arg = & args [++ iarg];
1180 /*
1181 ... and replace with the actual arguments. BUG: this loses type information.
1182 */
1183 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37).
1184 arg -> whichcxx . . $ structStackel#which. == Stackel_NUMBERcxx . . $ `sys/Formula.h:46:10`! ? Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (Melder_doublecxx . . $ Melder_double(f05d861d9dbec9b2). (arg -> numbercxx . . $ structStackel#$anonymous_type_0#number.)) :
1185 arg -> whichcxx . . $ structStackel#which. == Stackel_STRINGcxx . . $ `sys/Formula.h:47:10`! ? Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (arg -> getStringcxx . . $ structStackel#getString(1912f6684645c851).()) :
1186 arg -> whichcxx . . $ structStackel#which. == Stackel_NUMERIC_VECTORcxx . . $ `sys/Formula.h:48:10`! ? Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (Melder_VECcxx . . $ Melder_VEC(b17600fbee77d577). (argcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> numericVectorcxx . . $ structStackel#$anonymous_type_0#numericVector., true)) :
1187 autostring32cxx . . $ _autostring#_autostring(49f6e7a06ebc5aa8).();
1188 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! arguments [ipar]);
1189 }
1190 if (iarg < narg)
1191 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Found ", narg, U" arguments but expected only ", iarg, U".");
1192 convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePathscxx . . $ convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePaths(a0a95604869f3378). (me, size);
1193 }
1194
1195 void Interpreter_getArgumentsFromCommandLinecxx . . $ Interpreter_getArgumentsFromCommandLine(715a1a3989df8f8a). (Interpretercxx . . $ Interpreter# me, integercxx . . $ integer# argc, char **argv) {
1196 tracecxx . . $ `melder/melder_debug.h:60:10`! (argc, U" arguments");
1197 integercxx . . $ integer# size = mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.;
1198 while (size >= 1 && mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [size] [0] == U'\0')
1199 size --; // ignore trailing fields without a variable name (button, comment)
1200 tidyUpParameterNamescxx . . $ tidyUpParameterNames(a0a95604869f3378). (me, size);
1201 integercxx . . $ integer# iarg = 0;
1202 for (integercxx . . $ integer# ipar = 1; ipar <= size; ipar ++) {
1203 /*
1204 Ignore buttons and comments again. The buttons will keep their labels as "arguments".
1205 */
1206 if (mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar] [0] == U'\0')
1207 continue;
1208 /*
1209 Erase the current values, probably the default values,
1210 and replace with the actual arguments.
1211 */
1212 if (iarg == argc)
1213 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Found ", argc, U" arguments but expected more.");
1214 mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_8to32_ecxx . . $ Melder_8to32_e(f01fe69d6ed2498b). (argv [iarg ++]);
1215 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! arguments [ipar]);
1216 }
1217 if (iarg < argc)
1218 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Found ", argc, U" arguments but expected only ", iarg, U".");
1219 convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePathscxx . . $ convertBooleansAndChoicesToNumbersAndRelativeToAbsolutePaths(a0a95604869f3378). (me, size);
1220 }
1221
1222 static void Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# key, double value) {
1223 autoInterpreterVariablecxx . . $ autoInterpreterVariable# variable = InterpreterVariable_createcxx . . $ InterpreterVariable_create(37a296c0d921936f). (key);
1224 variable ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numericValuecxx . . $ structInterpreterVariable#numericValue. = value;
1225 mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap. [cxx . . $ std/unordered_map#`operator[]`(e943906cd8dd0420).keycxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). variable.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
1226 variable.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).();
1227 }
1228
1229 static void Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# key, conststring32cxx . . $ conststring32# value) {
1230 autoInterpreterVariablecxx . . $ autoInterpreterVariable# variable = InterpreterVariable_createcxx . . $ InterpreterVariable_create(37a296c0d921936f). (key);
1231 variable ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (value);
1232 mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap. [cxx . . $ std/unordered_map#`operator[]`(e943906cd8dd0420).keycxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). variable.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
1233 variable.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).();
1234 }
1235
1236 static void Interpreter_addNumericVectorVariablecxx . . $ Interpreter_addNumericVectorVariable(88746eaab04bd575). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# key, conststring32cxx . . $ conststring32# value) {
1237 autoInterpreterVariablecxx . . $ autoInterpreterVariable# variable = InterpreterVariable_createcxx . . $ InterpreterVariable_create(37a296c0d921936f). (key);
1238 variable ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). splitByWhitespace_VECcxx . . $ splitByWhitespace_VEC(be643ff064625b8d). (value);
1239 mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap. [cxx . . $ std/unordered_map#`operator[]`(e943906cd8dd0420).keycxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). variable.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
1240 variable.releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).();
1241 }
1242
1243 InterpreterVariablecxx . . $ InterpreterVariable# Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# key) {
1244 Melder_precxx . . $ `melder/melder_assert.h:40:10`! (key);
1245 conststring32cxx . . $ conststring32# variableNameIncludingProcedureName =
1246 ( key [0] == U'.' ? Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (mycxx . . $ `melder/melder.h:44:9`! procedureStackNamescxx . . $ structInterpreter#procedureStackNames. [mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth.], key) : key );
1247 auto it = mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap.. findcxx . . $ std/unordered_map#find(f711f2f81556fe93). (variableNameIncludingProcedureNamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
1248 if (it !=cxx . . $ std/__detail/`operator!=`(6ab342297d2d0253). mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).())
1249 return it ->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50). secondcxx . . $ std/pair#second..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).();
1250 else
1251 return nullptr;
1252 }
1253
1254 InterpreterVariablecxx . . $ InterpreterVariable# Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# key) {
1255 Melder_precxx . . $ `melder/melder_assert.h:40:10`! (key);
1256 conststring32cxx . . $ conststring32# variableNameIncludingProcedureName =
1257 ( key [0] == U'.' ? Melder_catcxx . . $ Melder_cat(7fbf27f4d367f442). (mycxx . . $ `melder/melder.h:44:9`! procedureStackNamescxx . . $ structInterpreter#procedureStackNames. [mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth.], key) : key );
1258 auto it = mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap.. findcxx . . $ std/unordered_map#find(f711f2f81556fe93). (variableNameIncludingProcedureNamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
1259 if (it !=cxx . . $ std/__detail/`operator!=`(6ab342297d2d0253). mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap..endcxx . . $ std/unordered_map#end(58ae48d364eea91c).())
1260 return it ->cxx . . $ std/__detail/_Node_iterator#`operator->`(35610babf8706b50). secondcxx . . $ std/pair#second..getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).();
1261 /*
1262 The variable doesn't yet exist: create a new one.
1263 */
1264 autoInterpreterVariablecxx . . $ autoInterpreterVariable# variable = InterpreterVariable_createcxx . . $ InterpreterVariable_create(37a296c0d921936f). (variableNameIncludingProcedureName);
1265 InterpreterVariablecxx . . $ InterpreterVariable# variable_ref = variable.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).();
1266 mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap. [cxx . . $ std/unordered_map#`operator[]`(e943906cd8dd0420).variableNameIncludingProcedureNamecxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).] =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). variable.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).();
1267 return variable_ref;
1268 }
1269
1270 static integercxx . . $ integer# lookupLabelcxx . . $ lookupLabel(df2c8148a0293fef). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# labelName) {
1271 const integercxx . . $ integer# position = NUMfindInSortedcxx . . $ NUMfindInSorted(5bcfdb87a5d5128). (mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames..getcxx . . $ _autostringautovector#get(9d56076a9ef7dd02).(), labelName);
1272 if (position == 0)
1273 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unknown label \"", labelName, U"\" (we know of ", mycxx . . $ `melder/melder.h:44:9`! labelNames.size, U" labels).");
1274 return position;
1275 }
1276
1277 static bool isCommandcxx . . $ isCommand(2df281243f91fe91). (conststring32cxx . . $ conststring32# string) {
1278 const char32cxx . . $ char32# *p = & string [0];
1279 /*
1280 Things that start with "nowarn", "noprogress", or "nocheck" are commands.
1281 */
1282 if (p [0] == U'n' && p [1] == U'o' &&
1283 (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (p + 2, U"warn ", 5) || str32nequcxx . . $ `melder/melder_str32.h:123:9`! (p + 2, U"progress ", 9) || str32nequcxx . . $ `melder/melder_str32.h:123:9`! (p + 2, U"check ", 6)))
1284 return true;
1285 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (p, U"demo ", 5))
1286 return true;
1287 /*
1288 Otherwise, things that start with nonupper case are formulas.
1289 */
1290 if (! Melder_isUpperCaseLettercxx . . $ Melder_isUpperCaseLetter(b8d0204ce8416907). (*p))
1291 return false;
1292 /*
1293 The remaining possibility is things that start with upper case.
1294 If they contain an underscore, they are object names, hence we must have a formula.
1295 Otherwise, we have a command.
1296 */
1297 while (Melder_isAlphanumericcxx . . $ Melder_isAlphanumeric(b8d0204ce8416907). (*p))
1298 p ++;
1299 return *p != U'_';
1300 }
1301
1302 static void parameterToVariablecxx . . $ parameterToVariable(e0eb84388112a533). (Interpretercxx . . $ Interpreter# me, int type, conststring32cxx . . $ conststring32# in_parameter, int ipar) {
1303 Melder_precxx . . $ `melder/melder_assert.h:40:10`! (type != 0);
1304 char32cxx . . $ char32# parameter [200];
1305 str32cpycxx . . $ str32cpy(6ab934322573b179). (parameter, in_parameter);
1306 if (type >= Interpreter_MINIMUM_TYPE_FOR_NUMERIC_VARIABLEcxx . . $ `sys/Interpreter.cpp:45:9`! && type <= Interpreter_MAXIMUM_TYPE_FOR_NUMERIC_VARIABLEcxx . . $ `sys/Interpreter.cpp:46:9`!) {
1307 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, parameter, Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()));
1308 } else if (type == Interpreter_CHOICEcxx . . $ `sys/Interpreter.cpp:58:9`! || type == Interpreter_OPTIONMENUcxx . . $ `sys/Interpreter.cpp:59:9`!) {
1309 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, parameter, Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()));
1310 str32catcxx . . $ str32cat(6ab934322573b179). (parameter, U"$");
1311 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, parameter, mycxx . . $ `melder/melder.h:44:9`! choiceArgumentscxx . . $ structInterpreter#choiceArguments. [ipar]);
1312 } else if (type == Interpreter_BUTTONcxx . . $ `sys/Interpreter.cpp:62:9`! || type == Interpreter_OPTIONcxx . . $ `sys/Interpreter.cpp:63:9`! || type == Interpreter_COMMENTcxx . . $ `sys/Interpreter.cpp:65:9`!) {
1313 ; // do not add a variable
1314 } else if (type >= Interpreter_MINIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:54:9`! && type <= Interpreter_MAXIMUM_TYPE_FOR_NUMERIC_VECTOR_VARIABLEcxx . . $ `sys/Interpreter.cpp:55:9`!) {
1315 str32catcxx . . $ str32cat(6ab934322573b179). (parameter, U"#");
1316 Interpreter_addNumericVectorVariablecxx . . $ Interpreter_addNumericVectorVariable(88746eaab04bd575). (me, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
1317 } else {
1318 str32catcxx . . $ str32cat(6ab934322573b179). (parameter, U"$");
1319 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, parameter, mycxx . . $ `melder/melder.h:44:9`! argumentscxx . . $ structInterpreter#arguments. [ipar].getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
1320 }
1321 }
1322
1323 inline static void NumericVectorVariable_movecxx . . $ NumericVectorVariable_move(edf649b628674408). (InterpreterVariablecxx . . $ InterpreterVariable# variable, VECcxx . . $ VEC# movedVector, bool rightHandSideOwned) {
1324 if (rightHandSideOwned) {
1325 /*
1326 Statement like: a# = b# + c#
1327 */
1328 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue.. adoptFromAmbiguousOwnercxx . . $ autovector#adoptFromAmbiguousOwner(bc17ed9a4b778f50). (movedVector);
1329 } else if (variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..sizecxx . . $ autovector#size. == movedVector.sizecxx . . $ vector#size.) {
1330 if (variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..cellscxx . . $ autovector#cells. == movedVector.cellscxx . . $ vector#cells.) {
1331 /*
1332 Statement like: a# = a#
1333 */
1334 (void) 0; // assigning a variable to itself: do nothing
1335 } else {
1336 /*
1337 Statement like: a# = b# // with matching sizes
1338 */
1339 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..allcxx . . $ autovector#all(a26726dad87555bb).() <<=cxx . . $ `operator<<=`(adea042513329390). movedVectorcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).;
1340 }
1341 } else {
1342 /*
1343 Statement like: a# = b# // with non-matching sizes
1344 */
1345 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). copy_VECcxx . . $ copy_VEC(d4415e68b25283a8). (movedVectorcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd).);
1346 }
1347 }
1348
1349 inline static void StringArrayVariable_movecxx . . $ StringArrayVariable_move(ea00a05ae1b01cb2). (InterpreterVariablecxx . . $ InterpreterVariable# variable, STRVECcxx . . $ STRVEC# movedVector, bool rightHandSideOwned) {
1350 if (rightHandSideOwned) {
1351 /*
1352 Statement like: a$# = b$# + c$#
1353 */
1354 variable -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue.. adoptFromAmbiguousOwnercxx . . $ _autostringautovector#adoptFromAmbiguousOwner(889d620ca03d505c). (movedVector);
1355 } else if (variable -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue..sizecxx . . $ _autostringautovector#size. == movedVector.sizecxx . . $ _stringvector#size.) {
1356 if ((char32cxx . . $ char32# **) variable -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue..elementscxx . . $ _autostringautovector#elements. == movedVector.elementscxx . . $ _stringvector#elements.) {
1357 /*
1358 Statement like: a$# = a$#
1359 */
1360 (void) 0; // assigning a variable to itself: do nothing
1361 } else {
1362 /*
1363 Statement like: a$# = b$# // with matching sizes
1364 */
1365 variable -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue..allcxx . . $ _autostringautovector#all(58997016dad794db).() <<=cxx . . $ `operator<<=`(af216a67914f06ad). movedVector;
1366 }
1367 } else {
1368 /*
1369 Statement like: a$# = b$# // with non-matching sizes
1370 */
1371 variable -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue. =cxx . . $ _autostringautovector#`operator=`(150f7ba7aac25b7e). copy_STRVECcxx . . $ copy_STRVEC(cfa8029879abedac). (movedVectorcxx . . $ _conststringvector#_conststringvector(93d9e701af42cb0d).);
1372 }
1373 }
1374
1375 inline static void NumericMatrixVariable_movecxx . . $ NumericMatrixVariable_move(fa2438427dd6cfa6). (InterpreterVariablecxx . . $ InterpreterVariable# variable, MATcxx . . $ MAT# movedMatrix, bool rightHandSideOwned) {
1376 if (rightHandSideOwned) {
1377 /*
1378 Statement like: a## = b## + c##
1379 */
1380 variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue.. adoptFromAmbiguousOwnercxx . . $ automatrix#adoptFromAmbiguousOwner(eed9513d24570b3d). (movedMatrix);
1381 } else if (variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..nrowcxx . . $ automatrix#nrow. == movedMatrix.nrowcxx . . $ matrix#nrow. && variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..ncolcxx . . $ automatrix#ncol. == movedMatrix.ncolcxx . . $ matrix#ncol.) {
1382 if (variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..cellscxx . . $ automatrix#cells. == movedMatrix.cellscxx . . $ matrix#cells.) {
1383 /*
1384 Statement like: a## = a##
1385 */
1386 (void) 0; // assigning a variable to itself: do nothing
1387 } else {
1388 /*
1389 Statement like: a## = b## // with matching sizes
1390 */
1391 variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..allcxx . . $ automatrix#all(2114117ba8ed4224).() <<=cxx . . $ `operator<<=`(a7d93ba40fe22fe0). movedMatrixcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d).;
1392 }
1393 } else {
1394 /*
1395 Statement like: a## = b## // with non-matching sizes
1396 */
1397 variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). copy_MATcxx . . $ copy_MAT(a392b09ce3fc3972). (movedMatrixcxx . . $ constmatrixview#constmatrixview(eed9513d24570b3d).);
1398 }
1399 }
1400
1401 inline static void NumericVectorVariable_addcxx . . $ NumericVectorVariable_add(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1402 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..allcxx . . $ autovector#all(a26726dad87555bb).() +=cxx . . $ `operator+=`(c555d170d72ff256). scalar;
1403 }
1404 inline static void NumericVectorVariable_addcxx . . $ NumericVectorVariable_add(ea30aa56812f98b8). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constVECcxx . . $ constVEC# vector) {
1405 VECcxx . . $ VEC# const& variableVector = variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..getcxx . . $ autovector#get(e8d1da7fe68a6585).();
1406 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (vector.size == variableVector.size,
1407 U"You cannot add a vector with size ", vector.size,
1408 U" to a vector with a different size (", variableVector.size, U")."
1409 );
1410 variableVectorcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). +=cxx . . $ `operator+=`(adea042513329390). vectorcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
1411 }
1412 inline static void NumericVectorVariable_subtractcxx . . $ NumericVectorVariable_subtract(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1413 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..allcxx . . $ autovector#all(a26726dad87555bb).() -=cxx . . $ `operator-=`(c555d170d72ff256). scalar;
1414 }
1415 inline static void NumericVectorVariable_subtractcxx . . $ NumericVectorVariable_subtract(ea30aa56812f98b8). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constVECcxx . . $ constVEC# vector) {
1416 VECcxx . . $ VEC# const& variableVector = variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..getcxx . . $ autovector#get(e8d1da7fe68a6585).();
1417 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (vector.size == variable -> numericVectorValue.size,
1418 U"You cannot subtract a vector with size ", vector.size,
1419 U" from a vector with a different size (", variableVector.size, U")."
1420 );
1421 variableVectorcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). -=cxx . . $ `operator-=`(adea042513329390). vectorcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
1422 }
1423 inline static void NumericVectorVariable_multiplycxx . . $ NumericVectorVariable_multiply(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1424 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..allcxx . . $ autovector#all(a26726dad87555bb).() *=cxx . . $ `operator*=`(c555d170d72ff256). scalar;
1425 }
1426 inline static void NumericVectorVariable_multiplycxx . . $ NumericVectorVariable_multiply(ea30aa56812f98b8). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constVECcxx . . $ constVEC# vector) {
1427 VECcxx . . $ VEC# const& variableVector = variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..getcxx . . $ autovector#get(e8d1da7fe68a6585).();
1428 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (vector.size != variableVector.size,
1429 U"You cannot multiply a vector with size ", variableVector.size,
1430 U" with a vector with a different size (", vector.size, U")."
1431 );
1432 variableVectorcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). *=cxx . . $ `operator*=`(adea042513329390). vectorcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
1433 }
1434 inline static void NumericVectorVariable_dividecxx . . $ NumericVectorVariable_divide(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1435 variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..allcxx . . $ autovector#all(a26726dad87555bb).() /=cxx . . $ `operator/=`(c555d170d72ff256). scalar;
1436 }
1437 inline static void NumericVectorVariable_dividecxx . . $ NumericVectorVariable_divide(ea30aa56812f98b8). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constVECcxx . . $ constVEC# vector) {
1438 VECcxx . . $ VEC# const& variableVector = variable -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..getcxx . . $ autovector#get(e8d1da7fe68a6585).();
1439 Melder_requirecxx . . $ `melder/melder_require.h:21:9`! (vector.size != variableVector.size,
1440 U"You cannot divide a vector with size ", variableVector.size,
1441 U" by a vector with a different size (", vector.size, U")."
1442 );
1443 variableVectorcxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd). /=cxx . . $ `operator/=`(adea042513329390). vectorcxx . . $ constvectorview#constvectorview(fc39adb4395e9baf).;
1444 }
1445 inline static void NumericMatrixVariable_addcxx . . $ NumericMatrixVariable_add(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1446 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1447 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1448 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1449 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] += scalar;
1450 }
1451 inline static void NumericMatrixVariable_addcxx . . $ NumericMatrixVariable_add(f44b454bc6f9f32d). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constMATcxx . . $ constMAT# matrix) {
1452 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1453 if (matrix.nrowcxx . . $ constmatrix#nrow. != variableMatrix.nrowcxx . . $ matrix#nrow. || matrix.ncolcxx . . $ constmatrix#ncol. != variableMatrix.ncolcxx . . $ matrix#ncol.)
1454 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot add a matrix with size ", matrix.nrow, U"x", matrix.ncol,
1455 U" to a matrix with a different size (", variableMatrix.nrow, U"x", variableMatrix.ncol, U").");
1456 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1457 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1458 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] += matrix [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).irow] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).icol];
1459 }
1460 inline static void NumericMatrixVariable_subtractcxx . . $ NumericMatrixVariable_subtract(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1461 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1462 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1463 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1464 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] -= scalar;
1465 }
1466 inline static void NumericMatrixVariable_subtractcxx . . $ NumericMatrixVariable_subtract(f44b454bc6f9f32d). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constMATcxx . . $ constMAT# matrix) {
1467 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1468 if (matrix.nrowcxx . . $ constmatrix#nrow. != variableMatrix.nrowcxx . . $ matrix#nrow. || matrix.ncolcxx . . $ constmatrix#ncol. != variableMatrix.ncolcxx . . $ matrix#ncol.)
1469 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot subtract a matrix with size ", matrix.nrow, U"x", matrix.ncol,
1470 U" from a matrix with a different size (", variableMatrix.nrow, U"x", variableMatrix.ncol, U").");
1471 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1472 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1473 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] -= matrix [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).irow] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).icol];
1474 }
1475 inline static void NumericMatrixVariable_multiplycxx . . $ NumericMatrixVariable_multiply(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1476 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1477 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1478 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1479 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] *= scalar;
1480 }
1481 inline static void NumericMatrixVariable_multiplycxx . . $ NumericMatrixVariable_multiply(f44b454bc6f9f32d). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constMATcxx . . $ constMAT# matrix) {
1482 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1483 if (matrix.nrowcxx . . $ constmatrix#nrow. != variableMatrix.nrowcxx . . $ matrix#nrow. || matrix.ncolcxx . . $ constmatrix#ncol. != variableMatrix.ncolcxx . . $ matrix#ncol.)
1484 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot multiply a matrix with size ", variableMatrix.nrow, U"x", variableMatrix.ncol,
1485 U" from a matrix with a different size (", matrix.nrow, U"x", matrix.ncol, U").");
1486 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1487 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1488 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] *= matrix [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).irow] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).icol];
1489 }
1490 inline static void NumericMatrixVariable_dividecxx . . $ NumericMatrixVariable_divide(812ebfd01c9301e7). (InterpreterVariablecxx . . $ InterpreterVariable# variable, double scalar) {
1491 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1492 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1493 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1494 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] /= scalar;
1495 }
1496 inline static void NumericMatrixVariable_dividecxx . . $ NumericMatrixVariable_divide(f44b454bc6f9f32d). (InterpreterVariablecxx . . $ InterpreterVariable# variable, constMATcxx . . $ constMAT# matrix) {
1497 MATcxx . . $ MAT# variableMatrix = variable -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
1498 if (matrix.nrowcxx . . $ constmatrix#nrow. != variableMatrix.nrowcxx . . $ matrix#nrow. || matrix.ncolcxx . . $ constmatrix#ncol. != variableMatrix.ncolcxx . . $ matrix#ncol.)
1499 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You cannot divide a matrix with size ", variableMatrix.nrow, U"x", variableMatrix.ncol,
1500 U" by a matrix with a different size (", matrix.nrow, U"x", matrix.ncol, U").");
1501 for (integercxx . . $ integer# irow = 1; irow <= variableMatrix.nrowcxx . . $ matrix#nrow.; irow ++)
1502 for (integercxx . . $ integer# icol = 1; icol <= variableMatrix.ncolcxx . . $ matrix#ncol.; icol ++)
1503 variableMatrix [cxx . . $ matrix#`operator[]`(2d545b3cb3f8e666).irow] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).icol] /= matrix [cxx . . $ constmatrix#`operator[]`(aae4ad074ae650ba).irow] [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).icol];
1504 }
1505
1506 static void Interpreter_do_procedureCallcxx . . $ Interpreter_do_procedureCall(5c6c60d1f5ffef11). (Interpretercxx . . $ Interpreter# me, char32cxx . . $ char32# *command,
1507 constvectorcxx . . $ constvector# <mutablestring32cxx . . $ mutablestring32#> const& lines, integercxx . . $ integer#& lineNumber, integercxx . . $ integer# callStack [], int& callDepth)
1508 {
1509 /*
1510 Modern type of procedure calls, with comma separation, quoted strings, and array support.
1511
1512 We just passed the `@` sign, so we continue by looking for a procedure name at the call site.
1513 */
1514 char32cxx . . $ char32# *p = command;
1515 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1516 char32cxx . . $ char32# *callName = p;
1517 while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*p) && *p != U'(' && *p != U':')
1518 p ++;
1519 if (p == callName) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing procedure name after \"@\".");
1520 bool hasArguments = ( *p != U'\0' );
1521 if (hasArguments) {
1522 bool parenthesisOrColonFound = ( *p == U'(' || *p == U':' );
1523 *p = U'\0'; // close procedure name
1524 if (! parenthesisOrColonFound) {
1525 p ++; // step over first white space
1526 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1527 hasArguments = ( *p != U'\0' );
1528 parenthesisOrColonFound = ( *p == U'(' || *p == U':' );
1529 if (hasArguments && ! parenthesisOrColonFound)
1530 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing parenthesis or colon after procedure name \"", callName, U"\".");
1531 }
1532 p ++; // step over parenthesis or colon
1533 }
1534 const integercxx . . $ integer# callLength = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (callName);
1535 integercxx . . $ integer# iline = 1;
1536 for (; iline <= lines.sizecxx . . $ constvector#size.; iline ++) {
1537 if (! str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"procedure", 9) || ! Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [9]))
1538 continue;
1539 char32cxx . . $ char32# *q = lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 10;
1540 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& q); // skip whitespace before procedure name
1541 char32cxx . . $ char32# *const procName = q;
1542 while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*q) && *q != U'(' && *q != U':')
1543 q ++;
1544 if (q == procName)
1545 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing procedure name after 'procedure'.");
1546 if (q - procName == callLength && str32nequcxx . . $ `melder/melder_str32.h:123:9`! (procName, callName, callLength)) {
1547 /*
1548 We found the procedure definition.
1549 */
1550 if (++ mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. > Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!)
1551 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Call depth greater than ", Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!, U".");
1552 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! procedureStackNamescxx . . $ structInterpreter#procedureStackNames. [mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth.], callName);
1553 const bool parenthesisOrColonFound = ( *q == U'(' || *q == U':' );
1554 if (*q)
1555 q ++; // step over parenthesis or colon or first white space
1556 if (! parenthesisOrColonFound) {
1557 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& q);
1558 if (*q == U'(' || *q == U':')
1559 q ++; // step over parenthesis or colon
1560 }
1561 while (*q && *q != U')' && *q != U';') {
1562 static MelderStringcxx . . $ MelderString# argument;
1563 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& argument);
1564 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1565 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& q);
1566 conststring32cxx . . $ conststring32# parameterName = q;
1567 while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*q) && *q != U',' && *q != U')' && *q != U';')
1568 q ++; // collect parameter name
1569 int expressionDepth = 0;
1570 for (; *p; p ++) {
1571 if (*p == U',') {
1572 if (expressionDepth == 0)
1573 break; // depth-0 comma ends expression
1574 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U',');
1575 } else if (*p == U')' || *p == U']' || *p == U'}') {
1576 if (expressionDepth == 0)
1577 break; // depth-0 closing parenthesis ends expression
1578 expressionDepth --;
1579 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, *p);
1580 } else if (*p == U'(' || *p == U'[' || *p == U'{') {
1581 expressionDepth ++;
1582 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, *p);
1583 } else if (*p == U'“') {
1584 /*
1585 Enter a string literal.
1586 */
1587 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1588 p ++;
1589 for (;; p ++) {
1590 if (*p == U'\0') {
1591 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Incomplete curly string literal: the quotes don't match.");
1592 } else if (*p == U'\"') {
1593 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1594 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1595 } else if (*p == U'”') {
1596 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1597 break;
1598 } else {
1599 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, *p);
1600 }
1601 }
1602 } else if (*p == U'\"') {
1603 /*
1604 Enter a string literal.
1605 */
1606 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1607 p ++;
1608 for (;; p ++) {
1609 if (*p == U'\0') {
1610 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Incomplete string literal: the quotes don't match.");
1611 } else if (*p == U'\"') {
1612 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1613 if (p [1] == '\"') {
1614 p ++; // stay in the string literal
1615 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, U'\"');
1616 } else {
1617 break;
1618 }
1619 } else {
1620 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, *p);
1621 }
1622 }
1623 } else {
1624 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& argument, *p);
1625 }
1626 }
1627 if (q == parameterName)
1628 break;
1629 if (*p) {
1630 *p = U'\0';
1631 p ++;
1632 }
1633 if (q [-1] == U'$') {
1634 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. --;
1635 autostring32cxx . . $ autostring32# value = Interpreter_stringExpressioncxx . . $ Interpreter_stringExpression(ae2ff4958c59280d). (me, argument.stringcxx . . $ MelderString#string.);
1636 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. ++;
1637 const char32cxx . . $ char32# save = *q;
1638 *q = U'\0';
1639 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, parameterName);
1640 *q = save;
1641 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). value.movecxx . . $ _autostring#move(bd43c759570f178f).();
1642 } else if (q [-1] == U'#') {
1643 if (q [-2] == U'#') {
1644 MATcxx . . $ MAT# valuecxx . . $ matrix#matrix(49f6e7a06ebc5aa8).;
1645 bool owned;
1646 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. --;
1647 Interpreter_numericMatrixExpressioncxx . . $ Interpreter_numericMatrixExpression(dd630cc19a2beb06). (me, argument.stringcxx . . $ MelderString#string., & value, & owned);
1648 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. ++;
1649 const char32cxx . . $ char32# save = *q;
1650 *q = U'\0';
1651 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, parameterName);
1652 *q = save;
1653 NumericMatrixVariable_movecxx . . $ NumericMatrixVariable_move(fa2438427dd6cfa6). (var, value, owned);
1654 } else if (q [-2] == U'$') {
1655 STRVECcxx . . $ STRVEC# valuecxx . . $ _stringvector#_stringvector(49f6e7a06ebc5aa8).;
1656 bool owned;
1657 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. --;
1658 Interpreter_stringArrayExpressioncxx . . $ Interpreter_stringArrayExpression(4cd1c45f7f524604). (me, argument.stringcxx . . $ MelderString#string., & value, & owned);
1659 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. ++;
1660 const char32cxx . . $ char32# save = *q;
1661 *q = U'\0';
1662 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, parameterName);
1663 *q = save;
1664 StringArrayVariable_movecxx . . $ StringArrayVariable_move(ea00a05ae1b01cb2). (var, value, owned);
1665 } else {
1666 VECcxx . . $ VEC# valuecxx . . $ vector#vector(49f6e7a06ebc5aa8).;
1667 bool owned;
1668 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. --;
1669 Interpreter_numericVectorExpressioncxx . . $ Interpreter_numericVectorExpression(e47164ae4c0553fe). (me, argument.stringcxx . . $ MelderString#string., & value, & owned);
1670 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. ++;
1671 const char32cxx . . $ char32# save = *q;
1672 *q = U'\0';
1673 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, parameterName);
1674 *q = save;
1675 NumericVectorVariable_movecxx . . $ NumericVectorVariable_move(edf649b628674408). (var, value, owned);
1676 }
1677 } else {
1678 double value;
1679 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. --;
1680 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, argument.stringcxx . . $ MelderString#string., & value);
1681 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. ++;
1682 const char32cxx . . $ char32# save = *q;
1683 *q = U'\0';
1684 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, parameterName);
1685 *q = save;
1686 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. = value;
1687 }
1688 if (*q)
1689 q ++; // skip comma
1690 }
1691 if (callDepth == Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!)
1692 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Call depth greater than ", Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!, U".");
1693 callStack [++ callDepth] = lineNumber;
1694 lineNumber = iline;
1695 break;
1696 }
1697 }
1698 if (iline > lines.sizecxx . . $ constvector#size.)
1699 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Procedure \"", callName, U"\" not found.");
1700 }
1701 static void Interpreter_do_oldProcedureCallcxx . . $ Interpreter_do_oldProcedureCall(5c6c60d1f5ffef11). (Interpretercxx . . $ Interpreter# me, char32cxx . . $ char32# *command,
1702 constvectorcxx . . $ constvector# <mutablestring32cxx . . $ mutablestring32#> const& lines, integercxx . . $ integer#& lineNumber, integercxx . . $ integer# callStack [], int& callDepth)
1703 {
1704 /*
1705 Old type of procedure calls, with space separation, unquoted strings, and no array support.
1706 */
1707 char32cxx . . $ char32# *p = command;
1708 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1709 char32cxx . . $ char32# *callName = p;
1710 while (*p != U'\0' && ! Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*p) && *p != U'(' && *p != U':')
1711 p ++;
1712 if (p == callName)
1713 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing procedure name after 'call'.");
1714 bool hasArguments = ( *p != U'\0' );
1715 *p = U'\0'; // close procedure name
1716 const integercxx . . $ integer# callLength = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (callName);
1717 integercxx . . $ integer# iline = 1;
1718 for (; iline <= lines.sizecxx . . $ constvector#size.; iline ++) {
1719 if (! str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"procedure ", 10))
1720 continue;
1721 char32cxx . . $ char32# *q = lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 10;
1722 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& q);
1723 char32cxx . . $ char32# *procName = q;
1724 while (*q != U'\0' && ! Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*q) && *q != U'(' && *q != U':')
1725 q ++;
1726 if (q == procName)
1727 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing procedure name after 'procedure'.");
1728 bool hasParameters = ( *q != U'\0' );
1729 if (q - procName == callLength && str32nequcxx . . $ `melder/melder_str32.h:123:9`! (procName, callName, callLength)) {
1730 if (hasArguments && ! hasParameters)
1731 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Call to procedure \"", callName, U"\" has too many arguments.");
1732 if (hasParameters && ! hasArguments)
1733 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Call to procedure \"", callName, U"\" has too few arguments.");
1734 if (++ mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. > Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!)
1735 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Call depth greater than ", Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!, U".");
1736 str32cpycxx . . $ str32cpy(6ab934322573b179). (mycxx . . $ `melder/melder.h:44:9`! procedureStackNamescxx . . $ structInterpreter#procedureStackNames. [mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth.], callName);
1737 if (hasParameters) {
1738 bool parenthesisOrColonFound = ( *q == U'(' || *q == U':' );
1739 q ++; // step over parenthesis or colon or first white space
1740 if (! parenthesisOrColonFound) {
1741 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& q);
1742 if (*q == U'(' || *q == U':')
1743 q ++; // step over parenthesis or colon
1744 }
1745 ++ p; // first argument
1746 while (*q && *q != U')') {
1747 char32cxx . . $ char32# *par, save;
1748 static MelderStringcxx . . $ MelderString# arg;
1749 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& arg);
1750 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1751 while (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*q) || *q == U',' || *q == U')')
1752 q ++;
1753 par = q;
1754 while (*q != U'\0' && ! Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*q) && *q != U',' && *q != U')')
1755 q ++; // collect parameter name
1756 if (*q) { // does anything follow the parameter name?
1757 if (*p == U'\"') {
1758 p ++; // skip initial quote
1759 while (*p != U'\0') {
1760 if (*p == U'\"') { // quote signals end-of-string or string-internal quote
1761 if (p [1] == U'\"') { // double quote signals string-internal quote
1762 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& arg, U'\"');
1763 p += 2; // skip second quote
1764 } else { // single quote signals end-of-string
1765 break;
1766 }
1767 } else {
1768 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& arg, *p ++);
1769 }
1770 }
1771 } else {
1772 while (*p != U'\0' && ! Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*p))
1773 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& arg, *p ++); // white space separates
1774 }
1775 if (*p) {
1776 *p = U'\0';
1777 p ++;
1778 }
1779 } else { // else rest of line
1780 while (*p != '\0')
1781 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& arg, *p ++);
1782 }
1783 if (q [-1] == '$') {
1784 save = *q; *q = U'\0';
1785 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, par); *q = save;
1786 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (arg.stringcxx . . $ MelderString#string.);
1787 } else {
1788 double value;
1789 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. --;
1790 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, arg.stringcxx . . $ MelderString#string., & value);
1791 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. ++;
1792 save = *q; *q = U'\0';
1793 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, par); *q = save;
1794 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. = value;
1795 }
1796 }
1797 }
1798 if (callDepth == Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!)
1799 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Call depth greater than ", Interpreter_MAX_CALL_DEPTHcxx . . $ `sys/Interpreter.h:37:9`!, U".");
1800 callStack [++ callDepth] = lineNumber;
1801 lineNumber = iline;
1802 break;
1803 }
1804 }
1805 if (iline > lines.sizecxx . . $ constvector#size.)
1806 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Procedure \"", callName, U"\" not found.");
1807 }
1808
1809 static void assignToNumericVectorElementcxx . . $ assignToNumericVectorElement(61d4635e44240b16). (Interpretercxx . . $ Interpreter# me, char32cxx . . $ char32# *& p, const char32cxx . . $ char32#* vectorName, MelderStringcxx . . $ MelderString#& valueString) {
1810 integercxx . . $ integer# indexValue = 0;
1811 static MelderStringcxx . . $ MelderString# index;
1812 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& index);
1813 int depth = 0;
1814 bool inString = false;
1815 while ((depth > 0 || *p != U']' || inString) && Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) {
1816 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& index, *p);
1817 if (*p == U'[') {
1818 if (! inString)
1819 depth ++;
1820 } else if (*p == U']') {
1821 if (! inString)
1822 depth --;
1823 }
1824 if (*p == U'"')
1825 inString = ! inString;
1826 p ++;
1827 }
1828 if (! Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p))
1829 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing bracket (]) in array element.");
1830 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
1831 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, index.stringcxx . . $ MelderString#string., & result);
1832 if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
1833 indexValue = Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (result. numericResultcxx . . $ Formula_Result#numericResult.);
1834 } else {
1835 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Element index should be numeric.");
1836 }
1837 p ++; // step over closing bracket
1838 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1839 int assignmentType = 0;
1840 if (*p == U'=') {
1841 p ++; // step over equals sign
1842 } else if (*p == U'+' && p [1] == U'=') {
1843 assignmentType = 1;
1844 p += 2; // step over plus-gets sign
1845 } else if (*p == U'-' && p [1] == U'=') {
1846 assignmentType = 2;
1847 p += 2; // step over minus-gets sign
1848 } else if (*p == U'*' && p [1] == U'=') {
1849 assignmentType = 3;
1850 p += 2; // step over times-gets sign
1851 } else if (*p == U'/' && p [1] == U'=') {
1852 assignmentType = 4;
1853 p += 2; // step over div-gets sign
1854 } else
1855 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing '=', '+=', '-=', '*=' or '/=' after vector element ", vectorName, U" [", index.string, U"].");
1856 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
1857 if (*p == U'\0')
1858 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing expression after vector element ", vectorName, U" [", index.string, U"].");
1859 double value;
1860 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
1861 /*
1862 Get the value of the query.
1863 */
1864 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& valueString);
1865 autoMelderDivertInfocxx . . $ autoMelderDivertInfo# divertcxx . . $ autoMelderDivertInfo#autoMelderDivertInfo(93db1090f27e5462). (& valueString);
1866 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& valueString, 1); // will be overwritten by something totally different if any MelderInfo function is called...
1867 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
1868 if (! status) {
1869 value = undefinedcxx . . $ undefined.;
1870 } else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::OBJECT_cxx . . $ kInterpreter_ReturnType#OBJECT_.) {
1871 integercxx . . $ integer# IOBJECT, selectedObject = 0, numberOfSelectedObjects = 0;
1872 WHEREcxx . . $ `sys/praat.h:198:9`! (SELECTEDcxx . . $ `sys/praat.h:200:9`!) {
1873 selectedObject = IOBJECT;
1874 numberOfSelectedObjects += 1;
1875 }
1876 if (numberOfSelectedObjects > 1)
1877 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Multiple objects selected. Cannot assign object IDs to vector element. "
1878 "Perhaps use a vector variable instead.");
1879 if (numberOfSelectedObjects == 0)
1880 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No objects selected. Cannot assign object ID to vector element.");
1881 value = theCurrentPraatObjectscxx . . $ theCurrentPraatObjects. -> listcxx . . $ structPraatObjects#list. [selectedObject]. idcxx . . $ structPraat_Object#id.;
1882 } else {
1883 value = Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (valueString.stringcxx . . $ MelderString#string.); // including --undefined--
1884 }
1885 } else {
1886 /*
1887 Get the value of the formula.
1888 */
1889 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, p, & value);
1890 }
1891 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName);
1892 if (! var)
1893 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Vector ", vectorName, U" does not exist.");
1894 /*@praat
1895 asserterror Vector interpreter_assignToVector# does not exist.
1896 interpreter_assignToVector# [5] = 3
1897 @*/
1898 if (indexValue < 1)
1899 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A vector index cannot be less than 1 (the index you supplied is ", indexValue, U").");
1900 if (indexValue > var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..sizecxx . . $ autovector#size.)
1901 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A vector index cannot be greater than the number of elements (here ",
1902 var -> numericVectorValue.size, U"). The index you supplied is ", indexValue, U".");
1903 if (assignmentType == 0)
1904 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).indexValue] = value;
1905 else if (assignmentType == 1)
1906 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).indexValue] += value;
1907 else if (assignmentType == 2)
1908 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).indexValue] -= value;
1909 else if (assignmentType == 3)
1910 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).indexValue] *= value;
1911 else if (assignmentType == 4)
1912 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).indexValue] /= value;
1913 else
1914 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (false);
1915 }
1916
1917 static void assignToNumericMatrixElementcxx . . $ assignToNumericMatrixElement(61d4635e44240b16). (Interpretercxx . . $ Interpreter# me, char32cxx . . $ char32# *& p, const char32cxx . . $ char32#* matrixName, MelderStringcxx . . $ MelderString#& valueString) {
1918 integercxx . . $ integer# rowNumber = 0, columnNumber = 0;
1919 /*
1920 Get the row number.
1921 */
1922 static MelderStringcxx . . $ MelderString# rowFormula;
1923 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& rowFormula);
1924 int depth = 0;
1925 bool inString = false;
1926 while ((depth > 0 || *p != U',' || inString) && Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) {
1927 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& rowFormula, *p);
1928 if (*p == U'[' || *p == U'(') {
1929 if (! inString)
1930 depth ++;
1931 } else if (*p == U']' || *p == U')') {
1932 if (! inString)
1933 depth --;
1934 }
1935 if (*p == U'"') inString = ! inString;
1936 p ++;
1937 }
1938 if (! Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p))
1939 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing comma in matrix indexing.");
1940 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
1941 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, rowFormula.stringcxx . . $ MelderString#string., & result);
1942 if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
1943 rowNumber = Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (result. numericResultcxx . . $ Formula_Result#numericResult.);
1944 } else {
1945 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Row number should be numeric.");
1946 }
1947 p ++; // step over comma
1948 /*
1949 Get the column number.
1950 */
1951 static MelderStringcxx . . $ MelderString# columnFormula;
1952 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& columnFormula);
1953 depth = 0;
1954 inString = false;
1955 while ((depth > 0 || *p != U']' || inString) && Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) {
1956 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& columnFormula, *p);
1957 if (*p == U'[') {
1958 if (! inString)
1959 depth ++;
1960 } else if (*p == U']') {
1961 if (! inString)
1962 depth --;
1963 }
1964 if (*p == U'"')
1965 inString = ! inString;
1966 p ++;
1967 }
1968 if (! Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p))
1969 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing bracket (]) in matrix indexing.");
1970 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, columnFormula.stringcxx . . $ MelderString#string., & result);
1971 if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
1972 columnNumber = Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (result. numericResultcxx . . $ Formula_Result#numericResult.);
1973 } else {
1974 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Column number should be numeric.");
1975 }
1976 p ++; // step over closing bracket
1977 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
1978 int assignmentType = 0;
1979 if (*p == U'=') {
1980 p ++; // step over equals sign
1981 } else if (*p == U'+' && p [1] == U'=') {
1982 assignmentType = 1;
1983 p += 2; // step over plus-gets sign
1984 } else if (*p == U'-' && p [1] == U'=') {
1985 assignmentType = 2;
1986 p += 2; // step over minus-gets sign
1987 } else if (*p == U'*' && p [1] == U'=') {
1988 assignmentType = 3;
1989 p += 2; // step over times-gets sign
1990 } else if (*p == U'/' && p [1] == U'=') {
1991 assignmentType = 4;
1992 p += 2; // step over div-gets sign
1993 } else
1994 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing '=', '+=', '-=', '*=' or '/=' after matrix element ", matrixName, U" [",
1995 rowFormula.string, U",", columnFormula.string, U"].");
1996 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (&p); // go to first token after assignment
1997 if (*p == U'\0')
1998 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing expression after matrix element ", matrixName, U" [",
1999 rowFormula.string, U",", columnFormula.string, U"].");
2000 double value;
2001 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
2002 /*
2003 Get the value of the query.
2004 */
2005 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& valueString);
2006 autoMelderDivertInfocxx . . $ autoMelderDivertInfo# divertcxx . . $ autoMelderDivertInfo#autoMelderDivertInfo(93db1090f27e5462). (& valueString);
2007 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& valueString, 1); // will be overwritten by something totally different if any MelderInfo function is called...
2008 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
2009 if (! status) {
2010 value = undefinedcxx . . $ undefined.;
2011 } else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::OBJECT_cxx . . $ kInterpreter_ReturnType#OBJECT_.) {
2012 integercxx . . $ integer# IOBJECT, selectedObject = 0, numberOfSelectedObjects = 0;
2013 WHEREcxx . . $ `sys/praat.h:198:9`! (SELECTEDcxx . . $ `sys/praat.h:200:9`!) {
2014 selectedObject = IOBJECT;
2015 numberOfSelectedObjects += 1;
2016 }
2017 if (numberOfSelectedObjects > 1)
2018 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Multiple objects selected. Cannot assign object IDs to matrix element. "
2019 "Perhaps use a vector variable instead.");
2020 if (numberOfSelectedObjects == 0)
2021 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No objects selected. Cannot assign object ID to matrix element.");
2022 value = theCurrentPraatObjectscxx . . $ theCurrentPraatObjects. -> listcxx . . $ structPraatObjects#list. [selectedObject]. idcxx . . $ structPraat_Object#id.;
2023 } else {
2024 value = Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (valueString.stringcxx . . $ MelderString#string.); // including --undefined--
2025 }
2026 } else {
2027 /*
2028 Get the value of the formula.
2029 */
2030 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, p, & value);
2031 }
2032 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, matrixName);
2033 if (! var)
2034 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Matrix ", matrixName, U" does not exist.");
2035 if (rowNumber < 1)
2036 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A row number cannot be less than 1 (the row number you supplied is ", rowNumber, U").");
2037 if (rowNumber > var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue.. nrowcxx . . $ automatrix#nrow.)
2038 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A row number cannot be greater than the number of rows (here ",
2039 var -> numericMatrixValue. nrow, U"). The row number you supplied is ", rowNumber, U".");
2040 if (columnNumber < 1)
2041 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A column number cannot be less than 1 (the column number you supplied is ", columnNumber, U").");
2042 if (columnNumber > var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue.. ncolcxx . . $ automatrix#ncol.)
2043 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A column number cannot be greater than the number of columns (here ",
2044 var -> numericMatrixValue. ncol, U"). The column number you supplied is ", columnNumber, U".");
2045 if (assignmentType == 0)
2046 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).rowNumber] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).columnNumber] = value;
2047 else if (assignmentType == 1)
2048 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).rowNumber] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).columnNumber] += value;
2049 else if (assignmentType == 2)
2050 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).rowNumber] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).columnNumber] -= value;
2051 else if (assignmentType == 3)
2052 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).rowNumber] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).columnNumber] *= value;
2053 else if (assignmentType == 4)
2054 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).rowNumber] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).columnNumber] /= value;
2055 else
2056 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (false);
2057 }
2058
2059 static void assignToStringArrayElementcxx . . $ assignToStringArrayElement(61d4635e44240b16). (Interpretercxx . . $ Interpreter# me, char32cxx . . $ char32# *& p, const char32cxx . . $ char32#* vectorName, MelderStringcxx . . $ MelderString#& valueString) {
2060 integercxx . . $ integer# indexValue = 0;
2061 static MelderStringcxx . . $ MelderString# index;
2062 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& index);
2063 int depth = 0;
2064 bool inString = false;
2065 while ((depth > 0 || *p != U']' || inString) && Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) {
2066 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& index, *p);
2067 if (*p == U'[') {
2068 if (! inString)
2069 depth ++;
2070 } else if (*p == U']') {
2071 if (! inString)
2072 depth --;
2073 }
2074 if (*p == U'"') inString = ! inString;
2075 p ++;
2076 }
2077 if (! Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p))
2078 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing bracket (]) in array element.");
2079 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
2080 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, index.stringcxx . . $ MelderString#string., & result);
2081 if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
2082 indexValue = Melder_iroundcxx . . $ `melder/melder_ftoi.h:78:9`! (result. numericResultcxx . . $ Formula_Result#numericResult.);
2083 } else {
2084 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Element index should be numeric.");
2085 }
2086 p ++; // step over closing bracket
2087 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
2088 if (*p != U'=')
2089 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing '=' after string vector element ", vectorName, U" [", index.string, U"].");
2090 p ++; // step over equals sign
2091 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
2092 if (*p == U'\0')
2093 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing expression after string vector element ", vectorName, U" [", index.string, U"].");
2094 autostring32cxx . . $ autostring32# valuecxx . . $ _autostring#_autostring(49f6e7a06ebc5aa8).;
2095 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
2096 /*
2097 Get the value of the query.
2098 */
2099 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& valueString);
2100 autoMelderDivertInfocxx . . $ autoMelderDivertInfo# divertcxx . . $ autoMelderDivertInfo#autoMelderDivertInfo(93db1090f27e5462). (& valueString);
2101 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
2102 if (! status)
2103 value =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). autostring32cxx . . $ _autostring#_autostring(49f6e7a06ebc5aa8).();
2104 else
2105 value =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (valueString.stringcxx . . $ MelderString#string.);
2106 } else {
2107 /*
2108 Get the value of the formula.
2109 */
2110 value =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Interpreter_stringExpressioncxx . . $ Interpreter_stringExpression(ae2ff4958c59280d). (me, p);
2111 }
2112 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName);
2113 if (! var)
2114 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"String vector ", vectorName, U" does not exist.");
2115 if (indexValue < 1)
2116 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A vector index cannot be less than 1 (the index you supplied is ", indexValue, U").");
2117 if (indexValue > var -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue..sizecxx . . $ _autostringautovector#size.)
2118 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"A vector index cannot be greater than the number of elements (here ",
2119 var -> stringArrayValue.size, U"). The index you supplied is ", indexValue, U".");
2120 var -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).indexValue] =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). value. movecxx . . $ _autostring#move(bd43c759570f178f).();
2121 }
2122
2123 static void private_Interpreter_initializecxx . . $ private_Interpreter_initialize(eec3dd5f99c9d46a). (Interpretercxx . . $ Interpreter# me, autostring32cxx . . $ autostring32# text, const bool reuseVariables) {
2124 if (text)
2125 mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structInterpreter#text. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). text.movecxx . . $ _autostring#move(bd43c759570f178f).(); // otherwise, use my existing text
2126 char32cxx . . $ char32# *command = mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structInterpreter#text..getcxx . . $ _autostring#get(5a2a78a048fb49a8).();
2127 autoMelderStringcxx . . $ autoMelderString# command2cxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
2128 integercxx . . $ integer# numberOfLines = 0;
2129 bool atLastLine = false;
2130 int chopped = 0;
2131 /*
2132 Count lines and set the newlines to zero.
2133 */
2134 while (! atLastLine) {
2135 char32cxx . . $ char32# *endOfLine = command;
2136 while (Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*endOfLine))
2137 endOfLine ++;
2138 if (*endOfLine == U'\0')
2139 atLastLine = true;
2140 *endOfLine = U'\0';
2141 numberOfLines ++;
2142 command = endOfLine + 1;
2143 }
2144 /*
2145 Remember line starts, labels and procedures.
2146 */
2147 mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines.. resizecxx . . $ autovector#resize(d91e89fbd57cd1). (numberOfLines);
2148 command = mycxx . . $ `melder/melder.h:44:9`! textcxx . . $ structInterpreter#text..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(); // reset
2149 mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames.. resetcxx . . $ _autostringautovector#reset(49f6e7a06ebc5aa8).();
2150 mycxx . . $ `melder/melder.h:44:9`! labelLinescxx . . $ structInterpreter#labelLines.. resetcxx . . $ autovector#reset(ced63f7c635d850d).();
2151 mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames.. resetcxx . . $ _autostringautovector#reset(49f6e7a06ebc5aa8).();
2152 mycxx . . $ `melder/melder.h:44:9`! procedureStartLinescxx . . $ structInterpreter#procedureStartLines.. resetcxx . . $ autovector#reset(ced63f7c635d850d).();
2153 for (integercxx . . $ integer# lineNumber = 1; lineNumber <= numberOfLines; lineNumber ++, command += Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (command) + 1 + chopped) {
2154 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& command); // nbsp can occur for scripts copied from the manual
2155 /*
2156 Chop trailing spaces?
2157 */
2158 #if 0
2159 chopped = 0;
2160 const integer length = Melder_length (command);
2161 while (length > 0) {
2162 char kar = command [-- length];
2163 if (! Melder_isHorizontalSpace (kar))
2164 break;
2165 command [length] = U'\0';
2166 chopped ++;
2167 }
2168 #endif
2169 mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).lineNumber] = command;
2170 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command, U"label", 5) && Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command [5])) {
2171 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& command2);
2172 for (integercxx . . $ integer# ichar = 6; ; ichar ++) {
2173 if (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command [ichar]) || command [ichar] == U';' || command [ichar] == U'\0')
2174 break;
2175 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& command2, command [ichar]);
2176 }
2177 mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames.. insertcxx . . $ _autostringautovector#insert(cfe533a552fd45e9). (0, command2.stringcxx . . $ MelderString#string.);
2178 mycxx . . $ `melder/melder.h:44:9`! labelLinescxx . . $ structInterpreter#labelLines.. insertcxx . . $ autovector#insert(c00212e9bf9e5df). (0, lineNumber);
2179 }
2180 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command, U"procedure", 9) && Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command [9])) {
2181 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& command2);
2182 for (integercxx . . $ integer# ichar = 10; ; ichar ++) {
2183 if (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command [ichar]) || command [ichar] == U';' || command [ichar] == U':' || command [ichar] == U'\0')
2184 break;
2185 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& command2, command [ichar]);
2186 }
2187 mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames.. insertcxx . . $ _autostringautovector#insert(cfe533a552fd45e9). (0, command2.stringcxx . . $ MelderString#string.);
2188 mycxx . . $ `melder/melder.h:44:9`! procedureStartLinescxx . . $ structInterpreter#procedureStartLines.. insertcxx . . $ autovector#insert(c00212e9bf9e5df). (0, lineNumber);
2189 }
2190 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command, U"proc", 4) && Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command [4])) {
2191 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& command2);
2192 for (integercxx . . $ integer# ichar = 5; ; ichar ++) {
2193 if (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command [ichar]) || command [ichar] == U';' || command [ichar] == U':' || command [ichar] == U'\0')
2194 break;
2195 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& command2, command [ichar]);
2196 }
2197 mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames.. insertcxx . . $ _autostringautovector#insert(cfe533a552fd45e9). (0, command2.stringcxx . . $ MelderString#string.);
2198 mycxx . . $ `melder/melder.h:44:9`! procedureStartLinescxx . . $ structInterpreter#procedureStartLines.. insertcxx . . $ autovector#insert(c00212e9bf9e5df). (0, lineNumber);
2199 }
2200 }
2201 NUMsortTogethercxx . . $ NUMsortTogether(fce7383e8ea9e411). (mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames..getcxx . . $ _autostringautovector#get(9d56076a9ef7dd02).(), mycxx . . $ `melder/melder.h:44:9`! labelLinescxx . . $ structInterpreter#labelLines..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
2202 for (integercxx . . $ integer# ilabel = 1; ilabel < mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames..sizecxx . . $ _autostringautovector#size.; ilabel ++)
2203 if (str32equcxx . . $ `melder/melder_str32.h:122:9`! (mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).ilabel].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! labelNamescxx . . $ structInterpreter#labelNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).ilabel + 1].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()))
2204 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Duplicate label \"", mycxx . . $ `melder/melder.h:44:9`! labelNames [ilabel].get(),
2205 U"\" on lines ", mycxx . . $ `melder/melder.h:44:9`! labelLines [ilabel], U" and ", mycxx . . $ `melder/melder.h:44:9`! labelLines [ilabel + 1], U".");
2206 NUMsortTogethercxx . . $ NUMsortTogether(fce7383e8ea9e411). (mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames..getcxx . . $ _autostringautovector#get(9d56076a9ef7dd02).(), mycxx . . $ `melder/melder.h:44:9`! procedureStartLinescxx . . $ structInterpreter#procedureStartLines..getcxx . . $ autovector#get(e8d1da7fe68a6585).());
2207 for (integercxx . . $ integer# iproc = 1; iproc < mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames..sizecxx . . $ _autostringautovector#size.; iproc ++)
2208 if (str32equcxx . . $ `melder/melder_str32.h:122:9`! (mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).iproc].getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), mycxx . . $ `melder/melder.h:44:9`! procedureNamescxx . . $ structInterpreter#procedureNames. [cxx . . $ _autostringautovector#`operator[]`(f191be2b65019068).iproc + 1].getcxx . . $ _autostring#get(5a2a78a048fb49a8).()))
2209 Melder_warning_oncecxx . . $ `melder/melder_warning.h:73:9`! (
2210 U"Duplicate procedure \"", mycxx . . $ `melder/melder.h:44:9`! procedureNames [iproc].get(),
2211 U"\" on lines ", mycxx . . $ `melder/melder.h:44:9`! procedureStartLines [iproc], U" and ", mycxx . . $ `melder/melder.h:44:9`! procedureStartLines [iproc + 1],
2212 U". This is probably a bug, for which you may want to contact the author of the script. "
2213 U"The script will run, but it is unpredictable which of the two procedure definitions will be chosen."
2214 ); // TURNED INTO WARNING 2026, SCHEDULED FOR ERROR 2036
2215 /*
2216 Connect continuation lines.
2217 */
2218 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"connect continuation lines");
2219 for (integercxx . . $ integer# lineNumber = numberOfLines; lineNumber >= 2; lineNumber --) {
2220 char32cxx . . $ char32# *line = mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).lineNumber];
2221 if (line [0] == U'.' && line [1] == U'.' && line [2] == U'.') {
2222 char32cxx . . $ char32# *previous = mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).lineNumber - 1];
2223 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& command2, line + 3);
2224 MelderString_getcxx . . $ MelderString_get(3e9758003f5426aa). (& command2, previous + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (previous));
2225 static char32cxx . . $ char32# emptyLine [] = { U'\0' };
2226 mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).lineNumber] = emptyLine;
2227 }
2228 }
2229 /*
2230 Copy the parameter names and argument values into the array of variables.
2231 */
2232 if (! reuseVariables) {
2233 mycxx . . $ `melder/melder.h:44:9`! variablesMapcxx . . $ structInterpreter#variablesMap.. clearcxx . . $ std/unordered_map#clear(ced63f7c635d850d). ();
2234 for (int ipar = 1; ipar <= mycxx . . $ `melder/melder.h:44:9`! numberOfParameterscxx . . $ structInterpreter#numberOfParameters.; ipar ++) {
2235 char32cxx . . $ char32# parameter [1+Interpreter_MAX_PARAMETER_LENGTHcxx . . $ `sys/Interpreter.h:40:9`!];
2236 /*
2237 Create variable names as-are and variable names without capitals.
2238 */
2239 str32cpycxx . . $ str32cpy(6ab934322573b179). (parameter, mycxx . . $ `melder/melder.h:44:9`! parameterscxx . . $ structInterpreter#parameters. [ipar]);
2240 parameterToVariablecxx . . $ parameterToVariable(e0eb84388112a533). (me, mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar], parameter, ipar); // deprecated 2014? probably works only with parameter substitution
2241 if (parameter [0] >= U'A' && parameter [0] <= U'Z') {
2242 parameter [0] = Melder_toLowerCasecxx . . $ Melder_toLowerCase(cd1afca5b9692c51). (parameter [0]);
2243 parameterToVariablecxx . . $ parameterToVariable(e0eb84388112a533). (me, mycxx . . $ `melder/melder.h:44:9`! typescxx . . $ structInterpreter#types. [ipar], parameter, ipar);
2244 }
2245 }
2246 /*
2247 Initialize some variables.
2248
2249 TODO: turn newline$ and tab$ into constants
2250 Time path:
2251 1. in 20xx, start asking for trust when assigning to these variables
2252 2. ten years later, assigning to these variables becomes an error (with an appropriate warning and recipe for correction),
2253 just as with `pi`, `undefined` and `e`.
2254
2255 TODO: turn the remainder of these variables into functions
2256 Time path:
2257 1. in 20xx, add functions to the side
2258 2. ten years later, start warning against undefined use of these variables
2259 3. another ten years later, undefined us of these variables becomes an error (with an appropriate warning and recipe for correction)
2260 */
2261 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"newline$", U"\n");
2262 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"tab$", U"\t");
2263 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"shellDirectory$", Melder_getShellDirectorycxx . . $ Melder_getShellDirectory(1912f6684645c851). ());
2264 {// scope
2265 structMelderFoldercxx . . $ structMelderFolder# folder { };
2266 Melder_getCurrentFoldercxx . . $ Melder_getCurrentFolder(63f38d3b6b86d1dc). (& folder);
2267 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"defaultDirectory$", MelderFolder_peekPathcxx . . $ MelderFolder_peekPath(fbe3b4f4d15c56ee). (& folder));
2268 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"preferencesDirectory$", MelderFolder_peekPathcxx . . $ MelderFolder_peekPath(fbe3b4f4d15c56ee). (Melder_preferencesFoldercxx . . $ Melder_preferencesFolder(3f0bf42ba8f9aa29).())); // settingsFolder$()
2269 Melder_getHomeDircxx . . $ Melder_getHomeDir(63f38d3b6b86d1dc). (& folder);
2270 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"homeDirectory$", MelderFolder_peekPathcxx . . $ MelderFolder_peekPath(fbe3b4f4d15c56ee). (& folder));
2271 Melder_getTempDircxx . . $ Melder_getTempDir(63f38d3b6b86d1dc). (& folder);
2272 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"temporaryDirectory$", MelderFolder_peekPathcxx . . $ MelderFolder_peekPath(fbe3b4f4d15c56ee). (& folder));
2273 }
2274 #if defined (macintosh)
2275 Interpreter_addNumericVariable (me, U"macintosh", 1);
2276 Interpreter_addNumericVariable (me, U"windows", 0);
2277 Interpreter_addNumericVariable (me, U"unix", 0);
2278 #elif defined (_WIN32)
2279 Interpreter_addNumericVariable (me, U"macintosh", 0);
2280 Interpreter_addNumericVariable (me, U"windows", 1);
2281 Interpreter_addNumericVariable (me, U"unix", 0);
2282 #elif defined (UNIXcxx . . $ `<built-in>:479:9`!)
2283 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"macintosh", 0);
2284 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"windows", 0);
2285 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"unix", 1);
2286 #else
2287 Interpreter_addNumericVariable (me, U"macintosh", 0);
2288 Interpreter_addNumericVariable (me, U"windows", 0);
2289 Interpreter_addNumericVariable (me, U"unix", 0);
2290 #endif
2291 #if defined (__aarch64__) || defined (_M_ARM64_)
2292 Interpreter_addNumericVariable (me, U"praat_intel32", 0);
2293 Interpreter_addNumericVariable (me, U"praat_intel64", 0);
2294 Interpreter_addNumericVariable (me, U"praat_arm64", 1);
2295 Interpreter_addNumericVariable (me, U"praat_s390x", 0);
2296 Interpreter_addNumericVariable (me, U"praat_armv7", 0);
2297 #elif defined (__s390x__)
2298 Interpreter_addNumericVariable (me, U"praat_intel32", 0);
2299 Interpreter_addNumericVariable (me, U"praat_intel64", 0);
2300 Interpreter_addNumericVariable (me, U"praat_arm64", 0);
2301 Interpreter_addNumericVariable (me, U"praat_s390x", 1);
2302 Interpreter_addNumericVariable (me, U"praat_armv7", 0);
2303 #elif defined (raspberrypi)
2304 Interpreter_addNumericVariable (me, U"praat_intel32", 0);
2305 Interpreter_addNumericVariable (me, U"praat_intel64", 0);
2306 Interpreter_addNumericVariable (me, U"praat_arm64", 0);
2307 Interpreter_addNumericVariable (me, U"praat_s390x", 0);
2308 Interpreter_addNumericVariable (me, U"praat_armv7", 1);
2309 #else
2310 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_intel32", sizeof (void *) == 4);
2311 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_intel64", sizeof (void *) == 8);
2312 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_arm64", 0);
2313 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_s390x", 0);
2314 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_armv7", 0);
2315 #endif
2316 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_32bit", sizeof (void *) == 4);
2317 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praat_64bit", sizeof (void *) == 8);
2318 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"left", 1); // deprecated 2010 (Praat 5.2.06)
2319 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"right", 2); // deprecated 2010 (Praat 5.2.06)
2320 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"mono", 1); // deprecated 2010 (Praat 5.2.06)
2321 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"stereo", 2); // deprecated 2010 (Praat 5.2.06)
2322 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"all", 0); // deprecated 2010 (Praat 5.2.06)
2323 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"average", 0); // deprecated 2010 (Praat 5.2.06)
2324 Interpreter_addStringVariablecxx . . $ Interpreter_addStringVariable(88746eaab04bd575). (me, U"praatVersion$", Melder_appVersionSTRcxx . . $ Melder_appVersionSTR(1912f6684645c851).());
2325 Interpreter_addNumericVariablecxx . . $ Interpreter_addNumericVariable(c77716fba6088d5a). (me, U"praatVersion", Melder_appVersioncxx . . $ Melder_appVersion(da6335ded91d79c2).());
2326 }
2327 }
2328
2329 void Interpreter_runcxx . . $ Interpreter_run(eec3dd5f99c9d46a). (Interpretercxx . . $ Interpreter# me, autostring32cxx . . $ autostring32# text, const bool reuseVariables) {
2330 try {
2331 //TRACE
2332 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"enter");
2333 private_Interpreter_initializecxx . . $ private_Interpreter_initialize(eec3dd5f99c9d46a). (me, textcxx . . $ _autostring#_autostring(39021ecceedcc7d2)..movecxx . . $ _autostring#move(bd43c759570f178f).(), reuseVariables);
2334 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = 1;
2335 mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth. = 0;
2336 mycxx . . $ `melder/melder.h:44:9`! fromifcxx . . $ structInterpreter#fromif. = false;
2337 mycxx . . $ `melder/melder.h:44:9`! fromendforcxx . . $ structInterpreter#fromendfor. = false;
2338 mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. = 0;
2339 mycxx . . $ `melder/melder.h:44:9`! setDynamicFromOwningEditorEnvironmentcxx . . $ structInterpreter#setDynamicFromOwningEditorEnvironment(ced63f7c635d850d). ();
2340 Interpreter_resumecxx . . $ Interpreter_resume(448c181fe9dacca8). (me);
2341 } catch (MelderErrorcxx . . $ MelderError#) {
2342 throw;
2343 }
2344 }
2345
2346 void Interpreter_resumecxx . . $ Interpreter_resume(448c181fe9dacca8). (Interpretercxx . . $ Interpreter# me) {
2347 /*
2348 Start.
2349 */
2350 mycxx . . $ `melder/melder.h:44:9`! runningcxx . . $ structInterpreter#running. = true;
2351 mycxx . . $ `melder/melder.h:44:9`! stoppedcxx . . $ structInterpreter#stopped. = false;
2352 mycxx . . $ `melder/melder.h:44:9`! isHaltedcxx . . $ structInterpreter#isHalted. = false;
2353 bool assertionFailed = false;
2354 //TRACE
2355 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"resuming at line ", mycxx . . $ `melder/melder.h:44:9`! lineNumber, U" in file ", & mycxx . . $ `melder/melder.h:44:9`! file);
2356 try {
2357 static MelderStringcxx . . $ MelderString# valueString; // to divert the info
2358 autoMelderStringcxx . . $ autoMelderString# command2cxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
2359 autoMelderStringcxx . . $ autoMelderString# buffercxx . . $ autoMelderString#autoMelderString(49f6e7a06ebc5aa8).;
2360 int callDepth = mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth.;
2361 const integercxx . . $ integer# numberOfLines = mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines..sizecxx . . $ autovector#size.;
2362 /*
2363 Execute commands.
2364 */
2365 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"going to handle ", numberOfLines, U" lines");
2366 //for (integer lineNumber = 1; lineNumber <= numberOfLines; lineNumber ++) {
2367 //trace (U"line ", lineNumber, U": ", lines [lineNumber]);
2368 //}
2369 for (; mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. <= numberOfLines; mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. ++) {
2370 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"considering to handle line ", mycxx . . $ `melder/melder.h:44:9`! lineNumber, U": ", mycxx . . $ `melder/melder.h:44:9`! lines [mycxx . . $ `melder/melder.h:44:9`! lineNumber], U", stopped ", mycxx . . $ `melder/melder.h:44:9`! stopped, U", halted ", mycxx . . $ `melder/melder.h:44:9`! isHalted, U", pass ", 1 + mycxx . . $ `melder/melder.h:44:9`! isInSecondPass);
2371 if (mycxx . . $ `melder/melder.h:44:9`! stoppedcxx . . $ structInterpreter#stopped.)
2372 break;
2373 if (mycxx . . $ `melder/melder.h:44:9`! isHaltedcxx . . $ structInterpreter#isHalted.)
2374 break;
2375 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"going to handle line ", mycxx . . $ `melder/melder.h:44:9`! lineNumber, U": ", mycxx . . $ `melder/melder.h:44:9`! lines [mycxx . . $ `melder/melder.h:44:9`! lineNumber]);
2376 constvectorcxx . . $ constvector# <mutablestring32cxx . . $ mutablestring32#> lines = mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines..getcxx . . $ autovector#get(e8d1da7fe68a6585).();
2377 try {
2378 char32cxx . . $ char32# c0;
2379 bool fail = false;
2380 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& command2, lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.]);
2381 c0 = command2.stringcxx . . $ MelderString#string. [0];
2382 if (c0 == U'\0')
2383 continue;
2384 /*
2385 Substitute variables.
2386 */
2387 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"preprocessing line ", mycxx . . $ `melder/melder.h:44:9`! lineNumber, U": ", command2.string);
2388 for (char32cxx . . $ char32# *p = & command2.stringcxx . . $ MelderString#string. [0]; *p != U'\0'; p ++) if (*p == U'\'') {
2389 /*
2390 Found a left quote. Search for a matching right quote.
2391 */
2392 char32cxx . . $ char32# *q = p + 1, varName [300], *r, *s;
2393 integercxx . . $ integer# precision = -1;
2394 bool percent = false;
2395 while (*q != U'\0' && *q != U'\'' && q - p < 299)
2396 q ++;
2397 if (*q == U'\0')
2398 break; // no matching right quote? done with this line!
2399 if (q - p == 1 || q - p >= 299)
2400 continue; // ignore empty and too long variable names
2401 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"found ", q - p - 1);
2402 /*
2403 Found a right quote. Get potential variable name.
2404 */
2405 for (r = p + 1, s = varName; q - r > 0; r ++, s ++)
2406 *s = *r;
2407 *s = U'\0'; // trailing null byte
2408 char32cxx . . $ char32# *colon = str32chrcxx . . $ str32chr(328a9ede0fba853a). (varName, U':');
2409 if (colon) {
2410 precision = Melder_atoicxx . . $ Melder_atoi(c94c67ff4219bf83). (colon + 1);
2411 if (str32chrcxx . . $ str32chr(328a9ede0fba853a). (colon + 1, U'%'))
2412 percent = true;
2413 *colon = U'\0';
2414 }
2415 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, varName);
2416 if (var) {
2417 /*
2418 Found a variable (p points to the left quote, q to the right quote). Substitute.
2419 */
2420 const integercxx . . $ integer# headlen = p - command2.stringcxx . . $ MelderString#string.;
2421 conststring32cxx . . $ conststring32# string = ( var -> stringValuecxx . . $ structInterpreterVariable#stringValue. ? var -> stringValuecxx . . $ structInterpreterVariable#stringValue..getcxx . . $ _autostring#get(5a2a78a048fb49a8).() :
2422 percent ? Melder_percentcxx . . $ Melder_percent(5b9062840a6ade99). (var -> numericValuecxx . . $ structInterpreterVariable#numericValue., precision) :
2423 precision >= 0 ? Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (var -> numericValuecxx . . $ structInterpreterVariable#numericValue., precision) :
2424 Melder_doublecxx . . $ Melder_double(f05d861d9dbec9b2). (var -> numericValuecxx . . $ structInterpreterVariable#numericValue.) );
2425 const integercxx . . $ integer# arglen = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (string);
2426 MelderString_ncopycxx . . $ MelderString_ncopy(b76236fd155635ca). (& buffer, command2.stringcxx . . $ MelderString#string., headlen);
2427 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& buffer, string, q + 1);
2428 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& command2, buffer.stringcxx . . $ MelderString#string.); // This invalidates p!! (really bad bug 20070203)
2429 p = command2.stringcxx . . $ MelderString#string. + headlen + arglen - 1;
2430 } else {
2431 p = q - 1; // go to before next quote
2432 }
2433 }
2434 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"going to parse line ", mycxx . . $ `melder/melder.h:44:9`! lineNumber, U": ", command2.string);
2435 c0 = command2.stringcxx . . $ MelderString#string. [0]; // resume in order to allow things like 'c$' = 5
2436 if ((! Melder_isLettercxx . . $ Melder_isLetter(b8d0204ce8416907). (c0) || Melder_isUpperCaseLettercxx . . $ Melder_isUpperCaseLetter(b8d0204ce8416907). (c0)) && c0 != U'@' &&
2437 ! (c0 == U'.' && Melder_isLettercxx . . $ Melder_isLetter(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [1]) && ! Melder_isUpperCaseLettercxx . . $ Melder_isUpperCaseLetter(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [1])))
2438 {
2439 (void) praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, command2.stringcxx . . $ MelderString#string.);
2440 /*
2441 Interpret control flow and variables.
2442 */
2443 } else switch (c0) {
2444 case U'.':
2445 fail = true;
2446 break;
2447 case U'@':
2448 Interpreter_do_procedureCallcxx . . $ Interpreter_do_procedureCall(5c6c60d1f5ffef11). (me, command2.stringcxx . . $ MelderString#string. + 1, lines, mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber., mycxx . . $ `melder/melder.h:44:9`! callStackcxx . . $ structInterpreter#callStack., callDepth);
2449 break;
2450 case U'a':
2451 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"assert ", 7)) {
2452 double value;
2453 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, command2.stringcxx . . $ MelderString#string. + 7, & value);
2454 if (value == 0.0 || isundefcxx . . $ isundef(f8197d536af80c96). (value)) {
2455 assertionFailed = true;
2456 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Script assertion fails in line ", mycxx . . $ `melder/melder.h:44:9`! lineNumber,
2457 U" (", value == 0.0 ? U"false" : U"undefined", U"):\n ", command2.string + 7);
2458 }
2459 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"asserterror ", 12)) {
2460 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& mycxx . . $ `melder/melder.h:44:9`! assertErrorStringcxx . . $ structInterpreter#assertErrorString., command2.stringcxx . . $ MelderString#string. + 12);
2461 //TRACE
2462 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"assert error string: <<", mycxx . . $ `melder/melder.h:44:9`! assertErrorString.string, U">>");
2463 mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.;
2464 } else
2465 fail = true;
2466 break;
2467 case U'b':
2468 fail = true;
2469 break;
2470 case U'c':
2471 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"call ", 5)) {
2472 Interpreter_do_oldProcedureCallcxx . . $ Interpreter_do_oldProcedureCall(5c6c60d1f5ffef11). (me, command2.stringcxx . . $ MelderString#string. + 5, lines, mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber., mycxx . . $ `melder/melder.h:44:9`! callStackcxx . . $ structInterpreter#callStack., callDepth);
2473 } else
2474 fail = true;
2475 break;
2476 case U'd':
2477 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"dec ", 4)) {
2478 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, command2.stringcxx . . $ MelderString#string. + 4);
2479 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. -= 1.0;
2480 } else
2481 fail = true;
2482 break;
2483 case U'e':
2484 if (command2.stringcxx . . $ MelderString#string. [1] == U'n' && command2.stringcxx . . $ MelderString#string. [2] == U'd') {
2485 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"endif", 5) &&
2486 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [5]) || command2.stringcxx . . $ MelderString#string. [5] == U';'))
2487 {
2488 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (command2.stringcxx . . $ MelderString#string. + 5);
2489 if (startOfInk && *startOfInk != U';')
2490 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endif'.");
2491 /* Ignore. */
2492 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"endfor", 6) &&
2493 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [6]) || command2.stringcxx . . $ MelderString#string. [6] == U';'))
2494 {
2495 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (command2.stringcxx . . $ MelderString#string. + 6);
2496 if (startOfInk && *startOfInk != U';')
2497 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endfor'.");
2498 int depth = 0;
2499 integercxx . . $ integer# iline;
2500 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. - 1; iline > 0; iline --) {
2501 char32cxx . . $ char32# *line = lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline];
2502 if (line [0] == U'f' && line [1] == U'o' && line [2] == U'r' && line [3] == U' ') {
2503 if (depth == 0) { mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline - 1; mycxx . . $ `melder/melder.h:44:9`! fromendforcxx . . $ structInterpreter#fromendfor. = true; break; } // go before 'for'
2504 else depth --;
2505 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endfor", 6) &&
2506 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [6]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [6] == U';'))
2507 {
2508 depth ++;
2509 }
2510 }
2511 if (iline <= 0) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'endfor'.");
2512 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"endwhile", 8) &&
2513 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [8]) || command2.stringcxx . . $ MelderString#string. [8] == U';'))
2514 {
2515 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (command2.stringcxx . . $ MelderString#string. + 8);
2516 if (startOfInk && *startOfInk != U';')
2517 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endwhile'.");
2518 int depth = 0;
2519 integercxx . . $ integer# iline;
2520 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. - 1; iline > 0; iline --) {
2521 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"while ", 6)) {
2522 if (depth == 0) {
2523 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline - 1;
2524 break; // go before 'while'
2525 } else
2526 depth --;
2527 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endwhile", 8) &&
2528 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [8]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [8] == U';'))
2529 {
2530 depth ++;
2531 }
2532 }
2533 if (iline <= 0) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'endwhile'.");
2534 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"endproc", 7) &&
2535 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [7]) || command2.stringcxx . . $ MelderString#string. [7] == U';'))
2536 {
2537 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (command2.stringcxx . . $ MelderString#string. + 7);
2538 if (startOfInk && *startOfInk != U';')
2539 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endproc'.");
2540 if (callDepth == 0)
2541 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'endproc'.");
2542 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = mycxx . . $ `melder/melder.h:44:9`! callStackcxx . . $ structInterpreter#callStack. [callDepth --];
2543 -- mycxx . . $ `melder/melder.h:44:9`! callDepthcxx . . $ structInterpreter#callDepth.;
2544 } else fail = true;
2545 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"else", 4) &&
2546 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [4]) || command2.stringcxx . . $ MelderString#string. [4] == U';'))
2547 {
2548 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (command2.stringcxx . . $ MelderString#string. + 4);
2549 if (startOfInk && *startOfInk != U';')
2550 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'else'.");
2551 int depth = 0;
2552 integercxx . . $ integer# iline;
2553 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1; iline <= numberOfLines; iline ++) {
2554 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endif", 5) &&
2555 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5] == U';'))
2556 {
2557 startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 5);
2558 if (startOfInk && *startOfInk != U';') {
2559 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of the error message
2560 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endif'.");
2561 }
2562 if (depth == 0) { mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; break; } // go after `endif`
2563 else depth --;
2564 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"if ", 3)) {
2565 depth ++;
2566 }
2567 }
2568 if (iline > numberOfLines)
2569 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'else'.");
2570 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"elsif ", 6) || str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"elif ", 5)) {
2571 if (mycxx . . $ `melder/melder.h:44:9`! fromifcxx . . $ structInterpreter#fromif.) {
2572 double value;
2573 mycxx . . $ `melder/melder.h:44:9`! fromifcxx . . $ structInterpreter#fromif. = false;
2574 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, command2.stringcxx . . $ MelderString#string. + 5, & value);
2575 if (value == 0.0) {
2576 int depth = 0;
2577 integercxx . . $ integer# iline;
2578 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1; iline <= numberOfLines; iline ++) {
2579 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endif", 5) &&
2580 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5] == U';'))
2581 {
2582 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 5);
2583 if (startOfInk && *startOfInk != U';') {
2584 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2585 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endif'.");
2586 }
2587 if (depth == 0) {
2588 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2589 break; // go after `endif`
2590 } else
2591 depth --;
2592 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"else", 4) &&
2593 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [4]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [4] == U';'))
2594 {
2595 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 4);
2596 if (startOfInk && *startOfInk != U';') {
2597 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2598 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'else'.");
2599 }
2600 if (depth == 0) {
2601 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2602 break; // go after `else`
2603 }
2604 } else if ((str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"elsif", 5) && ! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5]))
2605 || (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"elif", 4) && ! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [4]))) {
2606 if (depth == 0) {
2607 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline - 1;
2608 mycxx . . $ `melder/melder.h:44:9`! fromifcxx . . $ structInterpreter#fromif. = true;
2609 break; // go at next 'elsif' or 'elif'
2610 }
2611 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"if ", 3)) {
2612 depth ++;
2613 }
2614 }
2615 if (iline > numberOfLines)
2616 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'elsif'.");
2617 }
2618 } else {
2619 int depth = 0;
2620 integercxx . . $ integer# iline;
2621 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1; iline <= numberOfLines; iline ++) {
2622 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endif", 5) &&
2623 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5] == U';'))
2624 {
2625 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 5);
2626 if (startOfInk && *startOfInk != U';') {
2627 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2628 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endif'.");
2629 }
2630 if (depth == 0) {
2631 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2632 break; // go after `endif`
2633 } else
2634 depth --;
2635 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"if ", 3)) {
2636 depth ++;
2637 }
2638 }
2639 if (iline > numberOfLines)
2640 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"'elsif' not matched with 'endif'.");
2641 }
2642 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"exit", 4)) {
2643 if (command2.stringcxx . . $ MelderString#string. [4] == U'\0') {
2644 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = numberOfLines; // go after end
2645 } else if (command2.stringcxx . . $ MelderString#string. [4] == U' ') {
2646 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (command2.string + 5);
2647 } else
2648 fail = true;
2649 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"echo ", 5)) {
2650 /*
2651 Make sure that lines like "echo = 3" will not be regarded as assignments.
2652 */
2653 (void) praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, command2.stringcxx . . $ MelderString#string.);
2654 } else
2655 fail = true;
2656 break;
2657 case U'f':
2658 if (command2.stringcxx . . $ MelderString#string. [1] == U'o' && command2.stringcxx . . $ MelderString#string. [2] == U'r' && command2.stringcxx . . $ MelderString#string. [3] == U' ') { // for_
2659 double toValue, loopVariable;
2660 char32cxx . . $ char32# *frompos = str32strcxx . . $ str32str(2de17cd8f7c584a6). (command2.stringcxx . . $ MelderString#string., U" from "), *topos = str32strcxx . . $ str32str(2de17cd8f7c584a6). (command2.stringcxx . . $ MelderString#string., U" to ");
2661 char32cxx . . $ char32# *varpos = command2.stringcxx . . $ MelderString#string. + 4, *endvar = frompos;
2662 if (! topos)
2663 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing \'to\' in \'for\' loop.");
2664 if (! endvar)
2665 endvar = topos;
2666 while (*endvar == U' ') {
2667 *endvar = U'\0';
2668 endvar --;
2669 }
2670 while (*varpos == U' ')
2671 varpos ++;
2672 if (endvar - varpos < 0)
2673 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing loop variable after \'for\'.");
2674 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, varpos);
2675 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, topos + 4, & toValue);
2676 if (mycxx . . $ `melder/melder.h:44:9`! fromendforcxx . . $ structInterpreter#fromendfor.) {
2677 mycxx . . $ `melder/melder.h:44:9`! fromendforcxx . . $ structInterpreter#fromendfor. = false;
2678 loopVariable = var -> numericValuecxx . . $ structInterpreterVariable#numericValue. + 1.0;
2679 } else if (frompos) {
2680 *topos = U'\0';
2681 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, frompos + 6, & loopVariable);
2682 } else {
2683 loopVariable = 1.0;
2684 }
2685 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. = loopVariable;
2686 if (loopVariable > toValue) {
2687 int depth = 0;
2688 integercxx . . $ integer# iline;
2689 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1; iline <= numberOfLines; iline ++) {
2690 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endfor", 6) &&
2691 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [6]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [6] == U';'))
2692 {
2693 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 6);
2694 if (startOfInk && *startOfInk != U';') {
2695 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2696 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endfor'.");
2697 }
2698 if (depth == 0) {
2699 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2700 break; // go after 'endfor'
2701 } else
2702 depth --;
2703 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"for ", 4)) {
2704 depth ++;
2705 }
2706 }
2707 if (iline > numberOfLines)
2708 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'for' (matching 'endfor' not found).");
2709 }
2710 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"form", 4) &&
2711 (command2.stringcxx . . $ MelderString#string. [4] == U':' || Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [4])))
2712 {
2713 /*
2714 We encountered a `form` statement.
2715 The contents of everything between `form` and `endform`
2716 is irrelevant at this point (the parameters have been read earlier),
2717 so we will skip the whole contents of the form and jump past `endform`.
2718 */
2719 integercxx . . $ integer# iline;
2720 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1; iline <= numberOfLines; iline ++)
2721 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endform", 7) && Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [7])) {
2722 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2723 break; // go after 'endform'
2724 }
2725 if (iline > numberOfLines)
2726 /*
2727 We will probably never arrive here, because a missing `endform`
2728 will probably have been detected by Interpreter_readParameters(),
2729 either with "Unknown parameter type inside form:\nxxx"
2730 or with "Unfinished form (missing “endform”)."
2731 but we like to stay on the safe side. (last checked 2023-01-20)
2732 */
2733 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'form' (matching 'endform' not found).");
2734 } else
2735 fail = true;
2736 break;
2737 case U'g':
2738 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"goto ", 5)) {
2739 char32cxx . . $ char32# labelName [1+Interpreter_MAX_LABEL_LENGTHcxx . . $ `sys/Interpreter.h:39:9`!];
2740 str32ncpycxx . . $ str32ncpy(a0fb29e7f5bbd1dc). (labelName, command2.stringcxx . . $ MelderString#string. + 5, Interpreter_MAX_LABEL_LENGTHcxx . . $ `sys/Interpreter.h:39:9`!);
2741 labelName [Interpreter_MAX_LABEL_LENGTHcxx . . $ `sys/Interpreter.h:39:9`!] = U'\0';
2742 char32cxx . . $ char32# *space = str32chrcxx . . $ str32chr(328a9ede0fba853a). (labelName, U' ');
2743 if (space == labelName)
2744 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing label name after 'goto'.");
2745 bool dojump = true;
2746 if (space) {
2747 double value;
2748 *space = '\0';
2749 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, command2.stringcxx . . $ MelderString#string. + 6 + Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (labelName), & value);
2750 if (value == 0.0)
2751 dojump = false;
2752 }
2753 if (dojump) {
2754 integercxx . . $ integer# ilabel = lookupLabelcxx . . $ lookupLabel(df2c8148a0293fef). (me, labelName);
2755 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = mycxx . . $ `melder/melder.h:44:9`! labelLinescxx . . $ structInterpreter#labelLines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ilabel]; // loop will add 1
2756 }
2757 } else
2758 fail = true;
2759 break;
2760 case U'h':
2761 fail = true;
2762 break;
2763 case U'i':
2764 if (command2.stringcxx . . $ MelderString#string. [1] == U'f' && Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [2])) { // if_
2765 double value;
2766 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, command2.stringcxx . . $ MelderString#string. + 3, & value);
2767 if (value == 0.0) {
2768 int depth = 0;
2769 integercxx . . $ integer# iline;
2770 for (iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1; iline <= numberOfLines; iline ++) {
2771 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endif", 5) &&
2772 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [5] == U';'))
2773 {
2774 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 5);
2775 if (startOfInk && *startOfInk != U';') {
2776 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2777 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endif'.");
2778 }
2779 if (depth == 0) {
2780 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2781 break; // go after 'endif'
2782 } else
2783 depth --;
2784 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"else", 4) &&
2785 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [4]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [4] == U';'))
2786 {
2787 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 4);
2788 if (startOfInk && *startOfInk != U';') {
2789 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2790 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'else'.");
2791 }
2792 if (depth == 0) {
2793 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2794 break; // go after 'else'
2795 }
2796 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"elsif ", 6) || str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"elif ", 5)) {
2797 if (depth == 0) {
2798 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline - 1;
2799 mycxx . . $ `melder/melder.h:44:9`! fromifcxx . . $ structInterpreter#fromif. = true;
2800 break; // go at 'elsif'
2801 }
2802 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"if ", 3)) {
2803 depth ++;
2804 }
2805 }
2806 if (iline > numberOfLines)
2807 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'if'.");
2808 } else if (isundefcxx . . $ isundef(f8197d536af80c96). (value)) {
2809 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The value of the 'if' condition is undefined.");
2810 }
2811 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"inc ", 4)) {
2812 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, command2.stringcxx . . $ MelderString#string. + 4);
2813 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. += 1.0;
2814 } else
2815 fail = true;
2816 break;
2817 case U'j':
2818 fail = true;
2819 break;
2820 case U'k':
2821 fail = true;
2822 break;
2823 case U'l':
2824 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"label ", 6)) {
2825 if (command2.stringcxx . . $ MelderString#string. [6] == U'=')
2826 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"\"label\" cannot be used as a variable name.");
2827 ; // ignore labels
2828 } else
2829 fail = true;
2830 break;
2831 case U'm':
2832 fail = true;
2833 break;
2834 case U'n':
2835 fail = true;
2836 break;
2837 case U'o':
2838 fail = true;
2839 break;
2840 case U'p':
2841 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"procedure", 9) && Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [9])) {
2842 integercxx . . $ integer# iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1;
2843 for (; iline <= numberOfLines; iline ++) {
2844 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endproc", 7) &&
2845 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [7]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [7] == U';'))
2846 {
2847 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 7);
2848 if (startOfInk && *startOfInk != U';') {
2849 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline; // on behalf of error message
2850 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endproc'.");
2851 }
2852 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2853 break;
2854 } // go after `endproc`
2855 }
2856 if (iline > numberOfLines) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'procedure'.");
2857 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"print", 5)) {
2858 /*
2859 * Make sure that lines like "print = 3" will not be regarded as assignments.
2860 */
2861 if (command2.stringcxx . . $ MelderString#string. [5] == U' ' || (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string. + 5, U"line", 4) && (command2.stringcxx . . $ MelderString#string. [9] == U' ' || command2.stringcxx . . $ MelderString#string. [9] == U'\0'))) {
2862 (void) praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, command2.stringcxx . . $ MelderString#string.);
2863 } else
2864 fail = true;
2865 } else
2866 fail = true;
2867 break;
2868 case U'q':
2869 fail = true;
2870 break;
2871 case U'r':
2872 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"repeat", 6) &&
2873 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [6]) || command2.stringcxx . . $ MelderString#string. [6] == U';'))
2874 {
2875 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (command2.stringcxx . . $ MelderString#string. + 6);
2876 if (startOfInk && *startOfInk != U';')
2877 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'repeat'.");
2878 /* Ignore. */
2879 } else
2880 fail = true;
2881 break;
2882 case U's':
2883 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"stopwatch", 9) && ! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (command2.stringcxx . . $ MelderString#string. [9])) {
2884 (void) Melder_stopwatchcxx . . $ Melder_stopwatch(31fa7155c10fdd13). (); // reset stopwatch
2885 } else
2886 fail = true;
2887 break;
2888 case U't':
2889 fail = true;
2890 break;
2891 case U'u':
2892 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"until ", 6)) {
2893 double value;
2894 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, command2.stringcxx . . $ MelderString#string. + 6, & value);
2895 if (value == 0.0) {
2896 int depth = 0;
2897 integercxx . . $ integer# iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. - 1;
2898 for (; iline > 0; iline --) {
2899 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"repeat", 6) &&
2900 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [6]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [6] == U';'))
2901 {
2902 if (depth == 0) {
2903 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2904 break; // go after `repeat`
2905 } else
2906 depth --;
2907 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"until ", 6)) {
2908 depth ++;
2909 }
2910 }
2911 if (iline <= 0)
2912 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'until'.");
2913 }
2914 } else
2915 fail = true;
2916 break;
2917 case U'v':
2918 fail = true;
2919 break;
2920 case U'w':
2921 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (command2.stringcxx . . $ MelderString#string., U"while ", 6)) {
2922 double value;
2923 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, command2.stringcxx . . $ MelderString#string. + 6, & value);
2924 if (value == 0.0) {
2925 int depth = 0;
2926 integercxx . . $ integer# iline = mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. + 1;
2927 for (; iline <= numberOfLines; iline ++) {
2928 if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"endwhile", 8) &&
2929 (! Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [8]) || lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] [8] == U';'))
2930 {
2931 const char32cxx . . $ char32# *startOfInk = Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline] + 8);
2932 if (startOfInk && *startOfInk != U';') {
2933 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2934 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Stray text after 'endwhile'.");
2935 }
2936 if (depth == 0) {
2937 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. = iline;
2938 break; // go after `endwhile`
2939 } else
2940 depth --;
2941 } else if (str32nequcxx . . $ `melder/melder_str32.h:123:9`! (lines [cxx . . $ constvector#`operator[]`(e616e229aa94bfcf).iline], U"while ", 6)) {
2942 depth ++;
2943 }
2944 }
2945 if (iline > numberOfLines)
2946 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Unmatched 'while'.");
2947 }
2948 } else
2949 fail = true;
2950 break;
2951 case U'x':
2952 fail = true;
2953 break;
2954 case U'y':
2955 fail = true;
2956 break;
2957 case U'z':
2958 fail = true;
2959 break;
2960 default:
2961 fail = true;
2962 break;
2963 }
2964 if (fail) {
2965 /*
2966 Found an unknown word starting with a nonupper-case letter, optionally preceded by a period.
2967 See whether the word is a variable name.
2968 */
2969 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"found an unknown word starting with a nonupper-case letter, optionally preceded by a period");
2970 char32cxx . . $ char32# *p = & command2.stringcxx . . $ MelderString#string. [0];
2971 /*
2972 Variable names consist of a sequence of letters, digits, and underscores,
2973 optionally preceded by a period and optionally followed by a $ and/or #.
2974 */
2975 if (*p == U'.')
2976 p ++;
2977 while (Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (*p) || *p == U'.')
2978 p ++;
2979 if (*p == U'$') {
2980 if (p [1] == U'#') {
2981 /*
2982 Assign to a string array variable or a string array element.
2983 */
2984 static MelderStringcxx . . $ MelderString# arrayName;
2985 p ++;
2986 *p = U'\0'; // erase the number sign temporarily
2987 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& arrayName, command2.stringcxx . . $ MelderString#string., U"#");
2988 *p = U'#'; // put the number sign back
2989 p ++; // step over number sign
2990 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after array name
2991 if (*p == U'=') {
2992 /*
2993 This must be an assignment to a string array variable.
2994 */
2995 p ++; // step over equals sign
2996 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
2997 if (*p == U'\0')
2998 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing right-hand expression in assignment to string array ", arrayName.string, U".");
2999 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
3000 /*
3001 Statement like: lines$# = Get all strings
3002 */
3003 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
3004 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, arrayName.stringcxx . . $ MelderString#string.);
3005 if (! status)
3006 var -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue. =cxx . . $ _autostringautovector#`operator=`(150f7ba7aac25b7e). autoSTRVECcxx . . $ _autostringautovector#_autostringautovector(49f6e7a06ebc5aa8).(); // anything can have happened, including an incorrect returnType
3007 else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::STRINGARRAY_cxx . . $ kInterpreter_ReturnType#STRINGARRAY_.)
3008 var -> stringArrayValuecxx . . $ structInterpreterVariable#stringArrayValue. =cxx . . $ _autostringautovector#`operator=`(150f7ba7aac25b7e). mycxx . . $ `melder/melder.h:44:9`! returnedStringArraycxx . . $ structInterpreter#returnedStringArray..movecxx . . $ _autostringautovector#move(5fcb5f1929a10d2a).();
3009 else
3010 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (kInterpreter_ReturnType_errorMessage (mycxx . . $ `melder/melder.h:44:9`! returnType, p),
3011 U"; not assigned to the string array variable \"", arrayName.string, U"\".");
3012 } else {
3013 /*
3014 Statement like: files$# = fileNames$# ("*.wav")
3015 */
3016 STRVECcxx . . $ STRVEC# valuecxx . . $ _stringvector#_stringvector(49f6e7a06ebc5aa8).;
3017 bool owned;
3018 Interpreter_stringArrayExpressioncxx . . $ Interpreter_stringArrayExpression(4cd1c45f7f524604). (me, p, & value, & owned);
3019 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, arrayName.stringcxx . . $ MelderString#string.);
3020 StringArrayVariable_movecxx . . $ StringArrayVariable_move(ea00a05ae1b01cb2). (var, value, owned);
3021 }
3022 } else if (*p == U'[') {
3023 assignToStringArrayElementcxx . . $ assignToStringArrayElement(61d4635e44240b16). (me, ++ p, arrayName.stringcxx . . $ MelderString#string., valueString);
3024 } else Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing '=' or '[' after string array variable ", arrayName.string, U".");
3025 } else {
3026 /*
3027 Assign to a string variable.
3028 */
3029 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"detected an assignment to a string variable");
3030 char32cxx . . $ char32# *endOfVariable = ++ p;
3031 char32cxx . . $ char32# *variableName = command2.stringcxx . . $ MelderString#string.;
3032 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after variable name
3033 if (*p == U'[') {
3034 /*
3035 This must be an assignment to an indexed string variable.
3036 */
3037 *endOfVariable = U'\0';
3038 static MelderStringcxx . . $ MelderString# indexedVariableName;
3039 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& indexedVariableName, command2.stringcxx . . $ MelderString#string., U"[");
3040 for (;;) {
3041 p ++; // skip opening bracket or comma
3042 static MelderStringcxx . . $ MelderString# index;
3043 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& index);
3044 int depth = 0;
3045 bool inString = false;
3046 while ((depth > 0 || (*p != U',' && *p != U']') || inString) && Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) {
3047 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& index, *p);
3048 if (*p == U'[') {
3049 if (! inString)
3050 depth ++;
3051 } else if (*p == U']') {
3052 if (! inString)
3053 depth --;
3054 }
3055 if (*p == U'"')
3056 inString = ! inString;
3057 p ++;
3058 }
3059 if (! Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p))
3060 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing bracket (]) in indexed variable.");
3061 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3062 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, index.stringcxx . . $ MelderString#string., & result);
3063 if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3064 const double numericIndexValue = result. numericResultcxx . . $ Formula_Result#numericResult.;
3065 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& indexedVariableName, numericIndexValue);
3066 } else if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_STRINGcxx . . $ `sys/Formula.h:25:9`!) {
3067 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& indexedVariableName, U"\"", result. stringResultcxx . . $ Formula_Result#stringResult..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"\"");
3068 }
3069 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& indexedVariableName, *p);
3070 if (*p == U']') {
3071 break;
3072 }
3073 }
3074 variableName = indexedVariableName.stringcxx . . $ MelderString#string.;
3075 p ++; // skip closing bracket
3076 }
3077 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after (perhaps indexed) variable name
3078 int typeOfAssignment; // 0, 1, 2, 3 or 4
3079 if (*p == U'=') {
3080 typeOfAssignment = 0; // assignment
3081 } else if (*p == U'+') {
3082 if (p [1] == U'=') {
3083 typeOfAssignment = 1; // adding assignment
3084 p ++;
3085 } else {
3086 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing “=” after string variable ", variableName, U" followed by “+”.");
3087 }
3088 } else if (*p == U'<') {
3089 typeOfAssignment = 2; // read from file
3090 } else if (*p == U'>') {
3091 if (p [1] == U'>') {
3092 typeOfAssignment = 3; // append to file
3093 p ++;
3094 } else {
3095 typeOfAssignment = 4; // save to file
3096 }
3097 } else Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing “=”, “+=”, “<”, or “>” after string variable ", variableName, U".");
3098 *endOfVariable = U'\0';
3099 p ++;
3100 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment or I/O symbol
3101 if (*p == U'\0') {
3102 if (typeOfAssignment >= 2)
3103 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing file name after variable ", variableName, U".");
3104 else
3105 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing expression after variable ", variableName, U".");
3106 }
3107 if (typeOfAssignment >= 2) {
3108 structMelderFilecxx . . $ structMelderFile# file { };
3109 Melder_relativePathToFilecxx . . $ Melder_relativePathToFile(82691f2ee21fbb13). (p, & file);
3110 if (typeOfAssignment == 2) {
3111 autostring32cxx . . $ autostring32# stringValue = MelderFile_readTextcxx . . $ MelderFile_readText(2312d39ae70aea26). (& file);
3112 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, variableName);
3113 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). stringValue.movecxx . . $ _autostring#move(bd43c759570f178f).();
3114 } else if (typeOfAssignment == 3) {
3115 if (theCurrentPraatObjectscxx . . $ theCurrentPraatObjects. != & theForegroundPraatObjectscxx . . $ theForegroundPraatObjects.) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Commands that write to a file are not available inside pictures.");
3116 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, variableName);
3117 if (! var)
3118 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Variable ", variableName, U" undefined.");
3119 MelderFile_appendText_ecxx . . $ MelderFile_appendText_e(8fa576db0692df65). (& file, var -> stringValuecxx . . $ structInterpreterVariable#stringValue..getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
3120 } else {
3121 if (theCurrentPraatObjectscxx . . $ theCurrentPraatObjects. != & theForegroundPraatObjectscxx . . $ theForegroundPraatObjects.) Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Commands that write to a file are not available inside pictures.");
3122 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, variableName);
3123 if (! var)
3124 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Variable ", variableName, U" undefined.");
3125 MelderFile_writeText_ecxx . . $ MelderFile_writeText_e(4f26204211a3b413). (& file, var -> stringValuecxx . . $ structInterpreterVariable#stringValue..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), Melder_getOutputEncodingcxx . . $ Melder_getOutputEncoding(581d0d572cba43d7). ());
3126 }
3127 } else if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
3128 /*
3129 Statement like: name$ = Get name
3130 */
3131 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& valueString); // empty because command may print nothing; also makes sure that valueString.string exists
3132 autoMelderDivertInfocxx . . $ autoMelderDivertInfo# divertcxx . . $ autoMelderDivertInfo#autoMelderDivertInfo(93db1090f27e5462). (& valueString);
3133 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
3134 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, variableName);
3135 if (! status)
3136 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (U""); // anything can have happened, including an incorrect returnType
3137 else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::STRING_cxx . . $ kInterpreter_ReturnType#STRING_. ||
3138 mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REAL_cxx . . $ kInterpreter_ReturnType#REAL_. ||
3139 mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::INTEGER_cxx . . $ kInterpreter_ReturnType#INTEGER_.
3140 )
3141 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). Melder_dupcxx . . $ Melder_dup(87bf156b1f548402). (valueString.stringcxx . . $ MelderString#string.);
3142 else
3143 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (kInterpreter_ReturnType_errorMessage (mycxx . . $ `melder/melder.h:44:9`! returnType, p),
3144 U"; not assigned to the string variable \"", variableName, U"\".");
3145 } else {
3146 /*
3147 Evaluate a string expression and assign the result to the variable.
3148 Statements like:
3149 sentence$ = subject$ + verb$ + object$
3150 extension$ = if index (file$, ".") <> 0
3151 ... then right$ (file$, length (file$) - rindex (file$, "."))
3152 ... else "" fi
3153 */
3154 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"evaluating string expression");
3155 autostring32cxx . . $ autostring32# stringValue = Interpreter_stringExpressioncxx . . $ Interpreter_stringExpression(ae2ff4958c59280d). (me, p);
3156 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"assigning to string variable ", variableName);
3157 if (typeOfAssignment == 1) {
3158 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, variableName);
3159 if (! var)
3160 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The string ", variableName, U" does not exist.\n"
3161 U"You can increment (+=) only existing strings.");
3162 const integercxx . . $ integer# oldLength = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (var -> stringValuecxx . . $ structInterpreterVariable#stringValue..getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
3163 const integercxx . . $ integer# extraLength = Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (stringValue.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
3164 autostring32cxx . . $ autostring32# newStringcxx . . $ _autostring#_autostring(f153f132b2bc41c2). (oldLength + extraLength, false);
3165 str32cpycxx . . $ str32cpy(6ab934322573b179). (newString.getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), var -> stringValuecxx . . $ structInterpreterVariable#stringValue..getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
3166 str32cpycxx . . $ str32cpy(6ab934322573b179). (newString.getcxx . . $ _autostring#get(5a2a78a048fb49a8).() + oldLength, stringValue.getcxx . . $ _autostring#get(5a2a78a048fb49a8).());
3167 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). newString.movecxx . . $ _autostring#move(bd43c759570f178f).();
3168 } else {
3169 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, variableName);
3170 var -> stringValuecxx . . $ structInterpreterVariable#stringValue. =cxx . . $ _autostring#`operator=`(f562943cbc4bcf37). stringValue.movecxx . . $ _autostring#move(bd43c759570f178f).();
3171 }
3172 }
3173 }
3174 } else if (*p == U'#') {
3175 if (p [1] == U'#') {
3176 /*
3177 Assign to a numeric matrix variable or to a matrix element.
3178 */
3179 static MelderStringcxx . . $ MelderString# matrixName;
3180 p ++; // go to second '#'
3181 *p = U'\0'; // erase the last number sign temporarily
3182 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& matrixName, command2.stringcxx . . $ MelderString#string., U'#');
3183 *p = U'#'; // put the number sign back
3184 p ++; // step over last number sign
3185 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after matrix name
3186 if (*p == U'=') {
3187 /*
3188 This must be an assignment to a matrix variable.
3189 */
3190 p ++; // step over equals sign
3191 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
3192 if (*p == U'\0')
3193 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing right-hand expression in assignment to matrix ", matrixName.string, U".");
3194 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
3195 /*
3196 Statement like: values## = Get all values
3197 */
3198 const bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
3199 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3200 if (! status)
3201 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). autoMATcxx . . $ automatrix#automatrix(49f6e7a06ebc5aa8).(); // anything can have happened, including an incorrect returnType
3202 else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REALMATRIX_cxx . . $ kInterpreter_ReturnType#REALMATRIX_.)
3203 var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue. =cxx . . $ automatrix#`operator=`(a0f46581f260c488). mycxx . . $ `melder/melder.h:44:9`! returnedRealMatrixcxx . . $ structInterpreter#returnedRealMatrix..movecxx . . $ automatrix#move(8771494f681de611).();
3204 else
3205 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (kInterpreter_ReturnType_errorMessage (mycxx . . $ `melder/melder.h:44:9`! returnType, p),
3206 U"; not assigned to the matrix variable \"", matrixName.string, U"\".");
3207 } else {
3208 MATcxx . . $ MAT# valuecxx . . $ matrix#matrix(49f6e7a06ebc5aa8).;
3209 bool owned;
3210 Interpreter_numericMatrixExpressioncxx . . $ Interpreter_numericMatrixExpression(dd630cc19a2beb06). (me, p, & value, & owned);
3211 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3212 NumericMatrixVariable_movecxx . . $ NumericMatrixVariable_move(fa2438427dd6cfa6). (var, value, owned);
3213 }
3214 } else if (*p == U'[') {
3215 assignToNumericMatrixElementcxx . . $ assignToNumericMatrixElement(61d4635e44240b16). (me, ++ p, matrixName.stringcxx . . $ MelderString#string., valueString);
3216 } else if (*p == U'+' && p [1] == U'=') {
3217 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3218 if (! var)
3219 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The matrix ", matrixName.string, U" does not exist.\n"
3220 U"You can increment (+=) only existing matrices.");
3221 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3222 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3223 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_MATRIXcxx . . $ `sys/Formula.h:27:9`!) {
3224 NumericMatrixVariable_addcxx . . $ NumericMatrixVariable_add(f44b454bc6f9f32d). (var, resultcxx . . $ constmatrix#constmatrix(eed9513d24570b3d).. numericMatrixResultcxx . . $ Formula_Result#numericMatrixResult.);
3225 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3226 NumericMatrixVariable_addcxx . . $ NumericMatrixVariable_add(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3227 } else {
3228 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can increment (+=) a numeric matrix only with a number or another numeric matrix.");
3229 }
3230 } else if (*p == U'-' && p [1] == U'=') {
3231 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3232 if (! var)
3233 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The matrix ", matrixName.string, U" does not exist.\n"
3234 U"You can decrement (-=) only existing matrices.");
3235 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3236 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3237 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_MATRIXcxx . . $ `sys/Formula.h:27:9`!) {
3238 NumericMatrixVariable_subtractcxx . . $ NumericMatrixVariable_subtract(f44b454bc6f9f32d). (var, resultcxx . . $ constmatrix#constmatrix(eed9513d24570b3d).. numericMatrixResultcxx . . $ Formula_Result#numericMatrixResult.);
3239 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3240 NumericMatrixVariable_subtractcxx . . $ NumericMatrixVariable_subtract(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3241 } else {
3242 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can decrement (-=) a numeric matrix only with a number or another numeric matrix.");
3243 }
3244 } else if (*p == U'*' && p [1] == U'=') {
3245 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3246 if (! var)
3247 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The matrix ", matrixName.string, U" does not exist.\n"
3248 U"You can multiply (*=) only existing matrices.");
3249 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3250 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3251 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_MATRIXcxx . . $ `sys/Formula.h:27:9`!) {
3252 NumericMatrixVariable_multiplycxx . . $ NumericMatrixVariable_multiply(f44b454bc6f9f32d). (var, resultcxx . . $ constmatrix#constmatrix(eed9513d24570b3d).. numericMatrixResultcxx . . $ Formula_Result#numericMatrixResult.);
3253 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3254 NumericMatrixVariable_multiplycxx . . $ NumericMatrixVariable_multiply(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3255 } else {
3256 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can multiply (*=) a numeric matrix only with a number or another numeric matrix.");
3257 }
3258 } else if (*p == U'/' && p [1] == U'=') {
3259 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3260 if (! var)
3261 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The matrix ", matrixName.string, U" does not exist.\n"
3262 U"You can divide (/=) only existing matrices.");
3263 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3264 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3265 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_MATRIXcxx . . $ `sys/Formula.h:27:9`!) {
3266 NumericMatrixVariable_dividecxx . . $ NumericMatrixVariable_divide(f44b454bc6f9f32d). (var, resultcxx . . $ constmatrix#constmatrix(eed9513d24570b3d).. numericMatrixResultcxx . . $ Formula_Result#numericMatrixResult.);
3267 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3268 NumericMatrixVariable_dividecxx . . $ NumericMatrixVariable_divide(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3269 } else {
3270 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can divide (/=) a numeric matrix only with a number or another numeric matrix.");
3271 }
3272 } else if (*p == U'~') {
3273 /*
3274 This must be a formula assignment to a matrix variable.
3275 */
3276 p ++; // step over tilde
3277 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
3278 if (*p == U'\0')
3279 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing formula expression for matrix ", matrixName.string, U".");
3280 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, matrixName.stringcxx . . $ MelderString#string.);
3281 if (! var)
3282 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The matrix ", matrixName.string, U" does not exist.\n"
3283 "You can assign a formula only to an existing matrix.");
3284 static Matrixcxx . . $ Matrix# matrixObject;
3285 if (! matrixObject)
3286 matrixObject = Matrix_createSimplecxx . . $ Matrix_createSimple(1d1e893fc69cdb2f). (1, 1). releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(); // prevent exit-time destruction
3287 MATcxx . . $ MAT# mat = var -> numericMatrixValuecxx . . $ structInterpreterVariable#numericMatrixValue..getcxx . . $ automatrix#get(b2b81450b5bdda66).();
3288 matrixObject -> xmaxcxx . . $ structFunction#xmax. = mat.ncolcxx . . $ matrix#ncol. + 0.5;
3289 matrixObject -> nxcxx . . $ structSampled#nx. = mat.ncolcxx . . $ matrix#ncol.;
3290 matrixObject -> ymaxcxx . . $ structSampledXY#ymax. = mat.nrowcxx . . $ matrix#nrow. + 0.5;
3291 matrixObject -> nycxx . . $ structSampledXY#ny. = mat.nrowcxx . . $ matrix#nrow.;
3292 matrixObject -> zcxx . . $ structMatrix#z..cellscxx . . $ automatrix#cells. = mat.cellscxx . . $ matrix#cells.; // just a reference (YUCK)
3293 matrixObject -> zcxx . . $ structMatrix#z..nrowcxx . . $ automatrix#nrow. = mat.nrowcxx . . $ matrix#nrow.;
3294 matrixObject -> zcxx . . $ structMatrix#z..ncolcxx . . $ automatrix#ncol. = mat.ncolcxx . . $ matrix#ncol.;
3295 Matrix_formulacxx . . $ Matrix_formula(3b405620ba9cc26e). (matrixObject, p, me, nullptr);
3296 } else Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing '=' after matrix variable ", matrixName.string, U".");
3297 } else {
3298 /*
3299 Assign to a numeric vector variable or to a vector element.
3300 */
3301 static MelderStringcxx . . $ MelderString# vectorName;
3302 *p = U'\0'; // erase the number sign temporarily
3303 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& vectorName, command2.stringcxx . . $ MelderString#string., U"#");
3304 *p = U'#'; // put the number sign back
3305 p ++; // step over number sign
3306 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after array name
3307 if (*p == U'=') {
3308 /*
3309 This must be an assignment to a vector variable.
3310 First compute the value of the expression,
3311 *then* look up (perhaps create) the vector variable (the order is important)
3312 then assign the value to that vector variable.
3313 Reversing the order of the first and second step would fail the following test:
3314 */
3315 /*@praat
3316 asserterror Unknown variable:'newline$'« interpreter_assignToVector#
3317 interpreter_assignToVector# = interpreter_assignToVector# + 5
3318 @*/
3319 p ++; // step over equals sign
3320 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
3321 if (*p == U'\0')
3322 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing right-hand expression in assignment to vector ", vectorName.string, U".");
3323 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
3324 /*
3325 Statement like: times# = Get all times
3326 */
3327 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
3328 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.);
3329 if (! status)
3330 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). autoVECcxx . . $ autovector#autovector(49f6e7a06ebc5aa8).(); // anything can have happened, including an incorrect returnType
3331 else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::OBJECT_cxx . . $ kInterpreter_ReturnType#OBJECT_.) {
3332 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). autoVECcxx . . $ autovector#autovector(49f6e7a06ebc5aa8).();
3333 integercxx . . $ integer# IOBJECT;
3334 WHEREcxx . . $ `sys/praat.h:198:9`! (SELECTEDcxx . . $ `sys/praat.h:200:9`!)
3335 *var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue.. appendcxx . . $ autovector#append(155dc7f103cdb9db).() = IDcxx . . $ `sys/praat.h:206:9`!;
3336 } else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REALVECTOR_cxx . . $ kInterpreter_ReturnType#REALVECTOR_.)
3337 var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue. =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). mycxx . . $ `melder/melder.h:44:9`! returnedRealVectorcxx . . $ structInterpreter#returnedRealVector..movecxx . . $ autovector#move(57d90d7d77dfc011).();
3338 else
3339 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (kInterpreter_ReturnType_errorMessage (mycxx . . $ `melder/melder.h:44:9`! returnType, p), U"; not assigned to the vector variable \"", vectorName.string, U"\".");
3340 } else {
3341 VECcxx . . $ VEC# valuecxx . . $ vector#vector(49f6e7a06ebc5aa8).;
3342 bool owned;
3343 Interpreter_numericVectorExpressioncxx . . $ Interpreter_numericVectorExpression(e47164ae4c0553fe). (me, p, & value, & owned);
3344 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.); // not earlier, because it could have appeared in the expression
3345 NumericVectorVariable_movecxx . . $ NumericVectorVariable_move(edf649b628674408). (var, value, owned);
3346 }
3347 } else if (*p == U'[') {
3348 assignToNumericVectorElementcxx . . $ assignToNumericVectorElement(61d4635e44240b16). (me, ++ p, vectorName.stringcxx . . $ MelderString#string., valueString);
3349 } else if (*p == U'+' && p [1] == U'=') {
3350 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.);
3351 if (! var)
3352 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The vector ", vectorName.string, U" does not exist.\n"
3353 U"You can increment (+=) only existing vectors.");
3354 /*@praat
3355 asserterror The vector interpreter_assignToVector# does not exist.
3356 interpreter_assignToVector# += 5
3357 @*/
3358 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3359 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3360 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_VECTORcxx . . $ `sys/Formula.h:26:9`!) {
3361 NumericVectorVariable_addcxx . . $ NumericVectorVariable_add(ea30aa56812f98b8). (var, resultcxx . . $ constvector#constvector(eac9d6ec4c4bfecd).. numericVectorResultcxx . . $ Formula_Result#numericVectorResult.);
3362 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3363 NumericVectorVariable_addcxx . . $ NumericVectorVariable_add(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3364 } else {
3365 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can increment (+=) a numeric vector only with a number or another numeric vector.");
3366 }
3367 } else if (*p == U'-' && p [1] == U'=') {
3368 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.);
3369 if (! var)
3370 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The vector ", vectorName.string, U" does not exist.\n"
3371 U"You can decrement (-=) only existing vectors.");
3372 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3373 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3374 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_VECTORcxx . . $ `sys/Formula.h:26:9`!) {
3375 NumericVectorVariable_subtractcxx . . $ NumericVectorVariable_subtract(ea30aa56812f98b8). (var, resultcxx . . $ constvector#constvector(eac9d6ec4c4bfecd).. numericVectorResultcxx . . $ Formula_Result#numericVectorResult.);
3376 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3377 NumericVectorVariable_subtractcxx . . $ NumericVectorVariable_subtract(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3378 } else {
3379 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can decrement (-=) a numeric vector only with a number or another numeric vector.");
3380 }
3381 } else if (*p == U'*' && p [1] == U'=') {
3382 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.);
3383 if (! var)
3384 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The vector ", vectorName.string, U" does not exist.\n"
3385 U"You can multiply (*=) only existing vectors.");
3386 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3387 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3388 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_VECTORcxx . . $ `sys/Formula.h:26:9`!) {
3389 NumericVectorVariable_multiplycxx . . $ NumericVectorVariable_multiply(ea30aa56812f98b8). (var, resultcxx . . $ constvector#constvector(eac9d6ec4c4bfecd).. numericVectorResultcxx . . $ Formula_Result#numericVectorResult.);
3390 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3391 NumericVectorVariable_multiplycxx . . $ NumericVectorVariable_multiply(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3392 } else {
3393 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can multiply (*=) a numeric vector only with a number or another numeric vector.");
3394 }
3395 } else if (*p == U'/' && p [1] == U'=') {
3396 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.);
3397 if (! var)
3398 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The vector ", vectorName.string, U" does not exist.\n"
3399 U"You can divide (/=) only existing vectors.");
3400 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3401 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, p += 2, & result);
3402 if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERIC_VECTORcxx . . $ `sys/Formula.h:26:9`!) {
3403 NumericVectorVariable_dividecxx . . $ NumericVectorVariable_divide(ea30aa56812f98b8). (var, resultcxx . . $ constvector#constvector(eac9d6ec4c4bfecd).. numericVectorResultcxx . . $ Formula_Result#numericVectorResult.);
3404 } else if (result. expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3405 NumericVectorVariable_dividecxx . . $ NumericVectorVariable_divide(812ebfd01c9301e7). (var, result. numericResultcxx . . $ Formula_Result#numericResult.);
3406 } else {
3407 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"You can divide (/=) a numeric vector only with a number or another numeric vector.");
3408 }
3409 } else if (*p == U'~') {
3410 /*
3411 This must be a formula assignment to a vector variable.
3412 */
3413 p ++; // step over tilde
3414 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p); // go to first token after assignment
3415 if (*p == U'\0')
3416 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing formula expression for vector ", vectorName.string, U".");
3417 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, vectorName.stringcxx . . $ MelderString#string.);
3418 if (! var)
3419 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The vector ", vectorName.string, U" does not exist.\n"
3420 "You can assign a formula only to an existing vector.");
3421 static Matrixcxx . . $ Matrix# vectorObject;
3422 if (! vectorObject)
3423 vectorObject = Matrix_createSimplecxx . . $ Matrix_createSimple(1d1e893fc69cdb2f). (1, 1). releaseToAmbiguousOwnercxx . . $ autoSomeThing#releaseToAmbiguousOwner(258ee1c9e0a18a5c).(); // prevent destruction when program ends
3424 VECcxx . . $ VEC# vec = var -> numericVectorValuecxx . . $ structInterpreterVariable#numericVectorValue..getcxx . . $ autovector#get(e8d1da7fe68a6585).();
3425 //vectorObject -> xmin = 0.5;
3426 vectorObject -> xmaxcxx . . $ structFunction#xmax. = vec.sizecxx . . $ vector#size. + 0.5;
3427 vectorObject -> nxcxx . . $ structSampled#nx. = vec.sizecxx . . $ vector#size.;
3428 vectorObject -> zcxx . . $ structMatrix#z..cellscxx . . $ automatrix#cells. = & vec [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).1];
3429 //vectorObject -> z.nrow = 1;
3430 vectorObject -> zcxx . . $ structMatrix#z..ncolcxx . . $ automatrix#ncol. = vec.sizecxx . . $ vector#size.;
3431 Matrix_formulacxx . . $ Matrix_formula(3b405620ba9cc26e). (vectorObject, p, me, nullptr);
3432 } else Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing '=' or '+=' or '[' or '~' after vector variable ", vectorName.string, U".");
3433 }
3434 } else {
3435 /*
3436 Try to assign to a numeric variable.
3437 */
3438 double value;
3439 char32cxx . . $ char32# *variableName = command2.stringcxx . . $ MelderString#string.;
3440 int typeOfAssignment = 0; // plain assignment
3441 if (*p == U'\0') {
3442 /*
3443 Command ends here: it may be a PraatShell command.
3444 */
3445 (void) praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, command2.stringcxx . . $ MelderString#string.);
3446 continue; // next line
3447 }
3448 char32cxx . . $ char32# *endOfVariable = p;
3449 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
3450 if (*p == U'=' || ((*p == U'+' || *p == U'-' || *p == U'*' || *p == U'/') && p [1] == U'=')) {
3451 /*
3452 This must be an assignment (though: "echo = ..." ???)
3453 */
3454 typeOfAssignment = ( *p == U'+' ? 1 : *p == U'-' ? 2 : *p == U'*' ? 3 : *p == U'/' ? 4 : 0 );
3455 *endOfVariable = U'\0'; // close variable name; FIXME: this can be any weird character, e.g. hallo&
3456 } else if (*p == U'[') {
3457 /*
3458 This must be an assignment to an indexed numeric variable.
3459 */
3460 *endOfVariable = U'\0';
3461 static MelderStringcxx . . $ MelderString# indexedVariableName;
3462 MelderString_copycxx . . $ MelderString_copy(65be51a793e0ff96). (& indexedVariableName, command2.stringcxx . . $ MelderString#string., U"[");
3463 for (;;) {
3464 p ++; // skip opening bracket or comma
3465 static MelderStringcxx . . $ MelderString# index;
3466 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& index);
3467 int depth = 0;
3468 bool inString = false;
3469 while ((depth > 0 || (*p != U',' && *p != U']') || inString) && Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) {
3470 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& index, *p);
3471 if (*p == U'[') {
3472 if (! inString)
3473 depth ++;
3474 } else if (*p == U']') {
3475 if (! inString)
3476 depth --;
3477 }
3478 if (*p == U'"')
3479 inString = ! inString;
3480 p ++;
3481 }
3482 if (! Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p))
3483 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing closing bracket (]) in indexed variable.");
3484 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3485 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (! result. stringResult);
3486 Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (me, index.stringcxx . . $ MelderString#string., & result);
3487 if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!) {
3488 const double numericIndexValue = result. numericResultcxx . . $ Formula_Result#numericResult.;
3489 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& indexedVariableName, numericIndexValue);
3490 } else if (result.expressionTypecxx . . $ Formula_Result#expressionType. == kFormula_EXPRESSION_TYPE_STRINGcxx . . $ `sys/Formula.h:25:9`!) {
3491 MelderString_appendcxx . . $ MelderString_append(65be51a793e0ff96). (& indexedVariableName, U"\"", result. stringResultcxx . . $ Formula_Result#stringResult..getcxx . . $ _autostring#get(5a2a78a048fb49a8).(), U"\"");
3492 }
3493 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& indexedVariableName, *p);
3494 if (*p == U']')
3495 break;
3496 }
3497 variableName = indexedVariableName.stringcxx . . $ MelderString#string.;
3498 p ++; // skip closing bracket
3499 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
3500 if (*p == U'=' || ((*p == U'+' || *p == U'-' || *p == U'*' || *p == U'/') && p [1] == U'=')) {
3501 typeOfAssignment = ( *p == U'+' ? 1 : *p == U'-' ? 2 : *p == U'*' ? 3 : *p == U'/' ? 4 : 0 );
3502 }
3503 } else {
3504 /*
3505 Not an assignment: perhaps a PraatShell command (select, echo, execute, pause ...).
3506 */
3507 (void) praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, variableName);
3508 continue; // next line
3509 }
3510 p += ( typeOfAssignment == 0 ? 1 : 2 );
3511 Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (& p);
3512 if (*p == U'\0')
3513 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Missing expression after variable ", variableName, U".");
3514 /*
3515 Three classes of assignments:
3516 var = formula
3517 var = Query
3518 var = Object creation
3519 */
3520 if (isCommandcxx . . $ isCommand(2df281243f91fe91). (p)) {
3521 /*
3522 Get the value of the query.
3523 */
3524 MelderString_emptycxx . . $ MelderString_empty(93db1090f27e5462). (& valueString);
3525 autoMelderDivertInfocxx . . $ autoMelderDivertInfo# divertcxx . . $ autoMelderDivertInfo#autoMelderDivertInfo(93db1090f27e5462). (& valueString);
3526 MelderString_appendCharactercxx . . $ MelderString_appendCharacter(f4ab64866cffe712). (& valueString, 1); // will be overwritten by something totally different if any MelderInfo function is called...
3527 bool status = praat_executeCommandcxx . . $ praat_executeCommand(fa53797037260a84). (me, p);
3528 if (! status) {
3529 value = undefinedcxx . . $ undefined.; // anything can have happened, including an incorrect return type
3530 } else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::OBJECT_cxx . . $ kInterpreter_ReturnType#OBJECT_.) {
3531 integercxx . . $ integer# IOBJECT, selectedObject = 0, numberOfSelectedObjects = 0;
3532 WHEREcxx . . $ `sys/praat.h:198:9`! (SELECTEDcxx . . $ `sys/praat.h:200:9`!) {
3533 selectedObject = IOBJECT;
3534 numberOfSelectedObjects += 1;
3535 }
3536 if (numberOfSelectedObjects > 1)
3537 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Multiple objects selected. Cannot assign object IDs to numeric variable. "
3538 "Perhaps use a vector variable instead.");
3539 if (numberOfSelectedObjects == 0)
3540 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"No objects selected. Cannot assign object ID to variable.");
3541 value = theCurrentPraatObjectscxx . . $ theCurrentPraatObjects. -> listcxx . . $ structPraatObjects#list. [selectedObject]. idcxx . . $ structPraat_Object#id.;
3542 } else if (mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::REAL_cxx . . $ kInterpreter_ReturnType#REAL_. || mycxx . . $ `melder/melder.h:44:9`! returnTypecxx . . $ structInterpreter#returnType. == kInterpreter_ReturnTypecxx . . $ kInterpreter_ReturnType#::INTEGER_cxx . . $ kInterpreter_ReturnType#INTEGER_.) {
3543 value = Melder_atofcxx . . $ Melder_atof(13d725aae188c0cd). (valueString.stringcxx . . $ MelderString#string.); // including --undefined--
3544 } else
3545 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (kInterpreter_ReturnType_errorMessage (mycxx . . $ `melder/melder.h:44:9`! returnType, p),
3546 U"; not assigned to the numeric variable \"", variableName, U"\".");
3547 } else {
3548 /*
3549 Get the value of the formula.
3550 */
3551 Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (me, p, & value);
3552 }
3553 /*
3554 Assign the value to a variable.
3555 */
3556 if (typeOfAssignment == 0) {
3557 /*
3558 Use an existing variable, or create a new one.
3559 */
3560 //Melder_casual (U"looking up variable ", variableName);
3561 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_lookUpVariablecxx . . $ Interpreter_lookUpVariable(17b277cbad23fdab). (me, variableName);
3562 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. = value;
3563 } else {
3564 /*
3565 Modify an existing variable.
3566 */
3567 InterpreterVariablecxx . . $ InterpreterVariable# var = Interpreter_hasVariablecxx . . $ Interpreter_hasVariable(17b277cbad23fdab). (me, variableName);
3568 if (! var)
3569 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"The variable ", variableName, U" does not exist. You can modify only existing variables.");
3570 if (isundefcxx . . $ isundef(f8197d536af80c96). (var -> numericValuecxx . . $ structInterpreterVariable#numericValue.)) {
3571 /* Keep it that way. */
3572 } else {
3573 if (typeOfAssignment == 1) {
3574 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. += value;
3575 } else if (typeOfAssignment == 2) {
3576 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. -= value;
3577 } else if (typeOfAssignment == 3) {
3578 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. *= value;
3579 } else if (value == 0) {
3580 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. = undefinedcxx . . $ undefined.;
3581 } else {
3582 var -> numericValuecxx . . $ structInterpreterVariable#numericValue. /= value;
3583 }
3584 }
3585 }
3586 }
3587 } // endif fail
3588 if (mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. != 0 && mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. != mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.) {
3589 const integercxx . . $ integer# save_assertErrorLineNumber = mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber.;
3590 mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. = 0;
3591 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Script assertion fails in line ", save_assertErrorLineNumber,
3592 U": error « ", mycxx . . $ `melder/melder.h:44:9`! assertErrorString.string, U" » not raised. Instead: no error.");
3593
3594 }
3595 } catch (MelderErrorcxx . . $ MelderError#) {
3596 // Melder_casual (U"Error: << ", Melder_getError(),
3597 // U" >>\nassertErrorLineNumber: ", my assertErrorLineNumber,
3598 // U"\nlineNumber: ", lineNumber,
3599 // U"\nAssert error string: << ", assertErrorString.string,
3600 // U" >>\n"
3601 // );
3602 if (Melder_hasCrashcxx . . $ Melder_hasCrash(c9857a73d68e59ba). ())
3603 throw;
3604 if (mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. == 0) {
3605 throw;
3606 } else if (mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. != mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.) {
3607 if (str32strcxx . . $ str32str(2de17cd8f7c584a6). (Melder_getErrorcxx . . $ Melder_getError(1912f6684645c851). (), mycxx . . $ `melder/melder.h:44:9`! assertErrorStringcxx . . $ structInterpreter#assertErrorString..stringcxx . . $ MelderString#string.)) {
3608 Melder_clearErrorcxx . . $ Melder_clearError(49f6e7a06ebc5aa8). ();
3609 mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumbercxx . . $ structInterpreter#assertErrorLineNumber. = 0;
3610 } else {
3611 autostring32cxx . . $ autostring32# errorCopy_nothrow = Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (Melder_getErrorcxx . . $ Melder_getError(1912f6684645c851). ());
3612 Melder_clearErrorcxx . . $ Melder_clearError(49f6e7a06ebc5aa8). ();
3613 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Script assertion fails in line ", mycxx . . $ `melder/melder.h:44:9`! assertErrorLineNumber,
3614 U": error « ", mycxx . . $ `melder/melder.h:44:9`! assertErrorString.string, U" » not raised. Instead:\n",
3615 errorCopy_nothrow.get()
3616 );
3617 }
3618 }
3619 }
3620 } // endfor lineNumber
3621 if (! mycxx . . $ `melder/melder.h:44:9`! isHaltedcxx . . $ structInterpreter#isHalted.) {
3622 //my numberOfLabels = 0;
3623 mycxx . . $ `melder/melder.h:44:9`! runningcxx . . $ structInterpreter#running. = false;
3624 mycxx . . $ `melder/melder.h:44:9`! stoppedcxx . . $ structInterpreter#stopped. = false;
3625 }
3626 } catch (MelderErrorcxx . . $ MelderError#) {
3627 //TRACE
3628 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch");
3629 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch ", Melder_pointer (me));
3630 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch at line number ", mycxx . . $ `melder/melder.h:44:9`! lineNumber);
3631 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch with stack ", Melder_pointer (mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStack));
3632 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch in file ", & mycxx . . $ `melder/melder.h:44:9`! file);
3633 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch at level ", mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStack -> currentLevel);
3634 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch at stack interpreter ", Melder_pointer (mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStack -> current_0 ()));
3635 if (mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. > 0) {
3636 const bool normalExplicitExit = str32nequcxx . . $ `melder/melder_str32.h:123:9`! (mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.], U"exit ", 5) || Melder_hasErrorcxx . . $ Melder_hasError(2df281243f91fe91). (U"Script exited.");
3637 if (! normalExplicitExit && ! assertionFailed) { // don't show the message twice!
3638 while (mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.] [0] == U'\0') { // did this use to be a continuation line?
3639 mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber. --;
3640 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"line number lowered to ", mycxx . . $ `melder/melder.h:44:9`! lineNumber);
3641 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! lineNumber > 0); // originally empty lines that stayed empty should not generate errors
3642 }
3643 Melder_appendErrorcxx . . $ Melder_appendError(6298c93241566110). (U"Script line ", mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber., U" not performed or completed:\n« ", mycxx . . $ `melder/melder.h:44:9`! linescxx . . $ structInterpreter#lines. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! lineNumbercxx . . $ structInterpreter#lineNumber.], U" »");
3644 }
3645 }
3646 //my numberOfLabels = 0;
3647 mycxx . . $ `melder/melder.h:44:9`! runningcxx . . $ structInterpreter#running. = false;
3648 mycxx . . $ `melder/melder.h:44:9`! stoppedcxx . . $ structInterpreter#stopped. = false;
3649 //my isHalted = false; // TODO: needed?
3650 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch: has finished...", Melder_pointer (mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStack));
3651 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"catch: ... has finished");
3652 if (Melder_hasCrashcxx . . $ Melder_hasCrash(c9857a73d68e59ba). ()) {
3653 mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> currentLevelcxx . . $ structInterpreterStack#currentLevel. -= 1; // TODO: encapsulate
3654 throw;
3655 } else if (str32equcxx . . $ `melder/melder_str32.h:122:9`! (Melder_getErrorcxx . . $ Melder_getError(1912f6684645c851). (), U"\nScript exited.\n")) {
3656 Melder_clearErrorcxx . . $ Melder_clearError(49f6e7a06ebc5aa8). ();
3657 } else {
3658 mycxx . . $ `melder/melder.h:44:9`! owningInterpreterStackcxx . . $ structInterpreter#owningInterpreterStack. -> currentLevelcxx . . $ structInterpreterStack#currentLevel. -= 1; // TODO: encapsulate
3659 throw;
3660 }
3661 }
3662 }
3663
3664 void Interpreter_stopcxx . . $ Interpreter_stop(448c181fe9dacca8). (Interpretercxx . . $ Interpreter# me) {
3665 //Melder_casual (U"Interpreter_stop in: ", Melder_pointer (me));
3666 mycxx . . $ `melder/melder.h:44:9`! stoppedcxx . . $ structInterpreter#stopped. = true;
3667 mycxx . . $ `melder/melder.h:44:9`! runningcxx . . $ structInterpreter#running. = false;
3668 //my numberOfLabels = 0;
3669 //Melder_casual (U"Interpreter_stop out: ", Melder_pointer (me));
3670 }
3671
3672 void Interpreter_voidExpressioncxx . . $ Interpreter_voidExpression(c79bee1e2231f904). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression) {
3673 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!, false);
3674 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3675 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, & result);
3676 }
3677
3678 void Interpreter_numericExpressioncxx . . $ Interpreter_numericExpression(8639512facf48b76). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression, double *out_value) {
3679 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_NUMERICcxx . . $ `sys/Formula.h:24:9`!, false);
3680 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3681 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, & result);
3682 *out_value = result. numericResultcxx . . $ Formula_Result#numericResult.;
3683 }
3684
3685 void Interpreter_numericVectorExpressioncxx . . $ Interpreter_numericVectorExpression(e47164ae4c0553fe). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression, VECcxx . . $ VEC# *out_value, bool *out_owned) {
3686 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_NUMERIC_VECTORcxx . . $ `sys/Formula.h:26:9`!, false);
3687 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3688 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, & result);
3689 *out_value =cxx . . $ vector#`operator=`(958c14910af86093). result. numericVectorResultcxx . . $ Formula_Result#numericVectorResult.;
3690 *out_owned = result. ownedcxx . . $ Formula_Result#owned.;
3691 result. ownedcxx . . $ Formula_Result#owned. = false;
3692 }
3693
3694 void Interpreter_numericMatrixExpressioncxx . . $ Interpreter_numericMatrixExpression(dd630cc19a2beb06). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression, MATcxx . . $ MAT# *out_value, bool *out_owned) {
3695 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_NUMERIC_MATRIXcxx . . $ `sys/Formula.h:27:9`!, false);
3696 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3697 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, & result);
3698 *out_value =cxx . . $ matrix#`operator=`(5dfd60dc70a2bbd2). result. numericMatrixResultcxx . . $ Formula_Result#numericMatrixResult.;
3699 *out_owned = result. ownedcxx . . $ Formula_Result#owned.;
3700 result. ownedcxx . . $ Formula_Result#owned. = false;
3701 }
3702
3703 autostring32cxx . . $ autostring32# Interpreter_stringExpressioncxx . . $ Interpreter_stringExpression(ae2ff4958c59280d). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression) {
3704 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_STRINGcxx . . $ `sys/Formula.h:25:9`!, false);
3705 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3706 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, & result);
3707 return resultcxx . . $ _autostring#_autostring(39021ecceedcc7d2).. stringResultcxx . . $ Formula_Result#stringResult..movecxx . . $ _autostring#move(bd43c759570f178f).();
3708 }
3709
3710 void Interpreter_stringArrayExpressioncxx . . $ Interpreter_stringArrayExpression(4cd1c45f7f524604). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression, STRVECcxx . . $ STRVEC# *out_value, bool *out_owned) {
3711 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_STRING_ARRAYcxx . . $ `sys/Formula.h:30:9`!, false);
3712 Formula_Resultcxx . . $ Formula_Result# resultcxx . . $ Formula_Result#Formula_Result(49f6e7a06ebc5aa8).;
3713 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, & result);
3714 *out_value =cxx . . $ _stringvector#`operator=`(15d94a005602ee33). result. stringArrayResultcxx . . $ Formula_Result#stringArrayResult.;
3715 *out_owned = result. ownedcxx . . $ Formula_Result#owned.;
3716 result. ownedcxx . . $ Formula_Result#owned. = false;
3717 }
3718
3719 void Interpreter_anyExpressioncxx . . $ Interpreter_anyExpression(26b9613ed4865362). (Interpretercxx . . $ Interpreter# me, conststring32cxx . . $ conststring32# expression, Formula_Resultcxx . . $ Formula_Result# *out_result) {
3720 Formula_compilecxx . . $ Formula_compile(3f9bc12732facfd). (me, nullptr, expression, kFormula_EXPRESSION_TYPE_UNKNOWNcxx . . $ `sys/Formula.h:31:9`!, false);
3721 Formula_runcxx . . $ Formula_run(4cd939002183d562). (0, 0, out_result);
3722 }
3723
3724 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (InterpreterStack, Thing, 0);
3725
3726 /*
3727 Schematic code:
3728
3729 void Interpreter_run (Interpreter me) {
3730 my lineNumber = 1;
3731 Interpreter_resume (me);
3732 }
3733 void Interpreter_resume (Interpreter me) {
3734 my isHalted = false;
3735 try {
3736 for (; lineNumber <= my lines.size; lineNumber ++) {
3737 if (my isHalted)
3738 break;
3739 handleOneLine ();
3740 }
3741 } catch (MelderError) {
3742 my owningInterpreterStack -> currentLevel -= 1;
3743 throw;
3744 }
3745 }
3746 void runScript (InterpreterStack interpreterStack, conststring32 fileName, integer narg, Stackel args, Editor optionalInterpreterOwningEditor) {
3747 Melder_assert (interpreterStack);
3748 Interpreter parentInterpreter = interpreterStack -> current_a ();
3749 if (parentInterpreter -> isInSecondPass) {
3750 interpreterStack -> resumeNextLevelInSecondPass ();
3751 } else {
3752 Melder_assert (MelderFolder_equal (Melder_peekWorkingDirectory (), & parentInterpreter -> workingDirectory));
3753 //autoMelderSetCurrentFolder folder (& parentInterpreter -> workingDirectory); // TODO: is this superfluous, i.e. does the previous assertion never fire?
3754 structMelderFile file { };
3755 try {
3756 Melder_relativePathToFile (fileName, & file);
3757 autostring32 text = MelderFile_readText (& file);
3758 {// scope
3759 autoMelderFileSetCurrentFolder folder (& file); // so that callee-relative file names can be used for including include files
3760 Melder_includeIncludeFiles (& text);
3761 } // back to the default directory of the caller
3762 autoInterpreter me = Interpreter_createFromEnvironment (
3763 interpreterStack, // owner always needed
3764 optionalInterpreterOwningEditor,
3765 & file // so that callee-relative file names can be used inside the script
3766 );
3767 Interpreter_readParameters (me.get(), text.get()); // TODO: should become a field of structInterpreter
3768 my text = text.move();
3769 Interpreter_getArgumentsFromArgs (me.get(), narg, args); // interpret caller-relative paths for infile/outfile/folder arguments
3770 interpreterStack -> runDown (me.move(), autostring32(), false); // back to the default directory of the caller
3771 } catch (MelderError) {
3772 Melder_throw (U"Script ", & file, U" not completed."); // don't refer to 'fileName', because its contents may have changed
3773 }
3774 }
3775 }
3776 int endPause (int numberOfContinueButtons, int defaultContinueButton, int cancelContinueButton,
3777 conststring32 continueText1, conststring32 continueText2, conststring32 continueText3,
3778 conststring32 continueText4, conststring32 continueText5, conststring32 continueText6,
3779 conststring32 continueText7, conststring32 continueText8, conststring32 continueText9,
3780 conststring32 continueText10, Interpreter interpreter)
3781 {
3782 Melder_assert (interpreter);
3783 if (interpreter -> isInSecondPass) {
3784 Melder_assert (interpreter == thePauseForm_interpreterReference);
3785 Melder_assert (! thePauseForm);
3786 interpreter -> isInSecondPass = false; // TODO: needed?
3787 return thePauseForm_clicked;
3788 } else {
3789 if (! thePauseForm)
3790 Melder_throw (U"Found the function “endPause” without a preceding “beginPause”.");
3791 thePauseForm_interpreterReference = interpreter;
3792 thePauseForm_savedEditorReference = interpreter -> optionalDynamicEnvironmentEditor();
3793 UiForm_setPauseForm (thePauseForm.get(), numberOfContinueButtons, defaultContinueButton, cancelContinueButton,
3794 continueText1, continueText2, continueText3, continueText4, continueText5,
3795 continueText6, continueText7, continueText8, continueText9, continueText10,
3796 thePauseFormCancelCallback
3797 );
3798 theCancelContinueButton = cancelContinueButton;
3799 UiForm_finish (thePauseForm.get());
3800 thePauseForm_clicked = 0;
3801 Melder_assert (interpreter -> owningInterpreterStack);
3802 interpreter -> owningInterpreterStack -> haltAll ();
3803 UiForm_destroyWhenUnmanaged (thePauseForm.get());
3804 UiForm_do (thePauseForm.get(), false); // put he pause form on the screen
3805 return 0;
3806 }
3807 }
3808 void Demo_waitForInput (Interpreter interpreter) {
3809 Melder_assert (interpreter);
3810 if (interpreter -> isInSecondPass) {
3811 interpreter -> isInSecondPass = false; // TODO: needed?
3812 } else {
3813 if (! theReferenceToTheOnlyDemoEditor)
3814 Melder_throw (U"Cannot do demoWaitForInput() if the Demo window isn’t visible.");
3815 if (theReferenceToTheOnlyDemoEditor -> waitingForInput &&0) {
3816 Melder_throw (U"You cannot work with the Demo window while it is waiting for input. "
3817 U"Please click or type into the Demo window or close it.");
3818 }
3819 //GuiThing_show (theReferenceToTheOnlyDemoEditor -> windowForm);
3820 theReferenceToTheOnlyDemoEditor -> clicked = false;
3821 theReferenceToTheOnlyDemoEditor -> keyPressed = false;
3822 theReferenceToTheOnlyDemoEditor -> waitingForInput = true;
3823 interpreter -> owningInterpreterStack -> haltAll ();
3824 theReferenceToTheOnlyDemoEditor -> interpreterReference = interpreter;
3825 }
3826 }
3827 static void thePauseFormOkCallback (void *closure) {
3828 if (! thePauseForm_interpreterReference) { // interpreter was destroyed?
3829 GuiThing_hide (thePauseForm -> d_dialogForm); // BUG: memory leak
3830 thePauseForm. releaseToUser();
3831 return;
3832 }
3833 if (! thePauseForm) // BUG: perhaps there was a mistake in the script
3834 return;
3835 thePauseForm_clicked = UiForm_getClickedContinueButton (thePauseForm.get());
3836 if (thePauseForm_clicked != theCancelContinueButton)
3837 UiForm_Interpreter_addVariables (thePauseForm.get(), (Interpreter) closure); // 'closure', not 'interpreter' or 'theInterpreter'!
3838 Melder_assert (thePauseForm_clicked >= 1 && thePauseForm_clicked <= 10);
3839 autostring32 clickedText = Melder_dup (thePauseForm -> continueTexts [thePauseForm_clicked].get()); // very safe
3840 if (thePauseForm -> d_dialogForm) {
3841 GuiThing_hide (thePauseForm -> d_dialogForm); // BUG: memory leak
3842 //thePauseForm_interpreterReference -> isInSecondPass = false; // TODO: corrected? and what about isHalted?
3843 }
3844 thePauseForm. releaseToUser(); // undangle (will be autodestroyed when unmanaged)
3845 Melder_assert (! thePauseForm);
3846 try {
3847 autoPraatBackground background;
3848 Melder_assert (thePauseForm_interpreterReference -> owningInterpreterStack);
3849 thePauseForm_interpreterReference -> owningInterpreterStack -> resumeFromTop ();
3850 } catch (MelderError) {
3851 if (thePauseForm_clicked == theCancelContinueButton)
3852 Melder_throw (U"This happened after you cancelled the pause form.");
3853 else
3854 Melder_throw (U"This happened after you clicked “", clickedText.get(), U"” in the pause form.");
3855 }
3856 }
3857 */
3858
3859 autoInterpreterStackcxx . . $ autoInterpreterStack# InterpreterStack_createcxx . . $ InterpreterStack_create(91aa183261e4fa82). (Editorcxx . . $ Editor# optionalInterpreterStackOwningEditor) {
3860 try {
3861 autoInterpreterStackcxx . . $ autoInterpreterStack# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (InterpreterStack);
3862 mycxx . . $ `melder/melder.h:44:9`! optionalInterpreterStackOwningEditorcxx . . $ structInterpreterStack#optionalInterpreterStackOwningEditor. = optionalInterpreterStackOwningEditor;
3863 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
3864 } catch (MelderErrorcxx . . $ MelderError#) {
3865 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"InterpreterStack not created.");
3866 }
3867 }
3868
3869 void structInterpreterStackcxx . . $ structInterpreterStack# :: emptyAllcxx . . $ structInterpreterStack#emptyAll(49f6e7a06ebc5aa8). () {
3870 for (integercxx . . $ integer# ilevel = 1; ilevel <= ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel.; ilevel ++)
3871 ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ilevel]. resetcxx . . $ autoSomeThing#reset(ced63f7c635d850d).();
3872 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. = 0;
3873 }
3874
3875 void structInterpreterStackcxx . . $ structInterpreterStack# :: runDowncxx . . $ structInterpreterStack#runDown(f108da249e59f621). (autoInterpretercxx . . $ autoInterpreter# interpreter, autostring32cxx . . $ autostring32# text, const bool reuseVariables) {
3876 if (ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. == InterpreterStack_MAXIMUM_NUMBER_OF_LEVELScxx . . $ InterpreterStack_MAXIMUM_NUMBER_OF_LEVELS.)
3877 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cannot have more than ", InterpreterStack_MAXIMUM_NUMBER_OF_LEVELS, U" levels of nested scripts.");
3878 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. += 1;
3879 if (interpreter)
3880 ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel.] =cxx . . $ autoSomeThing#`operator=`(80cc59814f7161e8). interpreter.movecxx . . $ autoSomeThing#move(25acc3554b7d1642).(); // otherwise, use my existing interpreter
3881 const integercxx . . $ integer# oldLevel = ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel.; // sets up an assertion below
3882 Interpretercxx . . $ Interpreter# childInterpreter = ourcxx . . $ `melder/melder.h:42:9`! current_acxx . . $ structInterpreterStack#current_a(f106979d91fbaa9d).();
3883 try {
3884 autoMelderSetCurrentFoldercxx . . $ autoMelderSetCurrentFolder# foldercxx . . $ autoMelderSetCurrentFolder#autoMelderSetCurrentFolder(63f38d3b6b86d1dc). (& childInterpreter -> workingDirectorycxx . . $ structInterpreter#workingDirectory.);
3885 Interpreter_runcxx . . $ Interpreter_run(eec3dd5f99c9d46a). (childInterpreter, textcxx . . $ _autostring#_autostring(39021ecceedcc7d2)..movecxx . . $ _autostring#move(bd43c759570f178f).(), reuseVariables);
3886 } catch (MelderErrorcxx . . $ MelderError#) {
3887 //if (currentLevel == 0)
3888 // our emptyAll (); // TODO: figure out when precisely an interpreter can be deleted
3889 //Melder_throw (U"Interpreter stack not run completely.");
3890 throw;
3891 }
3892 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ourcxx . . $ `melder/melder.h:42:9`! currentLevel == oldLevel);
3893 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. -= 1;
3894 if (ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. == 0) {
3895 //our emptyAll(); // TODO: successful run of the whole stack; can we delete? Does it depend on halted?
3896 return; // nothing else to do
3897 }
3898 Interpretercxx . . $ Interpreter# parentInterpreter = ourcxx . . $ `melder/melder.h:42:9`! current_acxx . . $ structInterpreterStack#current_a(f106979d91fbaa9d).();
3899 if (! childInterpreter -> isHaltedcxx . . $ structInterpreter#isHalted.) { // TODO: why the child interpreter?
3900 parentInterpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass. = false; // TODO: why the parent interpreter?
3901 //childInterpreter. reset(); // TODO: figure out when precisely an interpreter can be deleted
3902 }
3903 }
3904
3905 void structInterpreterStackcxx . . $ structInterpreterStack# :: haltAllcxx . . $ structInterpreterStack#haltAll(49f6e7a06ebc5aa8). () {
3906 for (integercxx . . $ integer# ilevel = 1; ilevel <= ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel.; ilevel ++) {
3907 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ourcxx . . $ `melder/melder.h:42:9`! interpreters [ilevel]);
3908 ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ilevel] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). isHaltedcxx . . $ structInterpreter#isHalted. = true; // ensures fast unwinding, without processing any more lines
3909 ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ilevel] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). lineNumbercxx . . $ structInterpreter#lineNumber. -= 1; // ensure that all runScripts will get a second pass
3910 }
3911 }
3912
3913 void structInterpreterStackcxx . . $ structInterpreterStack# :: resumeFromTopcxx . . $ structInterpreterStack#resumeFromTop(49f6e7a06ebc5aa8). () {
3914 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. = 1;
3915 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ourcxx . . $ `melder/melder.h:42:9`! interpreters [1]);
3916
3917 /*
3918 Unhalt all.
3919 */
3920 for (integercxx . . $ integer# ilevel = 1; ilevel <= InterpreterStack_MAXIMUM_NUMBER_OF_LEVELScxx . . $ InterpreterStack_MAXIMUM_NUMBER_OF_LEVELS.; ilevel ++)
3921 if (ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ilevel]) {
3922 ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ilevel] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). isHaltedcxx . . $ structInterpreter#isHalted. = false;
3923 ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [ilevel] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). isInSecondPasscxx . . $ structInterpreter#isInSecondPass. = true; // ensures that all runScripts, the pause window and demoWaitForInput will short-cut
3924 }
3925
3926 try {
3927 autoMelderSetCurrentFoldercxx . . $ autoMelderSetCurrentFolder# foldercxx . . $ autoMelderSetCurrentFolder#autoMelderSetCurrentFolder(63f38d3b6b86d1dc). (& ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [1] ->cxx . . $ autoSomeThing#`operator->`(34d6acfd341ba7ab). workingDirectorycxx . . $ structInterpreter#workingDirectory.);
3928 Interpreter_resumecxx . . $ Interpreter_resume(448c181fe9dacca8). (ourcxx . . $ `melder/melder.h:42:9`! interpreterscxx . . $ structInterpreterStack#interpreters. [1].getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
3929 } catch (MelderErrorcxx . . $ MelderError#) {
3930 //if (currentLevel == 0)
3931 // our emptyAll (); // TODO: figure out when precisely an interpreter can be deleted; perhaps always, when we're here?
3932 //Melder_throw (U"Interpreter stack has not run to completion.");
3933 throw;
3934 }
3935 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. -= 1;
3936 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ourcxx . . $ `melder/melder.h:42:9`! currentLevel == 0); // running an interpreter to its end MUST have decremented the level
3937 //our emptyAll(); // TODO: successful run of the whole stack; can we delete? Does it depend on halted?
3938 }
3939
3940 void structInterpreterStackcxx . . $ structInterpreterStack# :: resumeNextLevelInSecondPasscxx . . $ structInterpreterStack#resumeNextLevelInSecondPass(49f6e7a06ebc5aa8). () {
3941 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. += 1;
3942 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (ourcxx . . $ `melder/melder.h:42:9`! currentLevel <= InterpreterStack_MAXIMUM_NUMBER_OF_LEVELS);
3943 Interpretercxx . . $ Interpreter# childInterpreter = ourcxx . . $ `melder/melder.h:42:9`! current_acxx . . $ structInterpreterStack#current_a(f106979d91fbaa9d).();
3944 {// scope
3945 autoMelderSetCurrentFoldercxx . . $ autoMelderSetCurrentFolder# foldercxx . . $ autoMelderSetCurrentFolder#autoMelderSetCurrentFolder(63f38d3b6b86d1dc). (& childInterpreter -> workingDirectorycxx . . $ structInterpreter#workingDirectory.); // so that callee-relative file names can be used inside the script
3946 Interpreter_resumecxx . . $ Interpreter_resume(448c181fe9dacca8). (childInterpreter);
3947 } // back to the default directory of the caller
3948 ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. -= 1;
3949 if (ourcxx . . $ `melder/melder.h:42:9`! currentLevelcxx . . $ structInterpreterStack#currentLevel. == 0)
3950 return; // nothing to do
3951 Interpretercxx . . $ Interpreter# parentInterpreter = ourcxx . . $ `melder/melder.h:42:9`! current_acxx . . $ structInterpreterStack#current_a(f106979d91fbaa9d).();
3952 //Melder_assert (! childInterpreter -> isHalted); // TODO: why not parentInterpreter? and why can this fire?
3953 if (! childInterpreter -> isHaltedcxx . . $ structInterpreter#isHalted.) {
3954 parentInterpreter -> isInSecondPasscxx . . $ structInterpreter#isInSecondPass. = false; // TODO: why not childInterpreter?
3955 //our interpreters [our currentLevel + 1]. reset(); // TODO: figure out when precisely an interpreter can be deleted
3956 }
3957 }
3958
3959 /* End of file Interpreter.cpp */