@sdeverywhere/parse 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { XmlElement } from '@rgrove/parse-xml';
2
-
1
+ import { XmlElement } from "@rgrove/parse-xml";
2
+ //#region src/_shared/canonical-id.d.ts
3
3
  /**
4
4
  * Format a model variable or subscript/dimension name into a valid C identifier (with
5
5
  * special characters converted to underscore).
@@ -10,52 +10,53 @@ import { XmlElement } from '@rgrove/parse-xml';
10
10
  * 'Variable name[DimA,B2]'), use `canonicalVarId` to convert the base variable name
11
11
  * and subscript/dimension parts to canonical form indepdendently.
12
12
  *
13
- * @param {string} name The name of the variable in the source model, e.g., "Variable name".
14
- * @returns {string} The C identifier for the given name, e.g., "_variable_name".
13
+ * @param name The name of the variable in the source model, e.g., "Variable name".
14
+ * @returns The C identifier for the given name, e.g., "_variable_name".
15
15
  */
16
- declare function canonicalId(name: string): string;
16
+ export declare function canonicalId(name: string): string;
17
17
  /**
18
18
  * Format a (subscripted or non-subscripted) model variable name into a canonical identifier,
19
19
  * (with special characters converted to underscore, and subscript/dimension parts separated
20
20
  * by commas).
21
21
  *
22
- * @param {string} name The name of the variable in the source model, e.g., "Variable name[DimA, B2]".
23
- * @returns {string} The canonical identifier for the given name, e.g., "_variable_name[_dima,_b2]".
22
+ * @param name The name of the variable in the source model, e.g., "Variable name[DimA, B2]".
23
+ * @returns The canonical identifier for the given name, e.g., "_variable_name[_dima,_b2]".
24
24
  */
25
- declare function canonicalVarId(name: string): string;
25
+ export declare function canonicalVarId(name: string): string;
26
26
  /**
27
27
  * Format a model function name into a valid C identifier (with special characters
28
28
  * converted to underscore, and the ID converted to uppercase).
29
29
  *
30
- * @param {string} name The name of the variable in the source model, e.g., "FUNCTION name".
31
- * @returns {string} The C identifier for the given name, e.g., "_FUNCTION_NAME".
30
+ * @param name The name of the variable in the source model, e.g., "FUNCTION name".
31
+ * @returns The C identifier for the given name, e.g., "_FUNCTION_NAME".
32
32
  */
33
- declare function canonicalFunctionId(name: string): string;
34
-
33
+ export declare function canonicalFunctionId(name: string): string;
34
+ //#endregion
35
+ //#region src/ast/ast-types.d.ts
35
36
  /** The simulation parameters, such as start time, end time, and time step. */
36
- interface SimulationSpec {
37
- /** The start time of the simulation. */
38
- startTime: number;
39
- /** The end time of the simulation. */
40
- endTime: number;
41
- /** The time step of the simulation. */
42
- timeStep: number;
37
+ export interface SimulationSpec {
38
+ /** The start time of the simulation. */
39
+ startTime: number;
40
+ /** The end time of the simulation. */
41
+ endTime: number;
42
+ /** The time step of the simulation. */
43
+ timeStep: number;
43
44
  }
44
45
  /** The original name of a dimension, as it appears in the model. */
45
- type DimName = string;
46
+ export type DimName = string;
46
47
  /** The canonical identifier of a dimension, as it appears in generated code. */
47
- type DimId = string;
48
+ export type DimId = string;
48
49
  /** The original name of a subscript/index, as it appears in the model. */
49
- type SubName = string;
50
+ export type SubName = string;
50
51
  /** The canonical identifier of a subscript/index, as it appears in generated code. */
51
- type SubId = string;
52
+ export type SubId = string;
52
53
  /**
53
54
  * The original name of a dimension or subscript/index, as it appears in the model.
54
55
  *
55
56
  * This type is used in cases where either a dimension or an individual subscript/index
56
57
  * can appear, and more analysis is needed to resolve the reference.
57
58
  */
58
- type DimOrSubName = string;
59
+ export type DimOrSubName = string;
59
60
  /**
60
61
  * The canonical identifier of a dimension or subscript/index, as it appears in
61
62
  * generated code.
@@ -63,7 +64,7 @@ type DimOrSubName = string;
63
64
  * This type is used in cases where either a dimension or an individual subscript/index
64
65
  * can appear, and more analysis is needed to resolve the reference.
65
66
  */
66
- type DimOrSubId = string;
67
+ export type DimOrSubId = string;
67
68
  /**
68
69
  * A reference to a dimension or an individual subscript/index, as used in a dimension
69
70
  * definition or in a variable reference inside an equation definition.
@@ -71,263 +72,263 @@ type DimOrSubId = string;
71
72
  * This type can be used in cases where either a dimension or an individual subscript/index
72
73
  * can appear, and more analysis is needed to resolve the reference.
73
74
  */
74
- interface SubscriptRef {
75
- /**
76
- * The original name of the dimension or subscript/index, as it appears in the model.
77
- */
78
- subName: DimOrSubName;
79
- /**
80
- * The canonical identifier of the dimension or subscript/index, as it appears in
81
- * generated code.
82
- */
83
- subId: DimOrSubId;
75
+ export interface SubscriptRef {
76
+ /**
77
+ * The original name of the dimension or subscript/index, as it appears in the model.
78
+ */
79
+ subName: DimOrSubName;
80
+ /**
81
+ * The canonical identifier of the dimension or subscript/index, as it appears in
82
+ * generated code.
83
+ */
84
+ subId: DimOrSubId;
84
85
  }
85
86
  /**
86
87
  * A subscript mapping, as used in a dimension definition.
87
88
  */
88
- interface SubscriptMapping {
89
- /**
90
- * The original name of the "target" dimension for the mapping, as it appears in
91
- * the model.
92
- */
93
- toDimName: DimName;
94
- /**
95
- * The canonical identifier of the "target" dimension for the mapping, as it appears
96
- * in generated code.
97
- */
98
- toDimId: DimId;
99
- /**
100
- * The mapped subscripts.
101
- */
102
- subscriptRefs: SubscriptRef[];
89
+ export interface SubscriptMapping {
90
+ /**
91
+ * The original name of the "target" dimension for the mapping, as it appears in
92
+ * the model.
93
+ */
94
+ toDimName: DimName;
95
+ /**
96
+ * The canonical identifier of the "target" dimension for the mapping, as it appears
97
+ * in generated code.
98
+ */
99
+ toDimId: DimId;
100
+ /**
101
+ * The mapped subscripts.
102
+ */
103
+ subscriptRefs: SubscriptRef[];
103
104
  }
104
105
  /**
105
106
  * A definition of a dimension (aka "subscript range" in Vensim).
106
107
  */
107
- interface DimensionDef {
108
- /**
109
- * The original name of the dimension being defined, as it appears in the model.
110
- */
111
- dimName: DimName;
112
- /**
113
- * The canonical identifier of the dimension being defined, as it appears in generated code.
114
- */
115
- dimId: DimId;
116
- /**
117
- * The original name of the family associated with the dimension being defined, as it
118
- * appears in the model.
119
- *
120
- * For a typical dimension, the family name is the same as the dimension name, but in the
121
- * case of an alias (e.g., in Vensim, `DimA <-> DimB`), this will be the name used on the
122
- * right side (e.g., `DimB`).
123
- */
124
- familyName: DimName;
125
- /**
126
- * The canonical identifier of the family associated with the dimension being defined, as
127
- * it appears in generated code.
128
- *
129
- * For a typical dimension, the family name is the same as the dimension name, but in the
130
- * case of an alias (e.g., in Vensim, `DimA <-> DimB`), this will be the ID used on the
131
- * right side (e.g., `_dimb`).
132
- */
133
- familyId: DimId;
134
- /**
135
- * The array of subscripts/indices that make up this dimension.
136
- */
137
- subscriptRefs: SubscriptRef[];
138
- /**
139
- * The array of subscript mappings, if defined for this dimension.
140
- */
141
- subscriptMappings: SubscriptMapping[];
142
- /**
143
- * The optional comment text that accompanies the dimension definition in the model.
144
- */
145
- comment?: string;
146
- /**
147
- * The optional group name, if this dimension definition is contained within a group.
148
- */
149
- group?: string;
108
+ export interface DimensionDef {
109
+ /**
110
+ * The original name of the dimension being defined, as it appears in the model.
111
+ */
112
+ dimName: DimName;
113
+ /**
114
+ * The canonical identifier of the dimension being defined, as it appears in generated code.
115
+ */
116
+ dimId: DimId;
117
+ /**
118
+ * The original name of the family associated with the dimension being defined, as it
119
+ * appears in the model.
120
+ *
121
+ * For a typical dimension, the family name is the same as the dimension name, but in the
122
+ * case of an alias (e.g., in Vensim, `DimA <-> DimB`), this will be the name used on the
123
+ * right side (e.g., `DimB`).
124
+ */
125
+ familyName: DimName;
126
+ /**
127
+ * The canonical identifier of the family associated with the dimension being defined, as
128
+ * it appears in generated code.
129
+ *
130
+ * For a typical dimension, the family name is the same as the dimension name, but in the
131
+ * case of an alias (e.g., in Vensim, `DimA <-> DimB`), this will be the ID used on the
132
+ * right side (e.g., `_dimb`).
133
+ */
134
+ familyId: DimId;
135
+ /**
136
+ * The array of subscripts/indices that make up this dimension.
137
+ */
138
+ subscriptRefs: SubscriptRef[];
139
+ /**
140
+ * The array of subscript mappings, if defined for this dimension.
141
+ */
142
+ subscriptMappings: SubscriptMapping[];
143
+ /**
144
+ * The optional comment text that accompanies the dimension definition in the model.
145
+ */
146
+ comment?: string;
147
+ /**
148
+ * The optional group name, if this dimension definition is contained within a group.
149
+ */
150
+ group?: string;
150
151
  }
151
152
  /** A number literal that appears in an expression. */
152
- interface NumberLiteral {
153
- kind: 'number';
154
- /** The numeric value. */
155
- value: number;
156
- /** The original string representation from the model. */
157
- text: string;
153
+ export interface NumberLiteral {
154
+ kind: 'number';
155
+ /** The numeric value. */
156
+ value: number;
157
+ /** The original string representation from the model. */
158
+ text: string;
158
159
  }
159
160
  /** A string literal that appears in an expression. */
160
- interface StringLiteral {
161
- kind: 'string';
162
- /** The string value without quotes. */
163
- text: string;
161
+ export interface StringLiteral {
162
+ kind: 'string';
163
+ /** The string value without quotes. */
164
+ text: string;
164
165
  }
165
166
  /** A keyword (e.g., ":NA:") that appears in an expression. */
166
- interface Keyword {
167
- kind: 'keyword';
168
- /** The original string representation from the model. */
169
- text: string;
167
+ export interface Keyword {
168
+ kind: 'keyword';
169
+ /** The original string representation from the model. */
170
+ text: string;
170
171
  }
171
172
  /** The original name of a variable, as it appears in the model. */
172
- type VariableName = string;
173
+ export type VariableName = string;
173
174
  /** The canonical identifier of a variable, as it appears in generated code. */
174
- type VariableId = string;
175
+ export type VariableId = string;
175
176
  /**
176
177
  * A reference to a variable that appears in an expression.
177
178
  */
178
- interface VariableRef {
179
- kind: 'variable-ref';
180
- /**
181
- * The original name of the variable, as it appears in the model.
182
- */
183
- varName: VariableName;
184
- /**
185
- * The canonical identifier of the variable, as it appears in generated code.
186
- */
187
- varId: VariableId;
188
- /**
189
- * The optional array of subscript/dimension references, if the referenced variable
190
- * is subscripted.
191
- */
192
- subscriptRefs?: SubscriptRef[];
179
+ export interface VariableRef {
180
+ kind: 'variable-ref';
181
+ /**
182
+ * The original name of the variable, as it appears in the model.
183
+ */
184
+ varName: VariableName;
185
+ /**
186
+ * The canonical identifier of the variable, as it appears in generated code.
187
+ */
188
+ varId: VariableId;
189
+ /**
190
+ * The optional array of subscript/dimension references, if the referenced variable
191
+ * is subscripted.
192
+ */
193
+ subscriptRefs?: SubscriptRef[];
193
194
  }
194
195
  /** An operator used in a unary expression. */
195
- type UnaryOp = '+' | '-' | ':NOT:';
196
+ export type UnaryOp = '+' | '-' | ':NOT:';
196
197
  /** A unary expression. */
197
- interface UnaryOpExpr {
198
- kind: 'unary-op';
199
- /** The operator. */
200
- op: UnaryOp;
201
- /** The child expression that the operator applies to. */
202
- expr: Expr;
198
+ export interface UnaryOpExpr {
199
+ kind: 'unary-op';
200
+ /** The operator. */
201
+ op: UnaryOp;
202
+ /** The child expression that the operator applies to. */
203
+ expr: Expr;
203
204
  }
204
205
  /** An operator used in a binary expression. */
205
- type BinaryOp = '+' | '-' | '*' | '/' | '^' | '=' | '<>' | '<' | '>' | '<=' | '>=' | ':AND:' | ':OR:';
206
+ export type BinaryOp = '+' | '-' | '*' | '/' | '^' | '=' | '<>' | '<' | '>' | '<=' | '>=' | ':AND:' | ':OR:';
206
207
  /** A binary expression. */
207
- interface BinaryOpExpr {
208
- kind: 'binary-op';
209
- /** The left-hand side child expression. */
210
- lhs: Expr;
211
- /** The operator. */
212
- op: BinaryOp;
213
- /** The right-hand side child expression. */
214
- rhs: Expr;
208
+ export interface BinaryOpExpr {
209
+ kind: 'binary-op';
210
+ /** The left-hand side child expression. */
211
+ lhs: Expr;
212
+ /** The operator. */
213
+ op: BinaryOp;
214
+ /** The right-hand side child expression. */
215
+ rhs: Expr;
215
216
  }
216
217
  /** An expression that was contained within parentheses in the original model. */
217
- interface ParensExpr {
218
- kind: 'parens';
219
- /** The child expression that was defined within parentheses. */
220
- expr: Expr;
218
+ export interface ParensExpr {
219
+ kind: 'parens';
220
+ /** The child expression that was defined within parentheses. */
221
+ expr: Expr;
221
222
  }
222
223
  /** A single (x,y) point in a lookup definition. */
223
- type LookupPoint = [number, number];
224
+ export type LookupPoint = [number, number];
224
225
  /** The range for a lookup definition. */
225
- interface LookupRange {
226
- min: LookupPoint;
227
- max: LookupPoint;
226
+ export interface LookupRange {
227
+ min: LookupPoint;
228
+ max: LookupPoint;
228
229
  }
229
230
  /** A lookup definition. */
230
- interface LookupDef {
231
- kind: 'lookup-def';
232
- /** The optional range that declares the minimum and maximum points for this lookup. */
233
- range?: LookupRange;
234
- /** The array of points that define this lookup. */
235
- points: LookupPoint[];
231
+ export interface LookupDef {
232
+ kind: 'lookup-def';
233
+ /** The optional range that declares the minimum and maximum points for this lookup. */
234
+ range?: LookupRange;
235
+ /** The array of points that define this lookup. */
236
+ points: LookupPoint[];
236
237
  }
237
238
  /**
238
239
  * A lookup call, as used in an expression. This is similar to a `FunctionCall`, except
239
240
  * that instead of a function name, there is a reference to a lookup variable, and the
240
241
  * single argument determines the x coordinate for the lookup.
241
242
  */
242
- interface LookupCall {
243
- kind: 'lookup-call';
244
- /** The reference to a lookup variable. */
245
- varRef: VariableRef;
246
- /** The single argument that determines the x coordinate for the lookup. */
247
- arg: Expr;
243
+ export interface LookupCall {
244
+ kind: 'lookup-call';
245
+ /** The reference to a lookup variable. */
246
+ varRef: VariableRef;
247
+ /** The single argument that determines the x coordinate for the lookup. */
248
+ arg: Expr;
248
249
  }
249
250
  /** The original name of a function, as it appears in the model. */
250
- type FunctionName = string;
251
+ export type FunctionName = string;
251
252
  /** The canonical identifier of a function, as it appears in generated code. */
252
- type FunctionId = string;
253
+ export type FunctionId = string;
253
254
  /** A function call, as used in an expression. */
254
- interface FunctionCall {
255
- kind: 'function-call';
256
- /**
257
- * The original name of the function, as it appears in the model.
258
- */
259
- fnName: FunctionName;
260
- /**
261
- * The canonical identifier of the function, as it appears in generated code.
262
- */
263
- fnId: FunctionId;
264
- /**
265
- * The array of argument expressions that are passed to the function.
266
- */
267
- args: Expr[];
255
+ export interface FunctionCall {
256
+ kind: 'function-call';
257
+ /**
258
+ * The original name of the function, as it appears in the model.
259
+ */
260
+ fnName: FunctionName;
261
+ /**
262
+ * The canonical identifier of the function, as it appears in generated code.
263
+ */
264
+ fnId: FunctionId;
265
+ /**
266
+ * The array of argument expressions that are passed to the function.
267
+ */
268
+ args: Expr[];
268
269
  }
269
270
  /**
270
271
  * A union type that includes all possible expression types. Each expression type includes
271
272
  * a unique `kind` property that can be used to identify the type of the expression.
272
273
  */
273
- type Expr = NumberLiteral | StringLiteral | Keyword | VariableRef | UnaryOpExpr | BinaryOpExpr | ParensExpr | LookupDef | LookupCall | FunctionCall;
274
+ export type Expr = NumberLiteral | StringLiteral | Keyword | VariableRef | UnaryOpExpr | BinaryOpExpr | ParensExpr | LookupDef | LookupCall | FunctionCall;
274
275
  /**
275
276
  * A variable definition that appears on the LHS of an equation definition. Note that
276
277
  * this is mostly the same as `VariableRef` that is used in an expression; the difference
277
278
  * is that a `VariableDef` may contain an "except" clause whereas a `VariableRef` will not.
278
279
  */
279
- interface VariableDef {
280
- kind: 'variable-def';
281
- /**
282
- * The original name of the variable, as it appears in the model.
283
- */
284
- varName: VariableName;
285
- /**
286
- * The canonical identifier of the variable, as it appears in generated code.
287
- */
288
- varId: VariableId;
289
- /**
290
- * The optional array of subscript/dimension references, if the variable is subscripted.
291
- */
292
- subscriptRefs?: SubscriptRef[];
293
- /**
294
- * The optional array of "exceptions". For example, in Vensim it is possible to express
295
- * that an equation to applies to all subscripts in a dimension except for one (or a subset),
296
- * e.g., `x[DimA] :EXCEPT: [A1] = 5`.
297
- */
298
- exceptSubscriptRefSets?: SubscriptRef[][];
280
+ export interface VariableDef {
281
+ kind: 'variable-def';
282
+ /**
283
+ * The original name of the variable, as it appears in the model.
284
+ */
285
+ varName: VariableName;
286
+ /**
287
+ * The canonical identifier of the variable, as it appears in generated code.
288
+ */
289
+ varId: VariableId;
290
+ /**
291
+ * The optional array of subscript/dimension references, if the variable is subscripted.
292
+ */
293
+ subscriptRefs?: SubscriptRef[];
294
+ /**
295
+ * The optional array of "exceptions". For example, in Vensim it is possible to express
296
+ * that an equation to applies to all subscripts in a dimension except for one (or a subset),
297
+ * e.g., `x[DimA] :EXCEPT: [A1] = 5`.
298
+ */
299
+ exceptSubscriptRefSets?: SubscriptRef[][];
299
300
  }
300
301
  /**
301
302
  * The left-hand side of an equation definition.
302
303
  */
303
- interface EquationLhs {
304
- /** The variable definition that appears on the LHS. */
305
- varDef: VariableDef;
304
+ export interface EquationLhs {
305
+ /** The variable definition that appears on the LHS. */
306
+ varDef: VariableDef;
306
307
  }
307
308
  /** The right-hand side of a typical equation that is defined with an expression. */
308
- interface EquationRhsExpr {
309
- kind: 'expr';
310
- /** The expression that appears on the right-hand side of the equation. */
311
- expr: Expr;
309
+ export interface EquationRhsExpr {
310
+ kind: 'expr';
311
+ /** The expression that appears on the right-hand side of the equation. */
312
+ expr: Expr;
312
313
  }
313
314
  /** The right-hand side of a constant list definition. */
314
- interface EquationRhsConstList {
315
- kind: 'const-list';
316
- /** The array of constant values. */
317
- constants: NumberLiteral[];
318
- /**
319
- * @hidden The original string representation from the model. This is only needed for
320
- * compatibility with the legacy parser, which includes the original string representation
321
- * including semicolons, which is used for the `modelFormula`. Ideally we could remove this
322
- * field if we fix antlr4-vensim to preserve the groupings as described above.
323
- */
324
- text: string;
315
+ export interface EquationRhsConstList {
316
+ kind: 'const-list';
317
+ /** The array of constant values. */
318
+ constants: NumberLiteral[];
319
+ /**
320
+ * @hidden The original string representation from the model. This is only needed for
321
+ * compatibility with the legacy parser, which includes the original string representation
322
+ * including semicolons, which is used for the `modelFormula`. Ideally we could remove this
323
+ * field if we fix antlr4-vensim to preserve the groupings as described above.
324
+ */
325
+ text: string;
325
326
  }
326
327
  /** The right-hand side of a "lookup variable" definition. */
327
- interface EquationRhsLookup {
328
- kind: 'lookup';
329
- /** The lookup definition that appears on the right-hand side of the variable definition. */
330
- lookupDef: LookupDef;
328
+ export interface EquationRhsLookup {
329
+ kind: 'lookup';
330
+ /** The lookup definition that appears on the right-hand side of the variable definition. */
331
+ lookupDef: LookupDef;
331
332
  }
332
333
  /**
333
334
  * The right-hand side of a "data variable" definition. In Vensim, a data variable does
@@ -335,92 +336,94 @@ interface EquationRhsLookup {
335
336
  * file, so this type is merely used to indicate the equation kind (to differentiate it
336
337
  * from other kinds of equations).
337
338
  */
338
- interface EquationRhsData {
339
- kind: 'data';
339
+ export interface EquationRhsData {
340
+ kind: 'data';
340
341
  }
341
342
  /**
342
343
  * A union type that includes all possible equation right-hand side types. Each type includes
343
344
  * a unique `kind` property that can be used to identify the type of the equation.
344
345
  */
345
- type EquationRhs = EquationRhsExpr | EquationRhsConstList | EquationRhsLookup | EquationRhsData;
346
+ export type EquationRhs = EquationRhsExpr | EquationRhsConstList | EquationRhsLookup | EquationRhsData;
346
347
  /** An equation definition. */
347
- interface Equation {
348
- /** The left-hand side of the equation. */
349
- lhs: EquationLhs;
350
- /** The right-hand side of the equation. */
351
- rhs: EquationRhs;
352
- /**
353
- * The optional units text that accompanies the equation definition in the model.
354
- */
355
- units?: string;
356
- /**
357
- * The optional comment text that accompanies the equation definition in the model.
358
- */
359
- comment?: string;
360
- /**
361
- * The optional group name, if this equation definition is contained within a group.
362
- */
363
- group?: string;
348
+ export interface Equation {
349
+ /** The left-hand side of the equation. */
350
+ lhs: EquationLhs;
351
+ /** The right-hand side of the equation. */
352
+ rhs: EquationRhs;
353
+ /**
354
+ * The optional units text that accompanies the equation definition in the model.
355
+ */
356
+ units?: string;
357
+ /**
358
+ * The optional comment text that accompanies the equation definition in the model.
359
+ */
360
+ comment?: string;
361
+ /**
362
+ * The optional group name, if this equation definition is contained within a group.
363
+ */
364
+ group?: string;
364
365
  }
365
366
  /** A complete model definition, including all defined dimensions and equations. */
366
- interface Model {
367
- /**
368
- * The simulation parameters, such as start time, end time, and time step.
369
- *
370
- * NOTE: This will be defined for XMILE models, but may be undefined for Vensim models
371
- * for which the parameters are not compile-time constants.
372
- */
373
- simulationSpec?: SimulationSpec;
374
- /** The array of all dimension definitions in the model. */
375
- dimensions: DimensionDef[];
376
- /** The array of all variable/equation definitions in the model. */
377
- equations: Equation[];
367
+ export interface Model {
368
+ /**
369
+ * The simulation parameters, such as start time, end time, and time step.
370
+ *
371
+ * NOTE: This will be defined for XMILE models, but may be undefined for Vensim models
372
+ * for which the parameters are not compile-time constants.
373
+ */
374
+ simulationSpec?: SimulationSpec;
375
+ /** The array of all dimension definitions in the model. */
376
+ dimensions: DimensionDef[];
377
+ /** The array of all variable/equation definitions in the model. */
378
+ equations: Equation[];
378
379
  }
379
-
380
+ //#endregion
381
+ //#region src/ast/print-expr.d.ts
380
382
  /**
381
383
  * @hidden This is not yet part of the public API.
382
384
  */
383
- declare function debugPrintExpr(expr: Expr, indent?: number): void;
385
+ export declare function debugPrintExpr(expr: Expr, indent?: number): void;
384
386
  /**
385
387
  * @hidden This is not yet part of the public API.
386
388
  */
387
- type FormatVariableRefFunc = (varRef: VariableRef) => string;
389
+ export type FormatVariableRefFunc = (varRef: VariableRef) => string;
388
390
  /**
389
391
  * @hidden This is not yet part of the public API.
390
392
  */
391
- interface PrettyOpts {
392
- /**
393
- * Whether to use a compact representation without additional spaces. (The compact form mimics
394
- * the behavior of the legacy parser.
395
- */
396
- compact?: boolean;
397
- html?: boolean;
398
- formatVariableRef?: FormatVariableRefFunc;
393
+ export interface PrettyOpts {
394
+ /**
395
+ * Whether to use a compact representation without additional spaces. (The compact form mimics
396
+ * the behavior of the legacy parser.
397
+ */
398
+ compact?: boolean;
399
+ html?: boolean;
400
+ formatVariableRef?: FormatVariableRefFunc;
399
401
  }
400
402
  /**
401
403
  * @hidden This is not yet part of the public API.
402
404
  */
403
- declare function toPrettyString(expr: Expr, opts?: PrettyOpts): string;
405
+ export declare function toPrettyString(expr: Expr, opts?: PrettyOpts): string;
404
406
  /**
405
407
  * @hidden This is not yet part of the public API.
406
408
  */
407
- declare function prettyPrintExpr(expr: Expr, indent?: number): void;
409
+ export declare function prettyPrintExpr(expr: Expr, indent?: number): void;
408
410
  /**
409
411
  * @hidden This is not yet part of the public API.
410
412
  */
411
- declare function printExprStats(exprs: Expr[]): void;
412
-
413
+ export declare function printExprStats(exprs: Expr[]): void;
414
+ //#endregion
415
+ //#region src/ast/reduce-expr.d.ts
413
416
  /**
414
417
  * @hidden This is not yet part of the public API.
415
418
  */
416
- interface ReduceExprOptions {
417
- /** A callback that returns the possibly reduced expression for the referenced variable. */
418
- resolveVarRef?: (varRef: VariableRef) => Expr | undefined;
419
+ export interface ReduceExprOptions {
420
+ /** A callback that returns the possibly reduced expression for the referenced variable. */
421
+ resolveVarRef?: (varRef: VariableRef) => Expr | undefined;
419
422
  }
420
423
  /**
421
424
  * @hidden This is not yet part of the public API.
422
425
  */
423
- declare function reduceExpr(expr: Expr, opts?: ReduceExprOptions): Expr;
426
+ export declare function reduceExpr(expr: Expr, opts?: ReduceExprOptions): Expr;
424
427
  /**
425
428
  * A variant of `reduceExpr` that does not aggressively reduce the expression, but only
426
429
  * tries to eliminate the unused branch if a conditional (`IF THEN ELSE`) has a condition
@@ -432,29 +435,31 @@ declare function reduceExpr(expr: Expr, opts?: ReduceExprOptions): Expr;
432
435
  * @param opts The reduce options.
433
436
  * @returns A possibly reduced expression.
434
437
  */
435
- declare function reduceConditionals(expr: Expr, opts?: ReduceExprOptions): Expr;
436
-
438
+ export declare function reduceConditionals(expr: Expr, opts?: ReduceExprOptions): Expr;
439
+ //#endregion
440
+ //#region src/vensim/vensim-parse-context.d.ts
437
441
  /**
438
442
  * Context interface that provides access to file system resources (such as external
439
443
  * data files) that are needed when parsing a Vensim model.
440
444
  */
441
- interface VensimParseContext {
442
- /**
443
- * Called when a `GET DIRECT SUBSCRIPTS` function call is encountered when parsing a
444
- * Vensim subscript range definition. The arguments are the same as those passed
445
- * to `GET DIRECT SUBSCRIPTS` in the model, except that the enclosing quotes have
446
- * already been removed.
447
- *
448
- * @param fileName The CSV or XLS[X] file path, or an indirect tag (e.g., '?data').
449
- * @param tabOrDelimiter The tab name (for XLS[X] files) or the delimiter (for CSV files).
450
- * @param firstCell The location of the first subscript element.
451
- * @param lastCell The location of the last subscript element.
452
- * @param prefix A string that is prepended to every subscript element.
453
- * @returns An array of subscript names read from the external data file.
454
- */
455
- getDirectSubscripts(fileName: string, tabOrDelimiter: string, firstCell: string, lastCell: string, prefix: string): SubName[];
445
+ export interface VensimParseContext {
446
+ /**
447
+ * Called when a `GET DIRECT SUBSCRIPTS` function call is encountered when parsing a
448
+ * Vensim subscript range definition. The arguments are the same as those passed
449
+ * to `GET DIRECT SUBSCRIPTS` in the model, except that the enclosing quotes have
450
+ * already been removed.
451
+ *
452
+ * @param fileName The CSV or XLS[X] file path, or an indirect tag (e.g., '?data').
453
+ * @param tabOrDelimiter The tab name (for XLS[X] files) or the delimiter (for CSV files).
454
+ * @param firstCell The location of the first subscript element.
455
+ * @param lastCell The location of the last subscript element.
456
+ * @param prefix A string that is prepended to every subscript element.
457
+ * @returns An array of subscript names read from the external data file.
458
+ */
459
+ getDirectSubscripts(fileName: string, tabOrDelimiter: string, firstCell: string, lastCell: string, prefix: string): SubName[];
456
460
  }
457
-
461
+ //#endregion
462
+ //#region src/vensim/parse-vensim-subscript-range.d.ts
458
463
  /**
459
464
  * Parse the given Vensim subscript range definition and return a `DimensionDef` AST node.
460
465
  *
@@ -463,24 +468,27 @@ interface VensimParseContext {
463
468
  * external data files) that are referenced during the parse phase.
464
469
  * @returns A `DimensionDef` AST node.
465
470
  */
466
- declare function parseVensimSubscriptRange(input: string, context?: VensimParseContext): DimensionDef;
467
-
471
+ export declare function parseVensimSubscriptRange(input: string, context?: VensimParseContext): DimensionDef;
472
+ //#endregion
473
+ //#region src/vensim/parse-vensim-expr.d.ts
468
474
  /**
469
475
  * Parse the given Vensim expression definition and return an `Expr` AST node.
470
476
  *
471
477
  * @param input A string containing the Vensim expression.
472
478
  * @returns An `Expr` AST node.
473
479
  */
474
- declare function parseVensimExpr(input: string): Expr;
475
-
480
+ export declare function parseVensimExpr(input: string): Expr;
481
+ //#endregion
482
+ //#region src/vensim/parse-vensim-equation.d.ts
476
483
  /**
477
484
  * Parse the given Vensim equation definition and return an `Equation` AST node.
478
485
  *
479
486
  * @param input A string containing the Vensim equation definition.
480
487
  * @returns An `Equation` AST node.
481
488
  */
482
- declare function parseVensimEquation(input: string): Equation;
483
-
489
+ export declare function parseVensimEquation(input: string): Equation;
490
+ //#endregion
491
+ //#region src/vensim/parse-vensim-model.d.ts
484
492
  /**
485
493
  * Parse the given Vensim model definition and return a `Model` AST node.
486
494
  *
@@ -490,65 +498,66 @@ declare function parseVensimEquation(input: string): Equation;
490
498
  * @param sort Whether to sort definitions alphabetically during the preprocessing phase.
491
499
  * @returns A `Model` AST node.
492
500
  */
493
- declare function parseVensimModel(input: string, context?: VensimParseContext, sort?: boolean): Model;
494
-
501
+ export declare function parseVensimModel(input: string, context?: VensimParseContext, sort?: boolean): Model;
502
+ //#endregion
503
+ //#region src/vensim/preprocess-vensim.d.ts
495
504
  /**
496
505
  * A single Vensim definition (either a subscript range definition or an
497
506
  * equation definition). This contains the definition's text and metadata
498
507
  * that was extracted during preprocessing.
499
508
  */
500
- interface VensimDef {
501
- /**
502
- * A simplified key for the LHS of the definition, used for sorting
503
- * and/or flattening.
504
- */
505
- key: string;
506
- /**
507
- * The preprocessed equation or subscript range definition (with
508
- * units and comment replaced with `~~|`).
509
- */
510
- def: string;
511
- /**
512
- * The kind of definition; either 'eqn' for an equation containing an equals
513
- * sign, 'dim' for a dimension (subscript range) definition, or 'decl' for
514
- * all other declarations (e.g., a lookup or data variable definition).
515
- */
516
- kind: 'eqn' | 'dim' | 'decl';
517
- /**
518
- * The (1-based) line number where the definition begins.
519
- */
520
- line: number;
521
- /**
522
- * The units text.
523
- */
524
- units: string;
525
- /**
526
- * The comment text.
527
- */
528
- comment: string;
529
- /**
530
- * The optional group name, if the definition is contained within a group.
531
- */
532
- group?: string;
509
+ export interface VensimDef {
510
+ /**
511
+ * A simplified key for the LHS of the definition, used for sorting
512
+ * and/or flattening.
513
+ */
514
+ key: string;
515
+ /**
516
+ * The preprocessed equation or subscript range definition (with
517
+ * units and comment replaced with `~~|`).
518
+ */
519
+ def: string;
520
+ /**
521
+ * The kind of definition; either 'eqn' for an equation containing an equals
522
+ * sign, 'dim' for a dimension (subscript range) definition, or 'decl' for
523
+ * all other declarations (e.g., a lookup or data variable definition).
524
+ */
525
+ kind: 'eqn' | 'dim' | 'decl';
526
+ /**
527
+ * The (1-based) line number where the definition begins.
528
+ */
529
+ line: number;
530
+ /**
531
+ * The units text.
532
+ */
533
+ units: string;
534
+ /**
535
+ * The comment text.
536
+ */
537
+ comment: string;
538
+ /**
539
+ * The optional group name, if the definition is contained within a group.
540
+ */
541
+ group?: string;
533
542
  }
534
543
  /**
535
544
  * Result type for the `preprocessVensimModel` function.
536
545
  */
537
- interface PreprocessedVensimModel {
538
- /**
539
- * The preprocessed definitions that were preserved.
540
- */
541
- defs: VensimDef[];
542
- /**
543
- * The macros that were removed by the preprocessor.
544
- */
545
- removedMacros: string[];
546
- /**
547
- * The text blocks that were removed by the preprocessor. These include
548
- * unsupported functions (such as `TABBED ARRAY`) and other definitions
549
- * that were requested for removal.
550
- */
551
- removedBlocks: string[];
546
+ export interface PreprocessedVensimModel {
547
+ /**
548
+ * The preprocessed definitions that were preserved.
549
+ */
550
+ defs: VensimDef[];
551
+ /**
552
+ * The macros that were removed by the preprocessor.
553
+ */
554
+ removedMacros: string[];
555
+ /**
556
+ * The text blocks that were removed by the preprocessor. These include
557
+ * unsupported functions (such as `TABBED ARRAY`) and other definitions
558
+ * that were requested for removal.
559
+ */
560
+ removedBlocks: string[];
552
561
  }
553
562
  /**
554
563
  * Process the given Vensim model content so that it can be parsed
@@ -572,36 +581,37 @@ interface PreprocessedVensimModel {
572
581
  * @return A `PreprocessedVensimModel` instance containing the preprocessed
573
582
  * Vensim definitions.
574
583
  */
575
- declare function preprocessVensimModel(input: string, options?: {
576
- removalKeys?: string[];
584
+ export declare function preprocessVensimModel(input: string, options?: {
585
+ removalKeys?: string[];
577
586
  }): PreprocessedVensimModel;
578
-
587
+ //#endregion
588
+ //#region src/xmile/parse-xmile-dimension-def.d.ts
579
589
  /**
580
590
  * Parse the given XMILE dimension (`<dim>`) definition and return a `DimensionDef` AST node.
581
591
  *
582
- * @param input A string containing the XMILE `<dim>` definition.
592
+ * @param dimElem An `XmlElement` containing the XMILE `<dim>` definition.
583
593
  * @returns A `DimensionDef` AST node.
584
594
  */
585
- declare function parseXmileDimensionDef(dimElem: XmlElement): DimensionDef;
586
-
595
+ export declare function parseXmileDimensionDef(dimElem: XmlElement): DimensionDef;
596
+ //#endregion
597
+ //#region src/xmile/parse-xmile-model.d.ts
587
598
  /**
588
599
  * Parse the given XMILE model definition and return a `Model` AST node.
589
600
  *
590
601
  * @param input A string containing the XMILE model.
591
- * @param context An object that provides access to file system resources (such as
592
- * external data files) that are referenced during the parse phase.
593
602
  * @returns A `Model` AST node.
594
603
  */
595
- declare function parseXmileModel(input: string): Model;
596
-
604
+ export declare function parseXmileModel(input: string): Model;
605
+ //#endregion
606
+ //#region src/xmile/parse-xmile-variable-def.d.ts
597
607
  /**
598
608
  * Parse the given XMILE variable definition and return an array of `Equation` AST nodes
599
609
  * corresponding to the variable definition (or definitions, in the case of a
600
610
  * non-apply-to-all variable that is defined with an `<element>` for each subscript).
601
611
  *
602
- * @param input A string containing the XMILE equation definition.
612
+ * @param varElem An `XmlElement` containing the XMILE variable definition.
603
613
  * @returns An `Equation` AST node.
604
614
  */
605
- declare function parseXmileVariableDef(varElem: XmlElement): Equation[];
606
-
607
- export { type BinaryOp, type BinaryOpExpr, type DimId, type DimName, type DimOrSubId, type DimOrSubName, type DimensionDef, type Equation, type EquationLhs, type EquationRhs, type EquationRhsConstList, type EquationRhsData, type EquationRhsExpr, type EquationRhsLookup, type Expr, type FormatVariableRefFunc, type FunctionCall, type FunctionId, type FunctionName, type Keyword, type LookupCall, type LookupDef, type LookupPoint, type LookupRange, type Model, type NumberLiteral, type ParensExpr, type PreprocessedVensimModel, type PrettyOpts, type ReduceExprOptions, type SimulationSpec, type StringLiteral, type SubId, type SubName, type SubscriptMapping, type SubscriptRef, type UnaryOp, type UnaryOpExpr, type VariableDef, type VariableId, type VariableName, type VariableRef, type VensimDef, type VensimParseContext, canonicalFunctionId, canonicalId, canonicalVarId, debugPrintExpr, parseVensimEquation, parseVensimExpr, parseVensimModel, parseVensimSubscriptRange, parseXmileDimensionDef, parseXmileModel, parseXmileVariableDef, preprocessVensimModel, prettyPrintExpr, printExprStats, reduceConditionals, reduceExpr, toPrettyString };
615
+ export declare function parseXmileVariableDef(varElem: XmlElement): Equation[];
616
+ //#endregion
617
+ //# sourceMappingURL=index.d.ts.map