ifc-expressions 0.3.2 → 0.3.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/IfcExpression.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ import { ObjectAccessor } from "./context/ObjectAccessor.js";
|
|
|
23
23
|
import { IfcExpressionEvaluationException } from "./expression/IfcExpressionEvaluationException.js";
|
|
24
24
|
import type { LiteralValueAnyArity } from "./value/LiteralValueAnyArity.js";
|
|
25
25
|
import type { PrimitiveValueType } from "./value/PrimitiveValueType.js";
|
|
26
|
-
import { ExprEvalResult } from "./expression/ExprEvalResult.js";
|
|
27
|
-
|
|
26
|
+
import { ExprEvalResult, isExprEvalSuccess, ExprEvalError, isExprEvalError } from "./expression/ExprEvalResult.js";
|
|
27
|
+
import { ExprKind } from "./expression/ExprKind.js";
|
|
28
|
+
export { IfcElementAccessor, IfcExpressionContext, Value, StringValue, BooleanValue, LogicalValue, NumericValue, LiteralValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ObjectAccessor, Expr, ExprVisitor, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, ExprEvalResult, ExprEvalError, isExprEvalError, isExprEvalSuccess, };
|
|
28
29
|
export type { PrimitiveValueType, LiteralValueAnyArity };
|
|
29
30
|
export declare class IfcExpression {
|
|
30
31
|
static parse(input: string, errorListener?: ErrorListener<Token>): ExprContext;
|
|
@@ -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.isNullish = exports.isPresent = exports.IfcExpressionVisitor = exports.IfcExpressionErrorListener = exports.IfcExpressionEvaluationException = exports.ExprVisitor = exports.NamedObjectAccessor = exports.IfcTypeObjectAccessor = exports.IfcRootObjectAccessor = exports.IfcPropertyAccessor = exports.IfcPropertySetAccessor = exports.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = void 0;
|
|
6
|
+
exports.IfcExpression = exports.isExprEvalSuccess = exports.isExprEvalError = exports.isNullish = exports.isPresent = exports.IfcExpressionVisitor = exports.IfcExpressionErrorListener = exports.IfcExpressionEvaluationException = exports.ExprKind = exports.ExprVisitor = exports.NamedObjectAccessor = exports.IfcTypeObjectAccessor = exports.IfcRootObjectAccessor = exports.IfcPropertyAccessor = exports.IfcPropertySetAccessor = exports.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = void 0;
|
|
7
7
|
const antlr4_1 = require("antlr4");
|
|
8
8
|
const ExprVisitor_js_1 = require("./ExprVisitor.js");
|
|
9
9
|
Object.defineProperty(exports, "ExprVisitor", { enumerable: true, get: function () { return ExprVisitor_js_1.ExprVisitor; } });
|
|
@@ -40,6 +40,11 @@ exports.IfcExpressionVisitor = IfcExpressionVisitor_js_1.default;
|
|
|
40
40
|
const IfcExpressionLexer_js_1 = __importDefault(require("./gen/parser/IfcExpressionLexer.js"));
|
|
41
41
|
const IfcExpressionEvaluationException_js_1 = require("./expression/IfcExpressionEvaluationException.js");
|
|
42
42
|
Object.defineProperty(exports, "IfcExpressionEvaluationException", { enumerable: true, get: function () { return IfcExpressionEvaluationException_js_1.IfcExpressionEvaluationException; } });
|
|
43
|
+
const ExprEvalResult_js_1 = require("./expression/ExprEvalResult.js");
|
|
44
|
+
Object.defineProperty(exports, "isExprEvalSuccess", { enumerable: true, get: function () { return ExprEvalResult_js_1.isExprEvalSuccess; } });
|
|
45
|
+
Object.defineProperty(exports, "isExprEvalError", { enumerable: true, get: function () { return ExprEvalResult_js_1.isExprEvalError; } });
|
|
46
|
+
const ExprKind_js_1 = require("./expression/ExprKind.js");
|
|
47
|
+
Object.defineProperty(exports, "ExprKind", { enumerable: true, get: function () { return ExprKind_js_1.ExprKind; } });
|
|
43
48
|
class IfcExpression {
|
|
44
49
|
static parse(input, errorListener) {
|
|
45
50
|
const chars = new antlr4_1.CharStream(input); // replace this with a FileStream as required
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/IfcExpression.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6E;AAC7E,qDAA+C;
|
|
1
|
+
{"version":3,"sources":["../../src/IfcExpression.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6E;AAC7E,qDAA+C;AAsD7C,4FAtDO,4BAAW,OAsDP;AArDb,mFAA6E;AAwD3E,2GAxDO,0DAA0B,OAwDP;AAvD5B,mEAA+D;AA0D7D,0FA1DO,iCAAS,OA0DP;AADT,0FAzDkB,iCAAS,OAyDlB;AArDX,2EAAqE;AAgCnE,mGAhCO,0CAAkB,OAgCP;AA9BpB,2DAAqD;AAiCnD,4FAjCO,4BAAW,OAiCP;AAhCb,6DAAuD;AAmCrD,6FAnCO,8BAAY,OAmCP;AAlCd,6DAAuD;AAgCrD,6FAhCO,8BAAY,OAgCP;AA/Bd,6DAAuD;AAgCrD,6FAhCO,8BAAY,OAgCP;AA9Bd,iEAA2D;AAiCzD,+FAjCO,kCAAc,OAiCP;AAhChB,mFAA6E;AAiC3E,uGAjCO,kDAAsB,OAiCP;AAhCxB,6EAAuE;AAiCrE,oGAjCO,4CAAmB,OAiCP;AAhCrB,iFAA2E;AAiCzE,sGAjCO,gDAAqB,OAiCP;AAhCvB,iFAA2E;AAiCzE,sGAjCO,gDAAqB,OAiCP;AAhCvB,6EAAuE;AAiCrE,oGAjCO,4CAAmB,OAiCP;AAhCrB,iGAE6C;AAC7C,mGAAwE;AAoCtE,+BApCK,iCAAoB,CAoCL;AAnCtB,+FAAoE;AAEpE,0GAAoG;AA+BlG,iHA/BO,sEAAgC,OA+BP;AA5BlC,sEAMwC;AA8BtC,kGAlCA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CAmCC","file":"IfcExpression.js","sourcesContent":["import { CharStream, CommonTokenStream, ErrorListener, Token } from \"antlr4\";\nimport { ExprVisitor } from \"./ExprVisitor.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { isNullish, isPresent } from \"./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 { LiteralValue } from \"./value/LiteralValue.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, {\n ExprContext,\n} 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 { LiteralValueAnyArity } from \"./value/LiteralValueAnyArity.js\";\nimport type { PrimitiveValueType } from \"./value/PrimitiveValueType.js\";\nimport {\n ExprEvalResult,\n isExprEvalSuccess,\n ExprEvalError,\n isExprEvalError,\n ExprEvalStatus,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n LiteralValue,\n ReferenceValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprVisitor,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n};\n\nexport type { PrimitiveValueType, LiteralValueAnyArity };\n\nexport class IfcExpression {\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token>\n ): ExprContext {\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 if (isPresent(errorListener)) {\n parser.removeErrorListeners();\n parser.addErrorListener(errorListener);\n }\n return parser.expr();\n }\n\n public static evaluate(\n expression: string,\n context: IfcExpressionContext\n ): ExprEvalResult<any> {\n const errorListener = new IfcExpressionErrorListener();\n const tree: ExprContext = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n throw errorListener.getException();\n }\n const parsedExpression = this.extractExprTree(tree);\n return parsedExpression.evaluate(context, new Map<string, any>());\n }\n\n private static extractExprTree(\n tree: ExprContext\n ): Expr<LiteralValueAnyArity> {\n const visitor = new ExprVisitor();\n return visitor.visit(tree);\n }\n}\n"]}
|
|
@@ -17,7 +17,9 @@ import IfcExpressionParser from "./gen/parser/IfcExpressionParser.js";
|
|
|
17
17
|
import IfcExpressionVisitor from "./gen/parser/IfcExpressionVisitor.js";
|
|
18
18
|
import IfcExpressionLexer from "./gen/parser/IfcExpressionLexer.js";
|
|
19
19
|
import { IfcExpressionEvaluationException } from "./expression/IfcExpressionEvaluationException.js";
|
|
20
|
-
|
|
20
|
+
import { isExprEvalSuccess, isExprEvalError, } from "./expression/ExprEvalResult.js";
|
|
21
|
+
import { ExprKind } from "./expression/ExprKind.js";
|
|
22
|
+
export { IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprVisitor, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, };
|
|
21
23
|
export class IfcExpression {
|
|
22
24
|
static parse(input, errorListener) {
|
|
23
25
|
const chars = new CharStream(input); // replace this with a FileStream as required
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["IfcExpression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAwB,MAAM,QAAQ,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAI/D,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;AAEvD,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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,aAAa,CAAC,YAAY,EAAE,CAAC;SACpC;QACD,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACpD,OAAO,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,GAAG,EAAe,CAAC,CAAC;IACpE,CAAC;IAEO,MAAM,CAAC,eAAe,CAC5B,IAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF","file":"IfcExpression.js","sourcesContent":["import { CharStream, CommonTokenStream, ErrorListener, Token } from \"antlr4\";\nimport { ExprVisitor } from \"./ExprVisitor.js\";\nimport { IfcExpressionErrorListener } from \"./IfcExpressionErrorListener.js\";\nimport { isNullish, isPresent } from \"./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 { LiteralValue } from \"./value/LiteralValue.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, {\n ExprContext,\n} 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 { LiteralValueAnyArity } from \"./value/LiteralValueAnyArity.js\";\nimport type { PrimitiveValueType } from \"./value/PrimitiveValueType.js\";\nimport {\n ExprEvalResult,\n isExprEvalSuccess,\n ExprEvalError,\n isExprEvalError,\n ExprEvalStatus,\n} from \"./expression/ExprEvalResult.js\";\nimport { ExprKind } from \"./expression/ExprKind.js\";\n\nexport {\n IfcElementAccessor,\n IfcExpressionContext,\n Value,\n StringValue,\n BooleanValue,\n LogicalValue,\n NumericValue,\n LiteralValue,\n ReferenceValue,\n IfcPropertySetAccessor,\n IfcPropertyAccessor,\n IfcRootObjectAccessor,\n IfcTypeObjectAccessor,\n NamedObjectAccessor,\n ObjectAccessor,\n Expr,\n ExprVisitor,\n ExprKind,\n IfcExpressionEvaluationException,\n IfcExpressionErrorListener,\n IfcExpressionVisitor,\n isPresent,\n isNullish,\n ExprEvalResult,\n ExprEvalError,\n isExprEvalError,\n isExprEvalSuccess,\n};\n\nexport type { PrimitiveValueType, LiteralValueAnyArity };\n\nexport class IfcExpression {\n public static parse(\n input: string,\n errorListener?: ErrorListener<Token>\n ): ExprContext {\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 if (isPresent(errorListener)) {\n parser.removeErrorListeners();\n parser.addErrorListener(errorListener);\n }\n return parser.expr();\n }\n\n public static evaluate(\n expression: string,\n context: IfcExpressionContext\n ): ExprEvalResult<any> {\n const errorListener = new IfcExpressionErrorListener();\n const tree: ExprContext = IfcExpression.parse(expression, errorListener);\n if (errorListener.isErrorOccurred()) {\n throw errorListener.getException();\n }\n const parsedExpression = this.extractExprTree(tree);\n return parsedExpression.evaluate(context, new Map<string, any>());\n }\n\n private static extractExprTree(\n tree: ExprContext\n ): Expr<LiteralValueAnyArity> {\n const visitor = new ExprVisitor();\n return visitor.visit(tree);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ifc-expressions",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Parsing and evaluation of IFC expressions",
|
|
5
|
-
"main": "dist/cjs/
|
|
6
|
-
"module": "dist/mjs/
|
|
5
|
+
"main": "dist/cjs/IfcExpression.js",
|
|
6
|
+
"module": "dist/mjs/IfcExpression.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"import": "./dist/mjs/
|
|
10
|
-
"require": "./dist/cjs/
|
|
9
|
+
"import": "./dist/mjs/IfcExpression.js",
|
|
10
|
+
"require": "./dist/cjs/IfcExpression.js"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
-
"types": "./dist/
|
|
13
|
+
"types": "./dist/IfcExpression.d.ts",
|
|
14
14
|
"files": [
|
|
15
15
|
"./dist/**/*",
|
|
16
16
|
"./dist/*"
|