@sdeverywhere/parse 0.1.2 → 0.1.4
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.cjs +615 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +609 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { XmlElement } from '@rgrove/parse-xml';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Format a model variable or subscript/dimension name into a valid C identifier (with
|
|
3
5
|
* special characters converted to underscore).
|
|
@@ -30,6 +32,15 @@ declare function canonicalVarId(name: string): string;
|
|
|
30
32
|
*/
|
|
31
33
|
declare function canonicalFunctionId(name: string): string;
|
|
32
34
|
|
|
35
|
+
/** 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;
|
|
43
|
+
}
|
|
33
44
|
/** The original name of a dimension, as it appears in the model. */
|
|
34
45
|
type DimName = string;
|
|
35
46
|
/** The canonical identifier of a dimension, as it appears in generated code. */
|
|
@@ -353,6 +364,13 @@ interface Equation {
|
|
|
353
364
|
}
|
|
354
365
|
/** A complete model definition, including all defined dimensions and equations. */
|
|
355
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;
|
|
356
374
|
/** The array of all dimension definitions in the model. */
|
|
357
375
|
dimensions: DimensionDef[];
|
|
358
376
|
/** The array of all variable/equation definitions in the model. */
|
|
@@ -558,4 +576,32 @@ declare function preprocessVensimModel(input: string, options?: {
|
|
|
558
576
|
removalKeys?: string[];
|
|
559
577
|
}): PreprocessedVensimModel;
|
|
560
578
|
|
|
561
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Parse the given XMILE dimension (`<dim>`) definition and return a `DimensionDef` AST node.
|
|
581
|
+
*
|
|
582
|
+
* @param input A string containing the XMILE `<dim>` definition.
|
|
583
|
+
* @returns A `DimensionDef` AST node.
|
|
584
|
+
*/
|
|
585
|
+
declare function parseXmileDimensionDef(dimElem: XmlElement): DimensionDef;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Parse the given XMILE model definition and return a `Model` AST node.
|
|
589
|
+
*
|
|
590
|
+
* @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
|
+
* @returns A `Model` AST node.
|
|
594
|
+
*/
|
|
595
|
+
declare function parseXmileModel(input: string): Model;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Parse the given XMILE variable definition and return an array of `Equation` AST nodes
|
|
599
|
+
* corresponding to the variable definition (or definitions, in the case of a
|
|
600
|
+
* non-apply-to-all variable that is defined with an `<element>` for each subscript).
|
|
601
|
+
*
|
|
602
|
+
* @param input A string containing the XMILE equation definition.
|
|
603
|
+
* @returns An `Equation` AST node.
|
|
604
|
+
*/
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { XmlElement } from '@rgrove/parse-xml';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Format a model variable or subscript/dimension name into a valid C identifier (with
|
|
3
5
|
* special characters converted to underscore).
|
|
@@ -30,6 +32,15 @@ declare function canonicalVarId(name: string): string;
|
|
|
30
32
|
*/
|
|
31
33
|
declare function canonicalFunctionId(name: string): string;
|
|
32
34
|
|
|
35
|
+
/** 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;
|
|
43
|
+
}
|
|
33
44
|
/** The original name of a dimension, as it appears in the model. */
|
|
34
45
|
type DimName = string;
|
|
35
46
|
/** The canonical identifier of a dimension, as it appears in generated code. */
|
|
@@ -353,6 +364,13 @@ interface Equation {
|
|
|
353
364
|
}
|
|
354
365
|
/** A complete model definition, including all defined dimensions and equations. */
|
|
355
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;
|
|
356
374
|
/** The array of all dimension definitions in the model. */
|
|
357
375
|
dimensions: DimensionDef[];
|
|
358
376
|
/** The array of all variable/equation definitions in the model. */
|
|
@@ -558,4 +576,32 @@ declare function preprocessVensimModel(input: string, options?: {
|
|
|
558
576
|
removalKeys?: string[];
|
|
559
577
|
}): PreprocessedVensimModel;
|
|
560
578
|
|
|
561
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Parse the given XMILE dimension (`<dim>`) definition and return a `DimensionDef` AST node.
|
|
581
|
+
*
|
|
582
|
+
* @param input A string containing the XMILE `<dim>` definition.
|
|
583
|
+
* @returns A `DimensionDef` AST node.
|
|
584
|
+
*/
|
|
585
|
+
declare function parseXmileDimensionDef(dimElem: XmlElement): DimensionDef;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Parse the given XMILE model definition and return a `Model` AST node.
|
|
589
|
+
*
|
|
590
|
+
* @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
|
+
* @returns A `Model` AST node.
|
|
594
|
+
*/
|
|
595
|
+
declare function parseXmileModel(input: string): Model;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Parse the given XMILE variable definition and return an array of `Equation` AST nodes
|
|
599
|
+
* corresponding to the variable definition (or definitions, in the case of a
|
|
600
|
+
* non-apply-to-all variable that is defined with an `<element>` for each subscript).
|
|
601
|
+
*
|
|
602
|
+
* @param input A string containing the XMILE equation definition.
|
|
603
|
+
* @returns An `Equation` AST node.
|
|
604
|
+
*/
|
|
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 };
|