ifc-expressions
Advanced tools
Comparing version 2.0.1-beta.3 to 2.0.1-beta.4
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IfcExpression = exports.IfcExpressionParseResult = 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.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = void 0; | ||
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.ReferenceValue = exports.NumericValue = exports.LogicalValue = exports.BooleanValue = exports.StringValue = exports.IfcElementAccessor = void 0; | ||
const antlr4_1 = require("antlr4"); | ||
@@ -55,2 +55,4 @@ const ExprCompiler_js_1 = require("./compiler/ExprCompiler.js"); | ||
Object.defineProperty(exports, "ExprToTextInputLinker", { enumerable: true, get: function () { return ExprToTextInputLinker_js_1.ExprToTextInputLinker; } }); | ||
const ExprFacade_js_1 = require("./expression/ExprFacade.js"); | ||
Object.defineProperty(exports, "ExprFacade", { enumerable: true, get: function () { return ExprFacade_js_1.ExprFacade; } }); | ||
class IfcExpressionParseResult { | ||
@@ -122,3 +124,3 @@ constructor(input, typeManager, exprContext) { | ||
ExprToTextInputLinker_js_1.ExprToTextInputLinker.linkTextToExpressions(parseResult.input, expr, compiler.getExprManager()); | ||
return expr; | ||
return new ExprFacade_js_1.ExprFacade(expr); | ||
} | ||
@@ -140,3 +142,3 @@ /** | ||
const compiledExpression = this.compile(parseResult); | ||
return compiledExpression.evaluate(context, new Map()); | ||
return compiledExpression.evaluate(context); | ||
} | ||
@@ -163,10 +165,3 @@ static formatError(input, error) { | ||
static evaluateExpression(expr, context = new NopContext_js_1.NopContext()) { | ||
if ((0, IfcExpressionUtils_js_1.isNullish)(expr.getTextSpan())) { | ||
// if the expr was created by parsing an input, it has a textSpan set. | ||
// If the expr was created programmatically, we have to generate its exprString once, which causes its | ||
// textspan to be set. | ||
// make sure we know the position | ||
expr.toExprString(); | ||
} | ||
return expr.evaluate(context, new Map()); | ||
return expr.evaluate(context); | ||
} | ||
@@ -173,0 +168,0 @@ } |
import { ParseTreeListener } from "antlr4"; | ||
import { ExprContext } from "./IfcExpressionParser"; | ||
import { SEComparisonContext } from "./IfcExpressionParser"; | ||
import { SELiteralContext } from "./IfcExpressionParser"; | ||
import { SEParenthesisContext } from "./IfcExpressionParser"; | ||
import { SEMulDivContext } from "./IfcExpressionParser"; | ||
import { SEPowerContext } from "./IfcExpressionParser"; | ||
import { SEBooleanBinaryOpContext } from "./IfcExpressionParser"; | ||
import { SEFunctionCallContext } from "./IfcExpressionParser"; | ||
import { SEArrayExprContext } from "./IfcExpressionParser"; | ||
import { SENotContext } from "./IfcExpressionParser"; | ||
import { SEVariableRefContext } from "./IfcExpressionParser"; | ||
import { SEUnaryMultipleMinusContext } from "./IfcExpressionParser"; | ||
import { SEUnaryMinusContext } from "./IfcExpressionParser"; | ||
import { SEAddSubContext } from "./IfcExpressionParser"; | ||
import { SEMethodCallContext } from "./IfcExpressionParser"; | ||
import { MethodCallChainInnerContext } from "./IfcExpressionParser"; | ||
import { MethodCallChainEndContext } from "./IfcExpressionParser"; | ||
import { FunctionCallContext } from "./IfcExpressionParser"; | ||
import { ExprListContext } from "./IfcExpressionParser"; | ||
import { ArrayExprContext } from "./IfcExpressionParser"; | ||
import { ArrayElementListContext } from "./IfcExpressionParser"; | ||
import { LiteralContext } from "./IfcExpressionParser"; | ||
import { NumLiteralContext } from "./IfcExpressionParser"; | ||
import { StringLiteralContext } from "./IfcExpressionParser"; | ||
import { BooleanLiteralContext } from "./IfcExpressionParser"; | ||
import { VariableRefContext } from "./IfcExpressionParser"; | ||
import { ExprContext } from "./IfcExpressionParser.js"; | ||
import { SEComparisonContext } from "./IfcExpressionParser.js"; | ||
import { SELiteralContext } from "./IfcExpressionParser.js"; | ||
import { SEParenthesisContext } from "./IfcExpressionParser.js"; | ||
import { SEMulDivContext } from "./IfcExpressionParser.js"; | ||
import { SEPowerContext } from "./IfcExpressionParser.js"; | ||
import { SEBooleanBinaryOpContext } from "./IfcExpressionParser.js"; | ||
import { SEFunctionCallContext } from "./IfcExpressionParser.js"; | ||
import { SEArrayExprContext } from "./IfcExpressionParser.js"; | ||
import { SENotContext } from "./IfcExpressionParser.js"; | ||
import { SEVariableRefContext } from "./IfcExpressionParser.js"; | ||
import { SEUnaryMultipleMinusContext } from "./IfcExpressionParser.js"; | ||
import { SEUnaryMinusContext } from "./IfcExpressionParser.js"; | ||
import { SEAddSubContext } from "./IfcExpressionParser.js"; | ||
import { SEMethodCallContext } from "./IfcExpressionParser.js"; | ||
import { MethodCallChainInnerContext } from "./IfcExpressionParser.js"; | ||
import { MethodCallChainEndContext } from "./IfcExpressionParser.js"; | ||
import { FunctionCallContext } from "./IfcExpressionParser.js"; | ||
import { ExprListContext } from "./IfcExpressionParser.js"; | ||
import { ArrayExprContext } from "./IfcExpressionParser.js"; | ||
import { ArrayElementListContext } from "./IfcExpressionParser.js"; | ||
import { LiteralContext } from "./IfcExpressionParser.js"; | ||
import { NumLiteralContext } from "./IfcExpressionParser.js"; | ||
import { StringLiteralContext } from "./IfcExpressionParser.js"; | ||
import { BooleanLiteralContext } from "./IfcExpressionParser.js"; | ||
import { VariableRefContext } from "./IfcExpressionParser.js"; | ||
/** | ||
@@ -29,0 +29,0 @@ * This interface defines a complete listener for a parse tree produced by |
import { ParseTreeVisitor } from 'antlr4'; | ||
import { ExprContext } from "./IfcExpressionParser"; | ||
import { SEComparisonContext } from "./IfcExpressionParser"; | ||
import { SELiteralContext } from "./IfcExpressionParser"; | ||
import { SEParenthesisContext } from "./IfcExpressionParser"; | ||
import { SEMulDivContext } from "./IfcExpressionParser"; | ||
import { SEPowerContext } from "./IfcExpressionParser"; | ||
import { SEBooleanBinaryOpContext } from "./IfcExpressionParser"; | ||
import { SEFunctionCallContext } from "./IfcExpressionParser"; | ||
import { SEArrayExprContext } from "./IfcExpressionParser"; | ||
import { SENotContext } from "./IfcExpressionParser"; | ||
import { SEVariableRefContext } from "./IfcExpressionParser"; | ||
import { SEUnaryMultipleMinusContext } from "./IfcExpressionParser"; | ||
import { SEUnaryMinusContext } from "./IfcExpressionParser"; | ||
import { SEAddSubContext } from "./IfcExpressionParser"; | ||
import { SEMethodCallContext } from "./IfcExpressionParser"; | ||
import { MethodCallChainInnerContext } from "./IfcExpressionParser"; | ||
import { MethodCallChainEndContext } from "./IfcExpressionParser"; | ||
import { FunctionCallContext } from "./IfcExpressionParser"; | ||
import { ExprListContext } from "./IfcExpressionParser"; | ||
import { ArrayExprContext } from "./IfcExpressionParser"; | ||
import { ArrayElementListContext } from "./IfcExpressionParser"; | ||
import { LiteralContext } from "./IfcExpressionParser"; | ||
import { NumLiteralContext } from "./IfcExpressionParser"; | ||
import { StringLiteralContext } from "./IfcExpressionParser"; | ||
import { BooleanLiteralContext } from "./IfcExpressionParser"; | ||
import { VariableRefContext } from "./IfcExpressionParser"; | ||
import { ExprContext } from "./IfcExpressionParser.js"; | ||
import { SEComparisonContext } from "./IfcExpressionParser.js"; | ||
import { SELiteralContext } from "./IfcExpressionParser.js"; | ||
import { SEParenthesisContext } from "./IfcExpressionParser.js"; | ||
import { SEMulDivContext } from "./IfcExpressionParser.js"; | ||
import { SEPowerContext } from "./IfcExpressionParser.js"; | ||
import { SEBooleanBinaryOpContext } from "./IfcExpressionParser.js"; | ||
import { SEFunctionCallContext } from "./IfcExpressionParser.js"; | ||
import { SEArrayExprContext } from "./IfcExpressionParser.js"; | ||
import { SENotContext } from "./IfcExpressionParser.js"; | ||
import { SEVariableRefContext } from "./IfcExpressionParser.js"; | ||
import { SEUnaryMultipleMinusContext } from "./IfcExpressionParser.js"; | ||
import { SEUnaryMinusContext } from "./IfcExpressionParser.js"; | ||
import { SEAddSubContext } from "./IfcExpressionParser.js"; | ||
import { SEMethodCallContext } from "./IfcExpressionParser.js"; | ||
import { MethodCallChainInnerContext } from "./IfcExpressionParser.js"; | ||
import { MethodCallChainEndContext } from "./IfcExpressionParser.js"; | ||
import { FunctionCallContext } from "./IfcExpressionParser.js"; | ||
import { ExprListContext } from "./IfcExpressionParser.js"; | ||
import { ArrayExprContext } from "./IfcExpressionParser.js"; | ||
import { ArrayElementListContext } from "./IfcExpressionParser.js"; | ||
import { LiteralContext } from "./IfcExpressionParser.js"; | ||
import { NumLiteralContext } from "./IfcExpressionParser.js"; | ||
import { StringLiteralContext } from "./IfcExpressionParser.js"; | ||
import { BooleanLiteralContext } from "./IfcExpressionParser.js"; | ||
import { VariableRefContext } from "./IfcExpressionParser.js"; | ||
/** | ||
@@ -29,0 +29,0 @@ * This interface defines a complete generic visitor for a parse tree produced |
@@ -28,3 +28,4 @@ import { ErrorListener, ParserRuleContext, Token } from "antlr4"; | ||
import { ExprToTextInputLinker } from "./compiler/ExprToTextInputLinker.js"; | ||
export { IfcElementAccessor, IfcExpressionContext, Value, StringValue, BooleanValue, LogicalValue, NumericValue, ExpressionValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ObjectAccessor, Expr, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, ExprEvalResult, ExprEvalError, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, }; | ||
import { ExprFacade } from "./expression/ExprFacade.js"; | ||
export { IfcElementAccessor, IfcExpressionContext, Value, StringValue, BooleanValue, LogicalValue, NumericValue, ExpressionValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ObjectAccessor, Expr, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, ExprEvalResult, ExprEvalError, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, }; | ||
export type { BoxedValueTypes }; | ||
@@ -53,3 +54,3 @@ export declare class IfcExpressionParseResult { | ||
*/ | ||
static compile(parseResult: IfcExpressionParseResult): Expr<ExpressionValue>; | ||
static compile(parseResult: IfcExpressionParseResult): ExprFacade<ExpressionValue>; | ||
/** | ||
@@ -66,3 +67,3 @@ * Evaluates the specified input expression and returns the evaluation result. The parse | ||
private static indent; | ||
static evaluateExpression(expr: Expr<ExpressionValue>, context?: IfcExpressionContext): ExprEvalResult<ExpressionValue>; | ||
static evaluateExpression(expr: ExprFacade<ExpressionValue>, context?: IfcExpressionContext): ExprEvalResult<ExpressionValue>; | ||
} |
@@ -27,3 +27,4 @@ import { CharStream, CommonTokenStream, ParseTreeWalker, } from "antlr4"; | ||
import { ExprToTextInputLinker } from "./compiler/ExprToTextInputLinker.js"; | ||
export { IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, }; | ||
import { ExprFacade } from "./expression/ExprFacade.js"; | ||
export { IfcElementAccessor, StringValue, BooleanValue, LogicalValue, NumericValue, ReferenceValue, IfcPropertySetAccessor, IfcPropertyAccessor, IfcRootObjectAccessor, IfcTypeObjectAccessor, NamedObjectAccessor, ExprCompiler, ExprKind, IfcExpressionEvaluationException, IfcExpressionErrorListener, IfcExpressionVisitor, isPresent, isNullish, isExprEvalError, isExprEvalSuccess, ExprToTextInputLinker, ExprFacade, }; | ||
export class IfcExpressionParseResult { | ||
@@ -94,3 +95,3 @@ constructor(input, typeManager, exprContext) { | ||
ExprToTextInputLinker.linkTextToExpressions(parseResult.input, expr, compiler.getExprManager()); | ||
return expr; | ||
return new ExprFacade(expr); | ||
} | ||
@@ -112,3 +113,3 @@ /** | ||
const compiledExpression = this.compile(parseResult); | ||
return compiledExpression.evaluate(context, new Map()); | ||
return compiledExpression.evaluate(context); | ||
} | ||
@@ -135,12 +136,5 @@ static formatError(input, error) { | ||
static evaluateExpression(expr, context = new NopContext()) { | ||
if (isNullish(expr.getTextSpan())) { | ||
// if the expr was created by parsing an input, it has a textSpan set. | ||
// If the expr was created programmatically, we have to generate its exprString once, which causes its | ||
// textspan to be set. | ||
// make sure we know the position | ||
expr.toExprString(); | ||
} | ||
return expr.evaluate(context, new Map()); | ||
return expr.evaluate(context); | ||
} | ||
} | ||
//# sourceMappingURL=IfcExpression.js.map |
{ | ||
"name": "ifc-expressions", | ||
"version": "2.0.1-beta.3", | ||
"version": "2.0.1-beta.4", | ||
"description": "Parsing and evaluation of IFC expressions", | ||
@@ -53,2 +53,3 @@ "main": "dist/cjs/IfcExpression.js", | ||
"gulp": "^4.0.2", | ||
"gulp-replace": "^1.1.4", | ||
"gulp-typescript": "^6.0.0-alpha.1", | ||
@@ -55,0 +56,0 @@ "gulp-uglify": "^3.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1717766
644
14940
15