Debian Codegraph @

packages/seacas/libraries/aprepro_lib/apr_init.cc

raw
1 // Copyright(C) 1999-2025 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6
7 /***
8 NAME
9 init
10 PURPOSE
11 Initialize variables and functions Aprepro
12 ***/
13 #include "apr_builtin.h"
14 #include "apr_tokenize.h"
15 #include "aprepro.h" // for symrec, Aprepro, etc
16 #include "init_structs.h" // for array_a_init, array_c_init, etc
17 #include <array>
18 #include <string> // for string
19
20 namespace SEAMS {
21 const init arith_0_fncts[] = {
22 {"seconds", do_time, "seconds()", "Seconds since epoch (useful for srand())."},
23 {nullptr, nullptr, nullptr, nullptr}};
24
25 const init_d arith_fncts[] = {
26 {"abs", do_fabs, "abs(x)", "Absolute value of x. |x|."},
27 {"acos", do_acos, "acos(x)", "Inverse cosine of x, returns radians."},
28 {"acosd", do_acosd, "acosd(x)", "Inverse cosine of x, returns degrees."},
29 {"acosh", do_acosh, "acosh(x)", "Inverse hyperbolic cosine of x."},
30 {"asin", do_asin, "asin(x)", "Inverse sine of x, returns radians."},
31 {"asind", do_asind, "asind(x)", "Inverse sine of x, returns degrees."},
32 {"asinh", do_asinh, "asinh(x)", "Inverse hyperbolic sine of x."},
33 {"atan", do_atan, "atan(x)", "Inverse tangent of x, returns radians."},
34 {"atand", do_atand, "atand(x)", "Inverse tangent of x, returns degrees."},
35 {"atanh", do_atanh, "atanh(x)", "Inverse hyperbolic tangent of x."},
36 {"cbrt", do_cbrt, "cbrt(x)", "Cube root of x. "},
37 {"ceil", do_ceil, "ceil(x)", "Smallest integer not less than x."},
38 {"cos", do_cos, "cos(x)", "Cosine of x, with x in radians"},
39 {"cosd", do_cosd, "cosd(x)", "Cosine of x, with x in degrees"},
40 {"cosh", do_cosh, "cosh(x)", "Hyperbolic cosine of x."},
41 {"d2r", do_d2r, "d2r(x)", "Degrees to radians."},
42 {"erf", do_erf, "erf(x)", "Error Function of x"},
43 {"erfc", do_erfc, "erfc(x)", "Complementary Error Function of x"},
44 {"exp", do_exp, "exp(x)", "Exponential: e^x"},
45 {"expm1", do_expm1, "expm1(x)", "Exponential: Accurate version of e^x - 1.0 for small x"},
46 {"floor", do_floor, "floor(x)", "Largest integer not greater than x."},
47 {"int", do_int, "int(x), [x]", "Integer part of x truncated toward 0."},
48 {"lgamma", do_lgamma, "lgamma(x)", "log(Gamma(x))."},
49 {"tgamma", do_tgamma, "tgamma(x)", "Gamma(x)."},
50 {"ln", do_log, "ln(x)", "Natural (base e) logarithm of x."},
51 {"log", do_log, "log(x)", "Natural (base e) logarithm of x."},
52 {"log10", do_log10, "log10(x)", "Base 10 logarithm of x. "},
53 {"log1p", do_log1p, "log1p(x)", "log(1+x) "},
54 {"nint", do_nint, "nint(x)", "Rounds x to nearest integer. <0.5 down; >=0.5 up."},
55 {"r2d", do_r2d, "r2d(x)", "Radians to degrees. "},
56 {"sin", do_sin, "sin(x)", "Sine of x, with x in radians. "},
57 {"sind", do_sind, "sind(x)", "Sine of x, with x in degrees. "},
58 {"sinh", do_sinh, "sinh(x)", "Hyperbolic sine of x "},
59 {"srand", do_srand, "srand(seed)",
60 "Seed the random number generator with the given integer value. "},
61 {"sqrt", do_sqrt, "sqrt(x)", "Square root of x. "},
62 {"tan", do_tan, "tan(x)", "Tangent of x, with x in radians. "},
63 {"tand", do_tand, "tand(x)", "Tangent of x, with x in radians. "},
64 {"tanh", do_tanh, "tanh(x)", "Hyperbolic tangent of x. "},
65 {"FtoC", do_FtoC, "FtoC(x)",
66 "Convert temperature x from degrees F to degrees C (212F -> 100C)"},
67 {"CtoF", do_CtoF, "CtoF(x)",
68 "Convert temperature x from degrees C to degrees F (100C -> 212F)"},
69 {nullptr, nullptr, nullptr, nullptr}};
70
71 const init_a arith_a_fncts[] = {
72 {"rows", do_rows, "rows(array)", "Returns the number of rows in the array. "},
73 {"cols", do_cols, "cols(array)", "Returns the number of columns in the array. "},
74 {nullptr, nullptr, nullptr, nullptr}};
75
76 const init_dd arith_dd_fncts[] = {
77 {"atan2", do_atan2, "atan2(y,x)", "Inverse tangent of y/x, returns radians."},
78 {"atan2d", do_atan2d, "atan2d(y,x)", "Inverse tangent of y/x, returns degrees."},
79 {"dim", do_dim, "dim(x,y)", "x - min(x,y)"},
80 {"fmod", do_fmod, "fmod(x,y)", "Floating-point remainder of x/y."},
81 {"hypot", do_hypot, "hypot(x,y)", "sqrt(x^2+y^2)."},
82 {"max", do_max, "max(x,y)", "Maximum of x and y. "},
83 {"min", do_min, "min(x,y)", "Minimum of x and y. "},
84 {"polarX", do_polarX, "polarX(r,a)", "r * cos(a), a is in degrees "},
85 {"polarY", do_polarY, "polarY(r,a)", "r * sin(a), a is in degrees "},
86 {"pow", do_pow, "pow(x,y)", "x^y "},
87 {"rand", do_rand, "rand(xl,xh)", "Random value between xl and xh; uniformly distributed. "},
88 {"rand_normal", do_rand_normal, "rand_normal(m,s)",
89 "Random value normally distributed with mean m and stddev s."},
90 {"rand_lognormal", do_rand_lognormal, "rand_lognormal(m,s)",
91 "Random value with lognormal distribution with mean m and stddev s."},
92 {"rand_weibull", do_rand_weibull, "rand_weibull(a, b)",
93 "Random value with weibull distribution with alpha=a and beta=b. "},
94 {"sign", do_sign, "sign(x,y)", "x * sgn(y)"},
95 {nullptr, nullptr, nullptr, nullptr}};
96
97 const init_dddd arith_dddd_fncts[] = {
98 {"Vangle", do_angle, "Vangle(x1,y1,x2,y2)",
99 "Angle (radians) between vector x1_i+y1_j and x2_i+y2_j."},
100 {"Vangled", do_angled, "Vangled(x1,y1,x2,y2)",
101 "Angle (degrees) between vector x1_i+y1_j and x2_i+y2_j."},
102 {"dist", do_dist, "dist(x1,y1, x2,y2)", "sqrt((x1-x2)^2 + (y1-y2)^2)"},
103 {nullptr, nullptr, nullptr, nullptr}};
104
105 const init_cc arith_cc_fncts[] = {
106 {"word_count", do_word_count, "word_count(svar,del)",
107 "Number of words in svar. Words are separated by one or more of the "
108 "characters\n\t\t\tin the "
109 "string variable 'del'."},
110 {nullptr, nullptr, nullptr, nullptr}};
111
112 const init_ccc arith_ccc_fncts[] = {
113 {"find_word", do_find_word, "find_word(w,s,d)",
114 "Find the 1-based index of word 'w' in variable 's'. Words are separated "
115 "by one or more of the\n\t\t\tcharacters in the "
116 "string variable 'd'. Returns 0 if not found."},
117 {nullptr, nullptr, nullptr, nullptr}};
118
119 const init_c arith_c_fncts[] = {{"strtod", do_strtod, "strtod(svar)",
120 "Returns a double-precision floating-point number "
121 "equal to the value represented by the\n\t\t\tcharacter "
122 "string pointed to by svar."},
123 {nullptr, nullptr, nullptr, nullptr}};
124
125 const init_cd arith_cd_fncts[] = {{"option", do_option, "option(?,?)", "Internal"},
126 {nullptr, nullptr, nullptr, nullptr}};
127
128 const init_ddd arith_ddd_fncts[] = {
129 {"julday", do_julday, "julday(mm, dd, yy)", "Julian day corresponding to mm/dd/yy. "},
130 {nullptr, nullptr, nullptr, nullptr}};
131
132 const init_dddddd arith_dddddd_fncts[] = {{"juldayhms", do_juldayhms, "juldayhms(m,d,y,h,m,s)",
133 "Julian day corresponding to m/d/y at h:m:s "},
134 {nullptr, nullptr, nullptr, nullptr}};
135
136 const str_init string_fncts[] = {
137 {"DUMP", do_dumpsym, "DUMP()",
138 "Output a list of all user-defined variables and their value."},
139 {"DUMP_JSON", do_dumpsym_json, "DUMP_JSON()",
140 "Output a list of all user-defined variables and their value in JSON format."},
141 {"DUMP_FUNC", do_dumpfunc, "DUMP_FUNC()",
142 "Output a list of all double and string functions recognized by aprepro."},
143 {"DUMP_PREVAR", do_dumpvar, "DUMP_PREVAR()",
144 "Output a list of all predefined variables and their value."},
145 {"get_date", do_get_date, "get_date()",
146 "Returns a string representing the current date in the form YYYY/MM/DD."},
147 {"get_iso_date", do_get_iso_date, "get_iso_date()",
148 "Returns a string representing the current date in the form YYYYMMDD."},
149 {"get_time", do_get_time, "get_time()",
150 "Returns a string representing the current time in the form HH:MM:SS."},
151 {"get_temp_filename", do_get_temp_filename, "get_temp_filename()",
152 "Returns a string which can be used for a temporary filename without conflicting with any "
153 "other filenames."},
154 {"version", do_version, "version()",
155 "Return the version string (See also _VERSION variable)"},
156 {nullptr, nullptr, nullptr, nullptr}};
157
158 const str_c_init string_c_fncts[] = {
159 {"DUMP", do_dumpsym1, "DUMP(str)",
160 "Output a list of all defined variables and their value if name contains 'str'."},
161 {"DUMP_FUNC", do_dumpfunc1, "DUMP_FUNC(str)",
162 "Output a list of all double and string functions recognized by aprepro if name contains "
163 "'str'."},
164 {"DUMP_PREVAR", do_dumpvar1, "DUMP_PREVAR()",
165 "Output a list of all predefined variables and their value if name contains 'str'."},
166 {"tolower", do_tolower, "tolower(svar)",
167 "Translates all uppercase characters in svar to "
168 "lowercase. It modifies svar and returns the "
169 "resulting string. "},
170 {"toupper", do_toupper, "toupper(svar)",
171 "Translates all lowercase character in svar to "
172 "uppercase. It modifies svar and returns the "
173 "resulting string. "},
174 {"to_lower", do_tolower, "to_lower(svar)",
175 "Translates all uppercase characters in svar to "
176 "lowercase. It modifies svar and returns the "
177 "resulting string. "},
178 {"to_upper", do_toupper, "to_upper(svar)",
179 "Translates all lowercase character in svar to "
180 "uppercase. It modifies svar and returns the "
181 "resulting string. "},
182 {"import", do_import, "import(svar)",
183 "Include/import the file pointed to by the string variable or expression 'svar'"},
184 {"getenv", do_getenv, "getenv(svar)",
185 "Returns a string containing the value of the environment variable svar. If the environment "
186 "\n\t\t\tvariable is not defined, an empty string is returned. "},
187 {"file_to_string", do_file_to_string, "file_to_string(fn)",
188 "Opens the file specified by fn and returns the contents as a multi-line string."},
189 {"error", do_error, "error(svar)",
190 "Outputs the string svar to stderr and then terminates the code with an error exit status."},
191 {"execute", do_execute, "execute(svar)",
192 "svar is parsed and executed as if it were a line read from the input file."},
193 {"output", do_output, "output(filename)",
194 "Creates the file specified by filename and sends "
195 "\n\t\t\tall subsequent output from aprepro to that file."},
196 {"output_append", do_append, "output_append(fn)",
197 "If file with name fn exists, append output to it; otherwise create the file and "
198 "send\n\t\t\tall "
199 "subsequent output from aprepro to that file."},
200 {"rescan", do_rescan, "rescan(svar)",
201 "The difference between execute(sv1) and rescan(sv2) "
202 "is that sv1 must be a valid expression,\n\t\t\tbut sv2 can "
203 "contain zero or more expressions. "},
204 {"include_path", do_include_path, "include_path(path)",
205 "Specify an optional path to be prepended to a filename when opening a file.\n\t\t\tCan "
206 "also be "
207 "specified via the -I command line option when executing aprepro."},
208 {"Units", do_Units, "Units(svar)",
209 "See manual. svar is one of the defined units "
210 "systems:\n\t\t\t'si', 'cgs', 'cgs-ev', 'shock', 'swap', "
211 "'ft-lbf-s', 'ft-lbm-s', 'in-lbf-s'"},
212 {"delete", do_delete, "delete(var_name)", "Delete the variable with name 'var_name'."},
213 {"if", do_str_if, "if(x)",
214 "Handles the if statements. x can be any valid expression; nonzero is true"},
215 {"If", do_str_if, "If(x)",
216 "Handles the if statements. x can be any valid expression; nonzero is true"},
217 {"elseif", do_str_elseif, "elseif(x)",
218 "Handles the if statements. x can be any valid expression; nonzero is true"},
219 {"Elseif", do_str_elseif, "Elseif(x)",
220 "Handles the if statements. x can be any valid expression; nonzero is true"},
221 {"_ifdef", do_str_if, "ifdef(x)",
222 "Handles the if statements. x can be any valid expression; "
223 "nonzero is true (deprecated, use if)"},
224 {"_ifndef", do_str_notif, "ifndef(x)",
225 "Handles the if statements. x can be any valid "
226 "expression; nonzero is true (deprecated, use if)"},
227 #if defined(EXODUS_SUPPORT)
228 {"exodus_meta", do_exodus_meta, "exodus_meta(filename)",
229 "Creates several variables and arrays related to the exodus metadata in the specified "
230 "file. "},
231 {"exodus_query_change_sets", do_exodus_query_change_sets,
232 "exodus_query_change_sets(filename)",
233 "Open the file and determine whether there are any change sets on the file."
234 "It will define the `ex_change_set_count`, and `ex_change_set_names` variables."},
235 #endif
236 {nullptr, nullptr, nullptr, nullptr}};
237
238 const str_cd_init string_cd_fncts[] = {
239 #if defined(EXODUS_SUPPORT)
240 {"exodus_meta", do_exodus_meta_cd, "exodus_meta(filename, cs_index)",
241 "Creates several variables and arrays related to the exodus metadata in the `cs_indexth` "
242 "change set in file. "},
243 #endif
244 {nullptr, nullptr, nullptr, nullptr}};
245
246 const str_d_init string_d_fncts[] = {
247 {"IO", do_intout, "IO(x)", "Convert x to an integer and then to a string. "},
248 {"to_string", do_tostring, "to_string(x)",
249 "Returns a string representation of the numerical variable x. The variable x is unchanged."},
250 {"tostring", do_tostring, "tostring(x)",
251 "Returns a string representation of the numerical variable x. The variable x is unchanged."},
252 {"if", do_if, "if(x)",
253 "Handles the if statements. x can be any valid expression; nonzero is true"},
254 {"If", do_if, "If(x)",
255 "Handles the if statements. x can be any valid expression; nonzero is true"},
256 {"elseif", do_elseif, "elseif(x)",
257 "Handles the if statements. x can be any valid expression; nonzero is true"},
258 {"Elseif", do_elseif, "Elseif(x)",
259 "Handles the if statements. x can be any valid expression; nonzero is true"},
260 {"_ifdef", do_if, "ifdef(x)",
261 "Handles the if statements. x can be any valid expression; "
262 "nonzero is true.\n\t\t\tEats leading whitespace. (deprecated, use "
263 "if)"},
264 {"_ifndef", do_notif, "ifndef(x)",
265 "Handles the if statements. x can be any valid "
266 "expression; nonzero is true.\n\t\t\tEats leading whitespace. "
267 "(deprecated, use if)"},
268 {"switch", do_switch, "switch(x)",
269 "Switch statement. Select from the following case "
270 "statements which matches 'x' and execute that one.\n\t\t\tEnd "
271 "with endswitch"},
272 {"Switch", do_switch, "Switch(x)",
273 "Switch statement. Select from the following case "
274 "statements which matches 'x' and execute that one.\n\t\t\tEnd "
275 "with endswitch"},
276 {"case", do_case, "case(x)",
277 "Switch statement. A case used in a containing switch statement."},
278 {"Case", do_case, "Case(x)",
279 "Switch statement. A case used in a containing switch statement."},
280 {nullptr, nullptr, nullptr, nullptr}};
281
282 const str_dc_init string_dc_fncts[] = {
283 {"format", do_format, "format(variable, output_format)",
284 "Print `variable` using the format specified in `output_format`"},
285 {nullptr, nullptr, nullptr, nullptr}};
286
287 const str_dcc_init string_dcc_fncts[] = {
288 {"get_word", do_get_word, "get_word(n,svar,del)",
289 "Returns a string containing the nth word of svar. The words are separated by one or more "
290 "\n\t\t\tcharacters in the string variable del "},
291 {nullptr, nullptr, nullptr, nullptr}};
292
293 const str_ccc_init string_ccc_fncts[] = {
294 {"extract", do_extract, "extract(s, b, e)",
295 "Return substring [b,e). 'b' is included; 'e' is not. If 'b' not found, return empty; If "
296 "'e' not found,\n\t\t\treturn rest of string. If 'b' empty, start at beginning; if 'e' "
297 "empty, "
298 "return rest of string."},
299 #if defined(EXODUS_SUPPORT)
300 {"exodus_info", do_exodus_info_range, "exodus_info(filename, beg, end)",
301 "Parses the info records starting after 'beg' and ending before 'end'"},
302 #endif
303 {nullptr, nullptr, nullptr, nullptr}};
304
305 const str_cc_init string_cc_fncts[] = {
306 #if defined(EXODUS_SUPPORT)
307 {"exodus_info", do_exodus_info, "exodus_info(filename, prefix)",
308 "Parses the info records that begin with 'prefix' extracted from the exodus file 'ex_fn'"},
309 #endif
310 {nullptr, nullptr, nullptr, nullptr}};
311
312 const str_a_init string_a_fncts[] = {
313 {"print_array", do_print_array, "print_array(array)", "Prints the data in the array."},
314 {nullptr, nullptr, nullptr, nullptr}};
315
316 const array_c_init array_c_fncts[] = {{"csv_array", do_csv_array1, "csv_array(filename)",
317 "Create a 2D array from the data in a csv file."},
318 {nullptr, nullptr, nullptr, nullptr}};
319
320 const array_cd_init array_cd_fncts[] = {
321 {"csv_array", do_csv_array, "csv_array(filename, [skip])",
322 "Create a 2D array from the data in a csv file optionally skipping rows."
323 " If skip is integer\n\t\t\tskip that many rows; if skip is a character, skip lines "
324 "beginning with "
325 "that character"},
326 {nullptr, nullptr, nullptr, nullptr}};
327
328 const array_cc_init array_cc_fncts[] = {
329 {"csv_array", do_csv_array2, "csv_array(filename, [skip])",
330 "Create a 2D array from the data in a csv file optionally skipping rows."
331 " If skip is integer skip that many rows; if skip is a character, skip lines beginning with "
332 "that character"},
333 {"array_from_string", do_array_from_string, "array_from_string(string, delim)",
334 "Create a 1D array from the data in a delimited string."
335 " The array double values are\n\t\t\tseparated by one or more of the characters in the "
336 "string "
337 "variable delim."},
338 {"sym_tensor_from_string", do_sym_tensor_from_string, "sym_tensor_from_string(string, delim)",
339 "Create a 3x3 symmetric array from the data in a delimited string."
340 " The six array values are\n\t\t\tseparated by one or more of the characters in the "
341 "string variable delim. Order is xx, yy, zz, xy, yz, xz."},
342 {nullptr, nullptr, nullptr, nullptr}};
343
344 const array_ddd_init array_ddd_fncts[] = {
345 {"linear_array", do_linear_array, "linear_array(init, final, count)",
346 "Create a 1D array of 'count' rows. Values linearly spaced from 'init' to 'final'."},
347 {"make_array", do_make_array_init, "make_array(rows, cols, init=0)",
348 "Create a 2D array of size 'rows' by 'cols' initialized to 'init'. 0 if not specified."},
349 {nullptr, nullptr, nullptr, nullptr}};
350
351 const array_dd_init array_dd_fncts[] = {
352 {"make_array", do_make_array, "make_array(rows, cols)",
353 "Create a 2D array of size 'rows' by 'cols' initialized to zero."},
354 {nullptr, nullptr, nullptr, nullptr}};
355
356 const array_d_init array_d_fncts[] = {
357 {"identity", do_identity, "identity(size)",
358 "Create a 2D identity array with 'size' rows and columns. Diagonal = 1.0"},
359 {nullptr, nullptr, nullptr, nullptr}};
360
361 const array_a_init array_a_fncts[] = {
362 {"transpose", do_transpose, "transpose(array)", "Return the transpose of input array"},
363 {"principal_stress", do_principal, "principal_stress(array)",
364 "Calculate principal stresses of symmetric 3x3 stress tensor (array)."},
365 {nullptr, nullptr, nullptr, nullptr}};
366
367 // clang-format off
368 const var_init variables[] = {
369 {"DEG", 57.29577951308232087680}, /* 180/pi, degrees per radian */
370 {"RAD", 0.01745329251994329576}, /* pi/180, radians per degree */
371 {"E", 2.71828182845904523536}, /* e, base of natural log */
372 {"GAMMA", 0.57721566490153286060}, /* euler-mascheroni constant */
373 {"PHI", 1.61803398874989484820}, /* golden ratio */
374 {"TAU", 6.28318530717958623200}, /* 2*PI see Tau Manifesto, http://tauday.com */
375 {"PI", 3.14159265358979323846}, /* pi */
376 {"PI_2", 1.57079632679489661923}, /* pi / 2 */
377 {"SQRT2", 1.41421356237309504880}, /* square root of 2 */
378 {"TRUE", 1},
379 {"FALSE", 0},
380 {nullptr, 0}
381 };
382 // clang-format on
383
384 const svar_init svariables[] = {{"_FORMAT", "%.10g"}, /* Default output format */
385 {"_UNITS_SYSTEM", "none"},
386 {nullptr, nullptr}};
387 /* NOTE: The current comment is stored in "_C_"
388 * Since it can be changed by user on command line, we
389 * initialize is differently than the other string variables.
390 */
391
392 #define internal_init_table(functions, func_type, sym_type) \
393 do { \
394 for (int i = 0; functions[i].fname != nullptr; i++) { \
395 symrec *ptr = putsym(functions[i].fname, sym_type, true); \
396 ptr->value.func_type = functions[i].fnct; \
397 ptr->info = functions[i].description; \
398 ptr->syntax = functions[i].syntax; \
399 } \
400 } while (0)
401
402 extern SEAMS::Aprepro *aprepro;
403
404 void Aprepro::init_table(const char *comment)
405 {
406 // clang-format off
407 internal_init_table(arith_0_fncts, fnctptr, SYMBOL_TYPE::FUNCTION);
408 internal_init_table(arith_fncts, fnctptr_d, SYMBOL_TYPE::FUNCTION);
409 internal_init_table(arith_dd_fncts, fnctptr_dd, SYMBOL_TYPE::FUNCTION);
410 internal_init_table(arith_a_fncts, fnctptr_a, SYMBOL_TYPE::FUNCTION);
411 internal_init_table(arith_dddd_fncts, fnctptr_dddd, SYMBOL_TYPE::FUNCTION);
412 internal_init_table(arith_ccc_fncts, fnctptr_ccc, SYMBOL_TYPE::FUNCTION);
413 internal_init_table(arith_cc_fncts, fnctptr_cc, SYMBOL_TYPE::FUNCTION);
414 internal_init_table(arith_c_fncts, fnctptr_c, SYMBOL_TYPE::FUNCTION);
415 internal_init_table(arith_cd_fncts, fnctptr_cd, SYMBOL_TYPE::FUNCTION);
416 internal_init_table(arith_ddd_fncts, fnctptr_ddd, SYMBOL_TYPE::FUNCTION);
417 internal_init_table(arith_dddddd_fncts, fnctptr_dddddd, SYMBOL_TYPE::FUNCTION);
418
419 internal_init_table(string_fncts, strfnct, SYMBOL_TYPE::STRING_FUNCTION);
420 internal_init_table(string_c_fncts, strfnct_c, SYMBOL_TYPE::STRING_FUNCTION);
421 internal_init_table(string_d_fncts, strfnct_d, SYMBOL_TYPE::STRING_FUNCTION);
422 internal_init_table(string_cd_fncts, strfnct_cd, SYMBOL_TYPE::STRING_FUNCTION);
423 internal_init_table(string_dc_fncts, strfnct_dc, SYMBOL_TYPE::STRING_FUNCTION);
424 internal_init_table(string_dcc_fncts, strfnct_dcc, SYMBOL_TYPE::STRING_FUNCTION);
425 internal_init_table(string_ccc_fncts, strfnct_ccc, SYMBOL_TYPE::STRING_FUNCTION);
426 internal_init_table(string_cc_fncts, strfnct_cc, SYMBOL_TYPE::STRING_FUNCTION);
427 internal_init_table(string_a_fncts, strfnct_a, SYMBOL_TYPE::STRING_FUNCTION);
428
429 internal_init_table(array_c_fncts, arrfnct_c, SYMBOL_TYPE::ARRAY_FUNCTION);
430 internal_init_table(array_cc_fncts, arrfnct_cc, SYMBOL_TYPE::ARRAY_FUNCTION);
431 internal_init_table(array_cd_fncts, arrfnct_cd, SYMBOL_TYPE::ARRAY_FUNCTION);
432 internal_init_table(array_d_fncts, arrfnct_d, SYMBOL_TYPE::ARRAY_FUNCTION);
433 internal_init_table(array_dd_fncts, arrfnct_dd, SYMBOL_TYPE::ARRAY_FUNCTION);
434 internal_init_table(array_ddd_fncts, arrfnct_ddd, SYMBOL_TYPE::ARRAY_FUNCTION);
435 internal_init_table(array_a_fncts, arrfnct_a, SYMBOL_TYPE::ARRAY_FUNCTION);
436 // clang-format on
437
438 for (int i = 0; variables[i].vname != nullptr; i++) {
439 // These should be immutable, but possible user is using them for some other purpose...
440 // For backward compatibility, keep as mutable.
441 add_variable(variables[i].vname, variables[i].value, false, true);
442 }
443
444 for (int i = 0; svariables[i].vname != nullptr; i++) {
445 add_variable(svariables[i].vname, svariables[i].value, false, true);
446 }
447
448 add_variable("_C_", comment, false, true);
449
450 std::string ap_version = SEAMS::Aprepro::version();
451 auto tokens = tokenize(ap_version, " ");
452 double ver = std::stod(tokens[0]);
453 add_variable("_VERSION_", ver, true, true);
454 }
455 } // namespace SEAMS