ifc-expressions 2.3.0-beta.1 → 2.3.0
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/IfcExpression.d.ts +7 -1
- package/dist/cjs/IfcExpression.js +11 -1
- package/dist/cjs/IfcExpression.js.map +1 -1
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/mjs/IfcExpression.js +6 -1
- package/dist/mjs/IfcExpression.js.map +1 -1
- package/dist/mjs/index.js +3 -0
- package/dist/mjs/index.js.map +1 -0
- package/package.json +6 -6
package/dist/IfcExpression.d.ts
CHANGED
|
@@ -31,7 +31,13 @@ import { IfcDateValue } from "./value/IfcDateValue.js";
|
|
|
31
31
|
import { IfcDateTimeValue } from "./value/IfcDateTimeValue.js";
|
|
32
32
|
import { IfcTimeValue } from "./value/IfcTimeValue.js";
|
|
33
33
|
import { IfcTimeStampValue } from "./value/IfcTimeStampValue.js";
|
|
34
|
-
|
|
34
|
+
import { ArrayType } from "./type/ArrayType.js";
|
|
35
|
+
import { ExprType } from "./type/ExprType.js";
|
|
36
|
+
import { SimpleType } from "./type/SimpleType.js";
|
|
37
|
+
import { TupleType } from "./type/TupleType.js";
|
|
38
|
+
import { TypeDisjunction } from "./type/TypeDisjunction.js";
|
|
39
|
+
import { Types } from "./type/Types.js";
|
|
40
|
+
export { IfcElementAccessor, IfcExpressionContext, Value, StringValue, BooleanValue, LogicalValue, NumericValue, ExpressionValue, ReferenceValue, IfcDateValue, IfcDateTimeValue, IfcTimeValue, IfcDurationValue, IfcTimeStampValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ObjectAccessor, Expr, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, ExprEvalResult, ExprEvalError, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, ArrayType, ExprType, SimpleType, TupleType, TypeDisjunction, Types, };
|
|
35
41
|
export type { BoxedValueTypes };
|
|
36
42
|
export declare class IfcExpressionParseResult {
|
|
37
43
|
private readonly _input;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IfcExpression = exports.IfcExpressionParseResult = exports.ExprFacade = exports.ExprToTextInputLinker = exports.isExprEvalSuccess = exports.isExprEvalError = exports.isNullish = exports.isPresent = exports.IfcExpressionVisitor = exports.IfcExpressionErrorListener = exports.IfcExpressionEvaluationException = exports.ExprKind = exports.ExprCompiler = exports.NamedObjectAccessor = exports.IfcTypeObjectAccessor = exports.IfcRootObjectAccessor = exports.IfcPropertyAccessor = exports.IfcPropertySetAccessor = exports.IfcTimeStampValue = exports.IfcDurationValue = exports.IfcTimeValue = exports.IfcDateTimeValue = exports.IfcDateValue = exports.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = void 0;
|
|
6
|
+
exports.IfcExpression = exports.IfcExpressionParseResult = exports.Types = exports.TypeDisjunction = exports.TupleType = exports.SimpleType = exports.ArrayType = exports.ExprFacade = exports.ExprToTextInputLinker = exports.isExprEvalSuccess = exports.isExprEvalError = exports.isNullish = exports.isPresent = exports.IfcExpressionVisitor = exports.IfcExpressionErrorListener = exports.IfcExpressionEvaluationException = exports.ExprKind = exports.ExprCompiler = exports.NamedObjectAccessor = exports.IfcTypeObjectAccessor = exports.IfcRootObjectAccessor = exports.IfcPropertyAccessor = exports.IfcPropertySetAccessor = exports.IfcTimeStampValue = exports.IfcDurationValue = exports.IfcTimeValue = exports.IfcDateTimeValue = exports.IfcDateValue = exports.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = void 0;
|
|
7
7
|
const antlr4_1 = require("antlr4");
|
|
8
8
|
const ExprCompiler_js_1 = require("./compiler/ExprCompiler.js");
|
|
9
9
|
Object.defineProperty(exports, "ExprCompiler", { enumerable: true, get: function () { return ExprCompiler_js_1.ExprCompiler; } });
|
|
@@ -63,6 +63,16 @@ const IfcTimeValue_js_1 = require("./value/IfcTimeValue.js");
|
|
|
63
63
|
Object.defineProperty(exports, "IfcTimeValue", { enumerable: true, get: function () { return IfcTimeValue_js_1.IfcTimeValue; } });
|
|
64
64
|
const IfcTimeStampValue_js_1 = require("./value/IfcTimeStampValue.js");
|
|
65
65
|
Object.defineProperty(exports, "IfcTimeStampValue", { enumerable: true, get: function () { return IfcTimeStampValue_js_1.IfcTimeStampValue; } });
|
|
66
|
+
const ArrayType_js_1 = require("./type/ArrayType.js");
|
|
67
|
+
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return ArrayType_js_1.ArrayType; } });
|
|
68
|
+
const SimpleType_js_1 = require("./type/SimpleType.js");
|
|
69
|
+
Object.defineProperty(exports, "SimpleType", { enumerable: true, get: function () { return SimpleType_js_1.SimpleType; } });
|
|
70
|
+
const TupleType_js_1 = require("./type/TupleType.js");
|
|
71
|
+
Object.defineProperty(exports, "TupleType", { enumerable: true, get: function () { return TupleType_js_1.TupleType; } });
|
|
72
|
+
const TypeDisjunction_js_1 = require("./type/TypeDisjunction.js");
|
|
73
|
+
Object.defineProperty(exports, "TypeDisjunction", { enumerable: true, get: function () { return TypeDisjunction_js_1.TypeDisjunction; } });
|
|
74
|
+
const Types_js_1 = require("./type/Types.js");
|
|
75
|
+
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return Types_js_1.Types; } });
|
|
66
76
|
class IfcExpressionParseResult {
|
|
67
77
|
constructor(input, typeManager, exprContext) {
|
|
68
78
|
this._typeManager = typeManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IfcExpression.ts"],"names":[],"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AI,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;aACpC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,IAAiC,EACjC,UAAgC,IAAI,0BAAU,EAAE;QAEhD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF;AAjHD,sCAiHC","file":"IfcExpression.js","sourcesContent":["import {\n CharStream,\n CommonTokenStream,\n ErrorListener,\n ParserRuleContext,\n ParseTreeWalker,\n Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n ExprEvalError,\n ExprEvalResult,\n isExprEvalError,\n isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\nimport { IfcDurationValue } from \"./value/IfcDurationValue\";\nimport { IfcDateValue } from \"./value/IfcDateValue.js\";\nimport { IfcDateTimeValue } from \"./value/IfcDateTimeValue.js\";\nimport { IfcTimeValue } from \"./value/IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./value/IfcTimeStampValue.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n private readonly _input: string;\n private readonly _typeManager: TypeManager;\n private readonly _parseTree: ParserRuleContext;\n\n constructor(input: string, typeManager: TypeManager, exprContext) {\n this._typeManager = typeManager;\n this._parseTree = exprContext;\n this._input = input;\n }\n\n get typeManager(): TypeManager {\n return this._typeManager;\n }\n\n get parseTree(): ParserRuleContext {\n return this._parseTree;\n }\n\n get input(): string {\n return this._input;\n }\n}\n\nexport class IfcExpression {\n /**\n * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n * @param input\n * @param errorListener\n * @return the parse result, which can subequently be compiled into an Expr using compile().\n */\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token | number>\n ): IfcExpressionParseResult {\n const chars = new CharStream(input); // replace this with a FileStream as required\n const lexer = new IfcExpressionLexer(chars);\n const tokens = new CommonTokenStream(lexer);\n const parser = new IfcExpressionParser(tokens);\n lexer.removeErrorListeners();\n parser.removeErrorListeners();\n const myErrorListener = new IfcExpressionErrorListener();\n if (isPresent(errorListener)) {\n lexer.addErrorListener(errorListener);\n parser.addErrorListener(errorListener);\n }\n lexer.addErrorListener(myErrorListener);\n parser.addErrorListener(myErrorListener);\n let expr;\n expr = parser.expr();\n const validationListener = new IfcExpressionValidationListener();\n if (!myErrorListener.isErrorOccurred()) {\n const walker = new ParseTreeWalker();\n try {\n walker.walk(validationListener, expr);\n } catch (e) {\n if (e instanceof ValidationException) {\n if (errorListener instanceof IfcExpressionErrorListener) {\n errorListener.validationException(e);\n }\n myErrorListener.validationException(e);\n }\n }\n }\n return new IfcExpressionParseResult(\n input,\n validationListener.getTypeManager(),\n expr\n );\n }\n\n /**\n * Compiles the specified parseResult into an Expr.\n * @param parseResult\n * @return the Expression (Expr), which can be evaluated to obtain its result.\n */\n public static compile(\n parseResult: IfcExpressionParseResult\n ): ExprFacade<ExpressionValue> {\n const compiler = new ExprCompiler(parseResult.typeManager);\n const expr = compiler.visit(parseResult.parseTree);\n ExprToTextInputLinker.linkTextToExpressions(\n parseResult.input,\n expr,\n compiler.getExprManager()\n );\n return new ExprFacade(expr);\n }\n\n /**\n * Evaluates the specified input expression and returns the evaluation result. The parse\n * and compile steps are done internally.\n *\n * @param expression: the input expression\n * @param context: the context required for accessing the IFC model\n * @return the result (or an error object).\n */\n public static evaluate(\n expression: string,\n context: IfcExpressionContext = new NopContext()\n ): ExprEvalResult<ExpressionValue> {\n const errorListener = new IfcExpressionErrorListener();\n const parseResult = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n return mapException(errorListener.getException());\n }\n const compiledExpression = this.compile(parseResult);\n return compiledExpression.evaluate(context);\n }\n\n public static formatError(input: string, error: ExprEvalError) {\n const lines = [\"** Error **\"];\n if (!isNullish(error[\"textSpan\"])) {\n const span: TextSpan = error[\"textSpan\"];\n const underlined = span.underline(input, \"^\");\n const startString = \"Input: \";\n const indented = this.indent(underlined, startString.length);\n const replaced = startString + indented.substr(startString.length);\n replaced.split(\"\\n\").forEach((line) => lines.push(line));\n }\n lines.push(\"Problem: \" + error.message);\n return lines.join(\"\\n\");\n }\n\n private static indent(s: string, by: number) {\n return s\n .split(\"\\n\")\n .map((line) => \" \".repeat(by) + line)\n .join(\"\\n\");\n }\n\n public static evaluateExpression(\n expr: ExprFacade<ExpressionValue>,\n context: IfcExpressionContext = new NopContext()\n ) {\n return expr.evaluate(context);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/IfcExpression.ts"],"names":[],"mappings":";;;;;;AAAA,mCAOgB;AAChB,gEAA0D;AA2ExD,6FA3EO,8BAAY,OA2EP;AA1Ed,mFAA6E;AA6E3E,2GA7EO,0DAA0B,OA6EP;AA5E5B,sGAAgG;AAEhG,wEAAoE;AA6ElE,0FA7EO,iCAAS,OA6EP;AADT,0FA5EkB,iCAAS,OA4ElB;AAxEX,2EAAqE;AA8CnE,mGA9CO,0CAAkB,OA8CP;AA5CpB,2DAAqD;AA+CnD,4FA/CO,4BAAW,OA+CP;AA9Cb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C;aACpC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,IAAiC,EACjC,UAAgC,IAAI,0BAAU,EAAE;QAEhD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF;AAjHD,sCAiHC","file":"IfcExpression.js","sourcesContent":["import {\n CharStream,\n CommonTokenStream,\n ErrorListener,\n ParserRuleContext,\n ParseTreeWalker,\n Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n ExprEvalError,\n ExprEvalResult,\n isExprEvalError,\n isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\nimport { IfcDurationValue } from \"./value/IfcDurationValue\";\nimport { IfcDateValue } from \"./value/IfcDateValue.js\";\nimport { IfcDateTimeValue } from \"./value/IfcDateTimeValue.js\";\nimport { IfcTimeValue } from \"./value/IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./value/IfcTimeStampValue.js\";\nimport { ArrayType } from \"./type/ArrayType.js\";\nimport { ExprType } from \"./type/ExprType.js\";\nimport { SimpleType } from \"./type/SimpleType.js\";\nimport { TupleType } from \"./type/TupleType.js\";\nimport { TypeDisjunction } from \"./type/TypeDisjunction.js\";\nimport { Types } from \"./type/Types.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n ArrayType,\n ExprType,\n SimpleType,\n TupleType,\n TypeDisjunction,\n Types,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n private readonly _input: string;\n private readonly _typeManager: TypeManager;\n private readonly _parseTree: ParserRuleContext;\n\n constructor(input: string, typeManager: TypeManager, exprContext) {\n this._typeManager = typeManager;\n this._parseTree = exprContext;\n this._input = input;\n }\n\n get typeManager(): TypeManager {\n return this._typeManager;\n }\n\n get parseTree(): ParserRuleContext {\n return this._parseTree;\n }\n\n get input(): string {\n return this._input;\n }\n}\n\nexport class IfcExpression {\n /**\n * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n * @param input\n * @param errorListener\n * @return the parse result, which can subequently be compiled into an Expr using compile().\n */\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token | number>\n ): IfcExpressionParseResult {\n const chars = new CharStream(input); // replace this with a FileStream as required\n const lexer = new IfcExpressionLexer(chars);\n const tokens = new CommonTokenStream(lexer);\n const parser = new IfcExpressionParser(tokens);\n lexer.removeErrorListeners();\n parser.removeErrorListeners();\n const myErrorListener = new IfcExpressionErrorListener();\n if (isPresent(errorListener)) {\n lexer.addErrorListener(errorListener);\n parser.addErrorListener(errorListener);\n }\n lexer.addErrorListener(myErrorListener);\n parser.addErrorListener(myErrorListener);\n let expr;\n expr = parser.expr();\n const validationListener = new IfcExpressionValidationListener();\n if (!myErrorListener.isErrorOccurred()) {\n const walker = new ParseTreeWalker();\n try {\n walker.walk(validationListener, expr);\n } catch (e) {\n if (e instanceof ValidationException) {\n if (errorListener instanceof IfcExpressionErrorListener) {\n errorListener.validationException(e);\n }\n myErrorListener.validationException(e);\n }\n }\n }\n return new IfcExpressionParseResult(\n input,\n validationListener.getTypeManager(),\n expr\n );\n }\n\n /**\n * Compiles the specified parseResult into an Expr.\n * @param parseResult\n * @return the Expression (Expr), which can be evaluated to obtain its result.\n */\n public static compile(\n parseResult: IfcExpressionParseResult\n ): ExprFacade<ExpressionValue> {\n const compiler = new ExprCompiler(parseResult.typeManager);\n const expr = compiler.visit(parseResult.parseTree);\n ExprToTextInputLinker.linkTextToExpressions(\n parseResult.input,\n expr,\n compiler.getExprManager()\n );\n return new ExprFacade(expr);\n }\n\n /**\n * Evaluates the specified input expression and returns the evaluation result. The parse\n * and compile steps are done internally.\n *\n * @param expression: the input expression\n * @param context: the context required for accessing the IFC model\n * @return the result (or an error object).\n */\n public static evaluate(\n expression: string,\n context: IfcExpressionContext = new NopContext()\n ): ExprEvalResult<ExpressionValue> {\n const errorListener = new IfcExpressionErrorListener();\n const parseResult = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n return mapException(errorListener.getException());\n }\n const compiledExpression = this.compile(parseResult);\n return compiledExpression.evaluate(context);\n }\n\n public static formatError(input: string, error: ExprEvalError) {\n const lines = [\"** Error **\"];\n if (!isNullish(error[\"textSpan\"])) {\n const span: TextSpan = error[\"textSpan\"];\n const underlined = span.underline(input, \"^\");\n const startString = \"Input: \";\n const indented = this.indent(underlined, startString.length);\n const replaced = startString + indented.substr(startString.length);\n replaced.split(\"\\n\").forEach((line) => lines.push(line));\n }\n lines.push(\"Problem: \" + error.message);\n return lines.join(\"\\n\");\n }\n\n private static indent(s: string, by: number) {\n return s\n .split(\"\\n\")\n .map((line) => \" \".repeat(by) + line)\n .join(\"\\n\");\n }\n\n public static evaluateExpression(\n expr: ExprFacade<ExpressionValue>,\n context: IfcExpressionContext = new NopContext()\n ) {\n return expr.evaluate(context);\n }\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.E = exports.Types = exports.TypeDisjunction = exports.TupleType = exports.SimpleType = exports.ArrayType = exports.ExprFacade = exports.ExprToTextInputLinker = exports.isExprEvalSuccess = exports.isExprEvalError = exports.isNullish = exports.isPresent = exports.IfcExpressionVisitor = exports.IfcExpressionErrorListener = exports.IfcExpressionEvaluationException = exports.ExprKind = exports.ExprCompiler = exports.NamedObjectAccessor = exports.IfcTypeObjectAccessor = exports.IfcRootObjectAccessor = exports.IfcPropertyAccessor = exports.IfcPropertySetAccessor = exports.IfcTimeStampValue = exports.IfcDurationValue = exports.IfcTimeValue = exports.IfcDateTimeValue = exports.IfcDateValue = exports.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = exports.IfcExpressionParseResult = exports.IfcExpression = void 0;
|
|
4
|
+
var IfcExpression_js_1 = require("./IfcExpression.js");
|
|
5
|
+
Object.defineProperty(exports, "IfcExpression", { enumerable: true, get: function () { return IfcExpression_js_1.IfcExpression; } });
|
|
6
|
+
Object.defineProperty(exports, "IfcExpressionParseResult", { enumerable: true, get: function () { return IfcExpression_js_1.IfcExpressionParseResult; } });
|
|
7
|
+
Object.defineProperty(exports, "IfcElementAccessor", { enumerable: true, get: function () { return IfcExpression_js_1.IfcElementAccessor; } });
|
|
8
|
+
Object.defineProperty(exports, "StringValue", { enumerable: true, get: function () { return IfcExpression_js_1.StringValue; } });
|
|
9
|
+
Object.defineProperty(exports, "BooleanValue", { enumerable: true, get: function () { return IfcExpression_js_1.BooleanValue; } });
|
|
10
|
+
Object.defineProperty(exports, "LogicalValue", { enumerable: true, get: function () { return IfcExpression_js_1.LogicalValue; } });
|
|
11
|
+
Object.defineProperty(exports, "NumericValue", { enumerable: true, get: function () { return IfcExpression_js_1.NumericValue; } });
|
|
12
|
+
Object.defineProperty(exports, "ReferenceValue", { enumerable: true, get: function () { return IfcExpression_js_1.ReferenceValue; } });
|
|
13
|
+
Object.defineProperty(exports, "IfcDateValue", { enumerable: true, get: function () { return IfcExpression_js_1.IfcDateValue; } });
|
|
14
|
+
Object.defineProperty(exports, "IfcDateTimeValue", { enumerable: true, get: function () { return IfcExpression_js_1.IfcDateTimeValue; } });
|
|
15
|
+
Object.defineProperty(exports, "IfcTimeValue", { enumerable: true, get: function () { return IfcExpression_js_1.IfcTimeValue; } });
|
|
16
|
+
Object.defineProperty(exports, "IfcDurationValue", { enumerable: true, get: function () { return IfcExpression_js_1.IfcDurationValue; } });
|
|
17
|
+
Object.defineProperty(exports, "IfcTimeStampValue", { enumerable: true, get: function () { return IfcExpression_js_1.IfcTimeStampValue; } });
|
|
18
|
+
Object.defineProperty(exports, "IfcPropertySetAccessor", { enumerable: true, get: function () { return IfcExpression_js_1.IfcPropertySetAccessor; } });
|
|
19
|
+
Object.defineProperty(exports, "IfcPropertyAccessor", { enumerable: true, get: function () { return IfcExpression_js_1.IfcPropertyAccessor; } });
|
|
20
|
+
Object.defineProperty(exports, "IfcRootObjectAccessor", { enumerable: true, get: function () { return IfcExpression_js_1.IfcRootObjectAccessor; } });
|
|
21
|
+
Object.defineProperty(exports, "IfcTypeObjectAccessor", { enumerable: true, get: function () { return IfcExpression_js_1.IfcTypeObjectAccessor; } });
|
|
22
|
+
Object.defineProperty(exports, "NamedObjectAccessor", { enumerable: true, get: function () { return IfcExpression_js_1.NamedObjectAccessor; } });
|
|
23
|
+
Object.defineProperty(exports, "ExprCompiler", { enumerable: true, get: function () { return IfcExpression_js_1.ExprCompiler; } });
|
|
24
|
+
Object.defineProperty(exports, "ExprKind", { enumerable: true, get: function () { return IfcExpression_js_1.ExprKind; } });
|
|
25
|
+
Object.defineProperty(exports, "IfcExpressionEvaluationException", { enumerable: true, get: function () { return IfcExpression_js_1.IfcExpressionEvaluationException; } });
|
|
26
|
+
Object.defineProperty(exports, "IfcExpressionErrorListener", { enumerable: true, get: function () { return IfcExpression_js_1.IfcExpressionErrorListener; } });
|
|
27
|
+
Object.defineProperty(exports, "IfcExpressionVisitor", { enumerable: true, get: function () { return IfcExpression_js_1.IfcExpressionVisitor; } });
|
|
28
|
+
Object.defineProperty(exports, "isPresent", { enumerable: true, get: function () { return IfcExpression_js_1.isPresent; } });
|
|
29
|
+
Object.defineProperty(exports, "isNullish", { enumerable: true, get: function () { return IfcExpression_js_1.isNullish; } });
|
|
30
|
+
Object.defineProperty(exports, "isExprEvalError", { enumerable: true, get: function () { return IfcExpression_js_1.isExprEvalError; } });
|
|
31
|
+
Object.defineProperty(exports, "isExprEvalSuccess", { enumerable: true, get: function () { return IfcExpression_js_1.isExprEvalSuccess; } });
|
|
32
|
+
Object.defineProperty(exports, "ExprToTextInputLinker", { enumerable: true, get: function () { return IfcExpression_js_1.ExprToTextInputLinker; } });
|
|
33
|
+
Object.defineProperty(exports, "ExprFacade", { enumerable: true, get: function () { return IfcExpression_js_1.ExprFacade; } });
|
|
34
|
+
Object.defineProperty(exports, "ArrayType", { enumerable: true, get: function () { return IfcExpression_js_1.ArrayType; } });
|
|
35
|
+
Object.defineProperty(exports, "SimpleType", { enumerable: true, get: function () { return IfcExpression_js_1.SimpleType; } });
|
|
36
|
+
Object.defineProperty(exports, "TupleType", { enumerable: true, get: function () { return IfcExpression_js_1.TupleType; } });
|
|
37
|
+
Object.defineProperty(exports, "TypeDisjunction", { enumerable: true, get: function () { return IfcExpression_js_1.TypeDisjunction; } });
|
|
38
|
+
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return IfcExpression_js_1.Types; } });
|
|
39
|
+
var E_js_1 = require("./E.js");
|
|
40
|
+
Object.defineProperty(exports, "E", { enumerable: true, get: function () { return E_js_1.E; } });
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDA2C4B;AA1C1B,iHAAA,aAAa,OAAA;AACb,4HAAA,wBAAwB,OAAA;AACxB,sHAAA,kBAAkB,OAAA;AAGlB,+GAAA,WAAW,OAAA;AACX,gHAAA,YAAY,OAAA;AACZ,gHAAA,YAAY,OAAA;AACZ,gHAAA,YAAY,OAAA;AAEZ,kHAAA,cAAc,OAAA;AACd,gHAAA,YAAY,OAAA;AACZ,oHAAA,gBAAgB,OAAA;AAChB,gHAAA,YAAY,OAAA;AACZ,oHAAA,gBAAgB,OAAA;AAChB,qHAAA,iBAAiB,OAAA;AACjB,0HAAA,sBAAsB,OAAA;AACtB,uHAAA,mBAAmB,OAAA;AACnB,yHAAA,qBAAqB,OAAA;AACrB,yHAAA,qBAAqB,OAAA;AACrB,uHAAA,mBAAmB,OAAA;AAGnB,gHAAA,YAAY,OAAA;AACZ,4GAAA,QAAQ,OAAA;AACR,oIAAA,gCAAgC,OAAA;AAChC,8HAAA,0BAA0B,OAAA;AAC1B,wHAAA,oBAAoB,OAAA;AACpB,6GAAA,SAAS,OAAA;AACT,6GAAA,SAAS,OAAA;AAGT,mHAAA,eAAe,OAAA;AACf,qHAAA,iBAAiB,OAAA;AACjB,yHAAA,qBAAqB,OAAA;AACrB,8GAAA,UAAU,OAAA;AAEV,6GAAA,SAAS,OAAA;AACT,8GAAA,UAAU,OAAA;AACV,6GAAA,SAAS,OAAA;AACT,mHAAA,eAAe,OAAA;AACf,yGAAA,KAAK,OAAA;AAKP,+BAA2B;AAAlB,yFAAA,CAAC,OAAA","file":"index.js","sourcesContent":["export {\n IfcExpression,\n IfcExpressionParseResult,\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n ExprType,\n ArrayType,\n SimpleType,\n TupleType,\n TypeDisjunction,\n Types,\n} from \"./IfcExpression.js\";\n\nexport type { BoxedValueTypes } from \"./IfcExpression.js\";\n\nexport { E } from \"./E.js\";\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { IfcExpression, IfcExpressionParseResult, IfcElementAccessor, IfcExpressionContext, Value, StringValue, BooleanValue, LogicalValue, NumericValue, ExpressionValue, ReferenceValue, IfcDateValue, IfcDateTimeValue, IfcTimeValue, IfcDurationValue, IfcTimeStampValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ObjectAccessor, Expr, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, ExprEvalResult, ExprEvalError, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, ExprType, ArrayType, SimpleType, TupleType, TypeDisjunction, Types, } from "./IfcExpression.js";
|
|
2
|
+
export type { BoxedValueTypes } from "./IfcExpression.js";
|
|
3
|
+
export { E } from "./E.js";
|
|
@@ -30,7 +30,12 @@ import { IfcDateValue } from "./value/IfcDateValue.js";
|
|
|
30
30
|
import { IfcDateTimeValue } from "./value/IfcDateTimeValue.js";
|
|
31
31
|
import { IfcTimeValue } from "./value/IfcTimeValue.js";
|
|
32
32
|
import { IfcTimeStampValue } from "./value/IfcTimeStampValue.js";
|
|
33
|
-
|
|
33
|
+
import { ArrayType } from "./type/ArrayType.js";
|
|
34
|
+
import { SimpleType } from "./type/SimpleType.js";
|
|
35
|
+
import { TupleType } from "./type/TupleType.js";
|
|
36
|
+
import { TypeDisjunction } from "./type/TypeDisjunction.js";
|
|
37
|
+
import { Types } from "./type/Types.js";
|
|
38
|
+
export { IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcDateValue, IfcDateTimeValue, IfcTimeValue, IfcDurationValue, IfcTimeStampValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, ArrayType, SimpleType, TupleType, TypeDisjunction, Types, };
|
|
34
39
|
export class IfcExpressionParseResult {
|
|
35
40
|
constructor(input, typeManager, exprContext) {
|
|
36
41
|
this._typeManager = typeManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["IfcExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EAGjB,eAAe,GAEhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,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,IAAiC,EACjC,UAAgC,IAAI,UAAU,EAAE;QAEhD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF","file":"IfcExpression.js","sourcesContent":["import {\n CharStream,\n CommonTokenStream,\n ErrorListener,\n ParserRuleContext,\n ParseTreeWalker,\n Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n ExprEvalError,\n ExprEvalResult,\n isExprEvalError,\n isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\nimport { IfcDurationValue } from \"./value/IfcDurationValue\";\nimport { IfcDateValue } from \"./value/IfcDateValue.js\";\nimport { IfcDateTimeValue } from \"./value/IfcDateTimeValue.js\";\nimport { IfcTimeValue } from \"./value/IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./value/IfcTimeStampValue.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n private readonly _input: string;\n private readonly _typeManager: TypeManager;\n private readonly _parseTree: ParserRuleContext;\n\n constructor(input: string, typeManager: TypeManager, exprContext) {\n this._typeManager = typeManager;\n this._parseTree = exprContext;\n this._input = input;\n }\n\n get typeManager(): TypeManager {\n return this._typeManager;\n }\n\n get parseTree(): ParserRuleContext {\n return this._parseTree;\n }\n\n get input(): string {\n return this._input;\n }\n}\n\nexport class IfcExpression {\n /**\n * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n * @param input\n * @param errorListener\n * @return the parse result, which can subequently be compiled into an Expr using compile().\n */\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token | number>\n ): IfcExpressionParseResult {\n const chars = new CharStream(input); // replace this with a FileStream as required\n const lexer = new IfcExpressionLexer(chars);\n const tokens = new CommonTokenStream(lexer);\n const parser = new IfcExpressionParser(tokens);\n lexer.removeErrorListeners();\n parser.removeErrorListeners();\n const myErrorListener = new IfcExpressionErrorListener();\n if (isPresent(errorListener)) {\n lexer.addErrorListener(errorListener);\n parser.addErrorListener(errorListener);\n }\n lexer.addErrorListener(myErrorListener);\n parser.addErrorListener(myErrorListener);\n let expr;\n expr = parser.expr();\n const validationListener = new IfcExpressionValidationListener();\n if (!myErrorListener.isErrorOccurred()) {\n const walker = new ParseTreeWalker();\n try {\n walker.walk(validationListener, expr);\n } catch (e) {\n if (e instanceof ValidationException) {\n if (errorListener instanceof IfcExpressionErrorListener) {\n errorListener.validationException(e);\n }\n myErrorListener.validationException(e);\n }\n }\n }\n return new IfcExpressionParseResult(\n input,\n validationListener.getTypeManager(),\n expr\n );\n }\n\n /**\n * Compiles the specified parseResult into an Expr.\n * @param parseResult\n * @return the Expression (Expr), which can be evaluated to obtain its result.\n */\n public static compile(\n parseResult: IfcExpressionParseResult\n ): ExprFacade<ExpressionValue> {\n const compiler = new ExprCompiler(parseResult.typeManager);\n const expr = compiler.visit(parseResult.parseTree);\n ExprToTextInputLinker.linkTextToExpressions(\n parseResult.input,\n expr,\n compiler.getExprManager()\n );\n return new ExprFacade(expr);\n }\n\n /**\n * Evaluates the specified input expression and returns the evaluation result. The parse\n * and compile steps are done internally.\n *\n * @param expression: the input expression\n * @param context: the context required for accessing the IFC model\n * @return the result (or an error object).\n */\n public static evaluate(\n expression: string,\n context: IfcExpressionContext = new NopContext()\n ): ExprEvalResult<ExpressionValue> {\n const errorListener = new IfcExpressionErrorListener();\n const parseResult = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n return mapException(errorListener.getException());\n }\n const compiledExpression = this.compile(parseResult);\n return compiledExpression.evaluate(context);\n }\n\n public static formatError(input: string, error: ExprEvalError) {\n const lines = [\"** Error **\"];\n if (!isNullish(error[\"textSpan\"])) {\n const span: TextSpan = error[\"textSpan\"];\n const underlined = span.underline(input, \"^\");\n const startString = \"Input: \";\n const indented = this.indent(underlined, startString.length);\n const replaced = startString + indented.substr(startString.length);\n replaced.split(\"\\n\").forEach((line) => lines.push(line));\n }\n lines.push(\"Problem: \" + error.message);\n return lines.join(\"\\n\");\n }\n\n private static indent(s: string, by: number) {\n return s\n .split(\"\\n\")\n .map((line) => \" \".repeat(by) + line)\n .join(\"\\n\");\n }\n\n public static evaluateExpression(\n expr: ExprFacade<ExpressionValue>,\n context: IfcExpressionContext = new NopContext()\n ) {\n return expr.evaluate(context);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["IfcExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,iBAAiB,EAGjB,eAAe,GAEhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,y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;YAC7D,MAAM,QAAQ,GAAG,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YACnE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC1D;QACD,KAAK,CAAC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,MAAM,CAAC,MAAM,CAAC,CAAS,EAAE,EAAU;QACzC,OAAO,CAAC;aACL,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;aACpC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,kBAAkB,CAC9B,IAAiC,EACjC,UAAgC,IAAI,UAAU,EAAE;QAEhD,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF","file":"IfcExpression.js","sourcesContent":["import {\n CharStream,\n CommonTokenStream,\n ErrorListener,\n ParserRuleContext,\n ParseTreeWalker,\n Token,\n} from \"antlr4\";\nimport { ExprCompiler } from \"./compiler/ExprCompiler.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { IfcExpressionValidationListener } from \"./compiler/IfcExpressionValidationListener.js\";\n\nimport { isNullish, isPresent } from \"./util/IfcExpressionUtils.js\";\nimport { IfcExpressionContext } from \"./context/IfcExpressionContext.js\";\nimport { Expr } from \"./expression/Expr.js\";\n\nimport { IfcElementAccessor } from \"./context/IfcElementAccessor.js\";\nimport { Value } from \"./value/Value.js\";\nimport { StringValue } from \"./value/StringValue.js\";\nimport { NumericValue } from \"./value/NumericValue.js\";\nimport { BooleanValue } from \"./value/BooleanValue.js\";\nimport { LogicalValue } from \"./value/LogicalValue.js\";\nimport { ReferenceValue } from \"./value/ReferenceValue.js\";\nimport { IfcPropertySetAccessor } from \"./context/IfcPropertySetAccessor.js\";\nimport { IfcPropertyAccessor } from \"./context/IfcPropertyAccessor.js\";\nimport { IfcRootObjectAccessor } from \"./context/IfcRootObjectAccessor.js\";\nimport { IfcTypeObjectAccessor } from \"./context/IfcTypeObjectAccessor.js\";\nimport { NamedObjectAccessor } from \"./context/NamedObjectAccessor.js\";\nimport IfcExpressionParser from \"./gen/parser/IfcExpressionParser.js\";\nimport IfcExpressionVisitor from \"./gen/parser/IfcExpressionVisitor.js\";\nimport IfcExpressionLexer from \"./gen/parser/IfcExpressionLexer.js\";\nimport { ObjectAccessor } from \"./context/ObjectAccessor.js\";\nimport { IfcExpressionEvaluationException } from \"./expression/IfcExpressionEvaluationException.js\";\nimport type { ExpressionValue } from \"./value/ExpressionValue.js\";\nimport type { BoxedValueTypes } from \"./value/BoxedValueTypes.js\";\nimport {\n ExprEvalError,\n ExprEvalResult,\n isExprEvalError,\n isExprEvalSuccess,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\nimport { ValidationException } from \"./error/ValidationException.js\";\nimport { TypeManager } from \"./compiler/TypeManager.js\";\nimport { mapException } from \"./error/ExceptionToExprEvalErrorMapper.js\";\nimport { NopContext } from \"./context/NopContext.js\";\nimport { ExprToTextInputLinker } from \"./compiler/ExprToTextInputLinker.js\";\nimport { TextSpan } from \"./util/TextSpan.js\";\nimport { ExprFacade } from \"./expression/ExprFacade.js\";\nimport { IfcDurationValue } from \"./value/IfcDurationValue\";\nimport { IfcDateValue } from \"./value/IfcDateValue.js\";\nimport { IfcDateTimeValue } from \"./value/IfcDateTimeValue.js\";\nimport { IfcTimeValue } from \"./value/IfcTimeValue.js\";\nimport { IfcTimeStampValue } from \"./value/IfcTimeStampValue.js\";\nimport { ArrayType } from \"./type/ArrayType.js\";\nimport { ExprType } from \"./type/ExprType.js\";\nimport { SimpleType } from \"./type/SimpleType.js\";\nimport { TupleType } from \"./type/TupleType.js\";\nimport { TypeDisjunction } from \"./type/TypeDisjunction.js\";\nimport { Types } from \"./type/Types.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n ArrayType,\n ExprType,\n SimpleType,\n TupleType,\n TypeDisjunction,\n Types,\n};\n\nexport type { BoxedValueTypes };\n\nexport class IfcExpressionParseResult {\n private readonly _input: string;\n private readonly _typeManager: TypeManager;\n private readonly _parseTree: ParserRuleContext;\n\n constructor(input: string, typeManager: TypeManager, exprContext) {\n this._typeManager = typeManager;\n this._parseTree = exprContext;\n this._input = input;\n }\n\n get typeManager(): TypeManager {\n return this._typeManager;\n }\n\n get parseTree(): ParserRuleContext {\n return this._parseTree;\n }\n\n get input(): string {\n return this._input;\n }\n}\n\nexport class IfcExpression {\n /**\n * Parses the input and returns a parse result, which contains the parse tree, the type information per parse tree node, and the input.\n * @param input\n * @param errorListener\n * @return the parse result, which can subequently be compiled into an Expr using compile().\n */\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token | number>\n ): IfcExpressionParseResult {\n const chars = new CharStream(input); // replace this with a FileStream as required\n const lexer = new IfcExpressionLexer(chars);\n const tokens = new CommonTokenStream(lexer);\n const parser = new IfcExpressionParser(tokens);\n lexer.removeErrorListeners();\n parser.removeErrorListeners();\n const myErrorListener = new IfcExpressionErrorListener();\n if (isPresent(errorListener)) {\n lexer.addErrorListener(errorListener);\n parser.addErrorListener(errorListener);\n }\n lexer.addErrorListener(myErrorListener);\n parser.addErrorListener(myErrorListener);\n let expr;\n expr = parser.expr();\n const validationListener = new IfcExpressionValidationListener();\n if (!myErrorListener.isErrorOccurred()) {\n const walker = new ParseTreeWalker();\n try {\n walker.walk(validationListener, expr);\n } catch (e) {\n if (e instanceof ValidationException) {\n if (errorListener instanceof IfcExpressionErrorListener) {\n errorListener.validationException(e);\n }\n myErrorListener.validationException(e);\n }\n }\n }\n return new IfcExpressionParseResult(\n input,\n validationListener.getTypeManager(),\n expr\n );\n }\n\n /**\n * Compiles the specified parseResult into an Expr.\n * @param parseResult\n * @return the Expression (Expr), which can be evaluated to obtain its result.\n */\n public static compile(\n parseResult: IfcExpressionParseResult\n ): ExprFacade<ExpressionValue> {\n const compiler = new ExprCompiler(parseResult.typeManager);\n const expr = compiler.visit(parseResult.parseTree);\n ExprToTextInputLinker.linkTextToExpressions(\n parseResult.input,\n expr,\n compiler.getExprManager()\n );\n return new ExprFacade(expr);\n }\n\n /**\n * Evaluates the specified input expression and returns the evaluation result. The parse\n * and compile steps are done internally.\n *\n * @param expression: the input expression\n * @param context: the context required for accessing the IFC model\n * @return the result (or an error object).\n */\n public static evaluate(\n expression: string,\n context: IfcExpressionContext = new NopContext()\n ): ExprEvalResult<ExpressionValue> {\n const errorListener = new IfcExpressionErrorListener();\n const parseResult = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n return mapException(errorListener.getException());\n }\n const compiledExpression = this.compile(parseResult);\n return compiledExpression.evaluate(context);\n }\n\n public static formatError(input: string, error: ExprEvalError) {\n const lines = [\"** Error **\"];\n if (!isNullish(error[\"textSpan\"])) {\n const span: TextSpan = error[\"textSpan\"];\n const underlined = span.underline(input, \"^\");\n const startString = \"Input: \";\n const indented = this.indent(underlined, startString.length);\n const replaced = startString + indented.substr(startString.length);\n replaced.split(\"\\n\").forEach((line) => lines.push(line));\n }\n lines.push(\"Problem: \" + error.message);\n return lines.join(\"\\n\");\n }\n\n private static indent(s: string, by: number) {\n return s\n .split(\"\\n\")\n .map((line) => \" \".repeat(by) + line)\n .join(\"\\n\");\n }\n\n public static evaluateExpression(\n expr: ExprFacade<ExpressionValue>,\n context: IfcExpressionContext = new NopContext()\n ) {\n return expr.evaluate(context);\n }\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { IfcExpression, IfcExpressionParseResult, IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcDateValue, IfcDateTimeValue, IfcTimeValue, IfcDurationValue, IfcTimeStampValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, ArrayType, SimpleType, TupleType, TypeDisjunction, Types, } from "./IfcExpression.js";
|
|
2
|
+
export { E } from "./E.js";
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,kBAAkB,EAGlB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EAEZ,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EAGnB,YAAY,EACZ,QAAQ,EACR,gCAAgC,EAChC,0BAA0B,EAC1B,oBAAoB,EACpB,SAAS,EACT,SAAS,EAGT,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EAEV,SAAS,EACT,UAAU,EACV,SAAS,EACT,eAAe,EACf,KAAK,GACN,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC","file":"index.js","sourcesContent":["export {\n IfcExpression,\n IfcExpressionParseResult,\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n ExpressionValue,\n ReferenceValue,\n IfcDateValue,\n IfcDateTimeValue,\n IfcTimeValue,\n IfcDurationValue,\n IfcTimeStampValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprCompiler,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n ExprToTextInputLinker,\n ExprFacade,\n ExprType,\n ArrayType,\n SimpleType,\n TupleType,\n TypeDisjunction,\n Types,\n} from \"./IfcExpression.js\";\n\nexport type { BoxedValueTypes } from \"./IfcExpression.js\";\n\nexport { E } from \"./E.js\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ifc-expressions",
|
|
3
|
-
"version": "2.3.0
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Parsing and evaluation of IFC expressions",
|
|
5
5
|
"main": "dist/cjs/IfcExpression.js",
|
|
6
6
|
"module": "dist/mjs/IfcExpression.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/mjs/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
11
12
|
}
|
|
12
13
|
},
|
|
13
14
|
"license": "Apache-2.0",
|
|
14
|
-
"types": "./dist/
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
15
16
|
"files": [
|
|
16
17
|
"./dist/**/*",
|
|
17
18
|
"./dist/*"
|
|
@@ -32,10 +33,9 @@
|
|
|
32
33
|
"check": "npm run format-check && npm run lint"
|
|
33
34
|
},
|
|
34
35
|
"keywords": [
|
|
35
|
-
"
|
|
36
|
+
"IFC",
|
|
36
37
|
"Expressions",
|
|
37
38
|
"BIM",
|
|
38
|
-
"Merkmalservice",
|
|
39
39
|
"Formula"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|