ifc-expressions 2.3.0 → 3.0.0-beta.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.
Files changed (185) hide show
  1. package/README.md +242 -30
  2. package/dist/IfcExpression.d.ts +24 -26
  3. package/dist/IfcExpressionErrorListener.d.ts +3 -3
  4. package/dist/IfcExpressionOptions.d.ts +4 -0
  5. package/dist/autocomplete/CompletionItem.d.ts +24 -0
  6. package/dist/autocomplete/IfcExpressionAutocomplete.d.ts +10 -0
  7. package/dist/builtin/BuiltinRuntimeValueConverter.d.ts +7 -0
  8. package/dist/builtin/BuiltinVariableRegistry.d.ts +50 -0
  9. package/dist/cjs/IfcExpression.js +112 -37
  10. package/dist/cjs/IfcExpression.js.map +1 -1
  11. package/dist/cjs/IfcExpressionErrorListener.js +3 -8
  12. package/dist/cjs/IfcExpressionErrorListener.js.map +1 -1
  13. package/dist/cjs/IfcExpressionOptions.js +3 -0
  14. package/dist/cjs/IfcExpressionOptions.js.map +1 -0
  15. package/dist/cjs/autocomplete/CompletionItem.js +3 -0
  16. package/dist/cjs/autocomplete/CompletionItem.js.map +1 -0
  17. package/dist/cjs/autocomplete/IfcExpressionAutocomplete.js +532 -0
  18. package/dist/cjs/autocomplete/IfcExpressionAutocomplete.js.map +1 -0
  19. package/dist/cjs/builtin/BuiltinRuntimeValueConverter.js +124 -0
  20. package/dist/cjs/builtin/BuiltinRuntimeValueConverter.js.map +1 -0
  21. package/dist/cjs/builtin/BuiltinVariableRegistry.js +405 -0
  22. package/dist/cjs/builtin/BuiltinVariableRegistry.js.map +1 -0
  23. package/dist/cjs/compiler/ExprCompiler.js +44 -41
  24. package/dist/cjs/compiler/ExprCompiler.js.map +1 -1
  25. package/dist/cjs/compiler/ExprManager.js.map +1 -1
  26. package/dist/cjs/compiler/IfcExpressionValidationListener.js +85 -25
  27. package/dist/cjs/compiler/IfcExpressionValidationListener.js.map +1 -1
  28. package/dist/cjs/compiler/TypeManager.js.map +1 -1
  29. package/dist/cjs/context/IfcExpressionContext.js.map +1 -1
  30. package/dist/cjs/context/NopContext.js +3 -0
  31. package/dist/cjs/context/NopContext.js.map +1 -1
  32. package/dist/cjs/documentation/Documentation.js +11 -0
  33. package/dist/cjs/documentation/Documentation.js.map +1 -0
  34. package/dist/cjs/error/ExpressionTypeError.js.map +1 -1
  35. package/dist/cjs/error/IfcExpressionBuiltinConfigException.js +10 -0
  36. package/dist/cjs/error/IfcExpressionBuiltinConfigException.js.map +1 -0
  37. package/dist/cjs/error/InvalidSyntaxException.js.map +1 -1
  38. package/dist/cjs/error/NoSuchFunctionException.js.map +1 -1
  39. package/dist/cjs/error/NoSuchMemberException.js +13 -0
  40. package/dist/cjs/error/NoSuchMemberException.js.map +1 -0
  41. package/dist/cjs/error/ValidationException.js.map +1 -1
  42. package/dist/cjs/error/WrongFunctionArgumentTypeException.js.map +1 -1
  43. package/dist/cjs/expression/ExprKind.js +3 -0
  44. package/dist/cjs/expression/ExprKind.js.map +1 -1
  45. package/dist/cjs/expression/function/Func.js +18 -14
  46. package/dist/cjs/expression/function/Func.js.map +1 -1
  47. package/dist/cjs/expression/function/FuncArg.js +11 -5
  48. package/dist/cjs/expression/function/FuncArg.js.map +1 -1
  49. package/dist/cjs/expression/function/IfcExpressionFunctions.js +198 -42
  50. package/dist/cjs/expression/function/IfcExpressionFunctions.js.map +1 -1
  51. package/dist/cjs/expression/function/impl/CHOOSE.js.map +1 -1
  52. package/dist/cjs/expression/function/impl/IF.js.map +1 -1
  53. package/dist/cjs/expression/function/impl/MAP.js.map +1 -1
  54. package/dist/cjs/expression/function/impl/ReplacePattern.js +20 -2
  55. package/dist/cjs/expression/function/impl/ReplacePattern.js.map +1 -1
  56. package/dist/cjs/expression/reference/BuiltinFunctionCallExpr.js +59 -0
  57. package/dist/cjs/expression/reference/BuiltinFunctionCallExpr.js.map +1 -0
  58. package/dist/cjs/expression/reference/BuiltinPropertyAccessExpr.js +34 -0
  59. package/dist/cjs/expression/reference/BuiltinPropertyAccessExpr.js.map +1 -0
  60. package/dist/cjs/expression/reference/BuiltinRootReferenceExpr.js +29 -0
  61. package/dist/cjs/expression/reference/BuiltinRootReferenceExpr.js.map +1 -0
  62. package/dist/cjs/gen/parser/IfcExpressionLexer.js +126 -104
  63. package/dist/cjs/gen/parser/IfcExpressionLexer.js.map +1 -1
  64. package/dist/cjs/gen/parser/IfcExpressionListener.js +7 -4
  65. package/dist/cjs/gen/parser/IfcExpressionListener.js.map +1 -1
  66. package/dist/cjs/gen/parser/IfcExpressionParser.js +739 -682
  67. package/dist/cjs/gen/parser/IfcExpressionParser.js.map +1 -1
  68. package/dist/cjs/gen/parser/IfcExpressionVisitor.js +4 -4
  69. package/dist/cjs/gen/parser/IfcExpressionVisitor.js.map +1 -1
  70. package/dist/cjs/index.js +4 -1
  71. package/dist/cjs/index.js.map +1 -1
  72. package/dist/cjs/type/ContextObjectType.js +45 -0
  73. package/dist/cjs/type/ContextObjectType.js.map +1 -0
  74. package/dist/cjs/type/Types.js +4 -6
  75. package/dist/cjs/type/Types.js.map +1 -1
  76. package/dist/cjs/value/ContextObjectValue.js +23 -0
  77. package/dist/cjs/value/ContextObjectValue.js.map +1 -0
  78. package/dist/cjs/value/ExpressionValue.js.map +1 -1
  79. package/dist/cjs/value/Value.js.map +1 -1
  80. package/dist/compiler/ExprCompiler.d.ts +8 -3
  81. package/dist/compiler/ExprManager.d.ts +1 -1
  82. package/dist/compiler/IfcExpressionValidationListener.d.ts +9 -3
  83. package/dist/compiler/TypeManager.d.ts +1 -1
  84. package/dist/context/IfcExpressionContext.d.ts +3 -4
  85. package/dist/context/NopContext.d.ts +1 -0
  86. package/dist/documentation/Documentation.d.ts +12 -0
  87. package/dist/error/ExpressionTypeError.d.ts +1 -1
  88. package/dist/error/IfcExpressionBuiltinConfigException.d.ts +3 -0
  89. package/dist/error/InvalidSyntaxException.d.ts +1 -1
  90. package/dist/error/NoSuchFunctionException.d.ts +1 -1
  91. package/dist/error/NoSuchMemberException.d.ts +6 -0
  92. package/dist/error/ValidationException.d.ts +1 -1
  93. package/dist/error/WrongFunctionArgumentTypeException.d.ts +1 -1
  94. package/dist/expression/ExprKind.d.ts +3 -0
  95. package/dist/expression/function/Func.d.ts +7 -21
  96. package/dist/expression/function/FuncArg.d.ts +6 -5
  97. package/dist/expression/function/IfcExpressionFunctions.d.ts +1 -0
  98. package/dist/expression/function/impl/CHOOSE.d.ts +1 -1
  99. package/dist/expression/function/impl/IF.d.ts +1 -1
  100. package/dist/expression/function/impl/MAP.d.ts +1 -1
  101. package/dist/expression/reference/BuiltinFunctionCallExpr.d.ts +19 -0
  102. package/dist/expression/reference/BuiltinPropertyAccessExpr.d.ts +15 -0
  103. package/dist/expression/reference/BuiltinRootReferenceExpr.d.ts +14 -0
  104. package/dist/gen/parser/IfcExpressionLexer.d.ts +9 -8
  105. package/dist/gen/parser/IfcExpressionListener.d.ts +89 -59
  106. package/dist/gen/parser/IfcExpressionParser.d.ts +192 -169
  107. package/dist/gen/parser/IfcExpressionVisitor.d.ts +51 -35
  108. package/dist/index.d.ts +2 -2
  109. package/dist/mjs/IfcExpression.js +104 -32
  110. package/dist/mjs/IfcExpression.js.map +1 -1
  111. package/dist/mjs/IfcExpressionErrorListener.js +3 -8
  112. package/dist/mjs/IfcExpressionErrorListener.js.map +1 -1
  113. package/dist/mjs/IfcExpressionOptions.js +2 -0
  114. package/dist/mjs/IfcExpressionOptions.js.map +1 -0
  115. package/dist/mjs/autocomplete/CompletionItem.js +2 -0
  116. package/dist/mjs/autocomplete/CompletionItem.js.map +1 -0
  117. package/dist/mjs/autocomplete/IfcExpressionAutocomplete.js +528 -0
  118. package/dist/mjs/autocomplete/IfcExpressionAutocomplete.js.map +1 -0
  119. package/dist/mjs/builtin/BuiltinRuntimeValueConverter.js +117 -0
  120. package/dist/mjs/builtin/BuiltinRuntimeValueConverter.js.map +1 -0
  121. package/dist/mjs/builtin/BuiltinVariableRegistry.js +399 -0
  122. package/dist/mjs/builtin/BuiltinVariableRegistry.js.map +1 -0
  123. package/dist/mjs/compiler/ExprCompiler.js +43 -40
  124. package/dist/mjs/compiler/ExprCompiler.js.map +1 -1
  125. package/dist/mjs/compiler/ExprManager.js.map +1 -1
  126. package/dist/mjs/compiler/IfcExpressionValidationListener.js +85 -22
  127. package/dist/mjs/compiler/IfcExpressionValidationListener.js.map +1 -1
  128. package/dist/mjs/compiler/TypeManager.js.map +1 -1
  129. package/dist/mjs/context/IfcExpressionContext.js.map +1 -1
  130. package/dist/mjs/context/NopContext.js +3 -0
  131. package/dist/mjs/context/NopContext.js.map +1 -1
  132. package/dist/mjs/documentation/Documentation.js +7 -0
  133. package/dist/mjs/documentation/Documentation.js.map +1 -0
  134. package/dist/mjs/error/ExpressionTypeError.js.map +1 -1
  135. package/dist/mjs/error/IfcExpressionBuiltinConfigException.js +6 -0
  136. package/dist/mjs/error/IfcExpressionBuiltinConfigException.js.map +1 -0
  137. package/dist/mjs/error/InvalidSyntaxException.js.map +1 -1
  138. package/dist/mjs/error/NoSuchFunctionException.js.map +1 -1
  139. package/dist/mjs/error/NoSuchMemberException.js +9 -0
  140. package/dist/mjs/error/NoSuchMemberException.js.map +1 -0
  141. package/dist/mjs/error/ValidationException.js.map +1 -1
  142. package/dist/mjs/error/WrongFunctionArgumentTypeException.js.map +1 -1
  143. package/dist/mjs/expression/ExprKind.js +3 -0
  144. package/dist/mjs/expression/ExprKind.js.map +1 -1
  145. package/dist/mjs/expression/function/Func.js +18 -14
  146. package/dist/mjs/expression/function/Func.js.map +1 -1
  147. package/dist/mjs/expression/function/FuncArg.js +11 -5
  148. package/dist/mjs/expression/function/FuncArg.js.map +1 -1
  149. package/dist/mjs/expression/function/IfcExpressionFunctions.js +198 -42
  150. package/dist/mjs/expression/function/IfcExpressionFunctions.js.map +1 -1
  151. package/dist/mjs/expression/function/impl/CHOOSE.js.map +1 -1
  152. package/dist/mjs/expression/function/impl/IF.js.map +1 -1
  153. package/dist/mjs/expression/function/impl/MAP.js.map +1 -1
  154. package/dist/mjs/expression/function/impl/ReplacePattern.js +20 -2
  155. package/dist/mjs/expression/function/impl/ReplacePattern.js.map +1 -1
  156. package/dist/mjs/expression/reference/BuiltinFunctionCallExpr.js +55 -0
  157. package/dist/mjs/expression/reference/BuiltinFunctionCallExpr.js.map +1 -0
  158. package/dist/mjs/expression/reference/BuiltinPropertyAccessExpr.js +30 -0
  159. package/dist/mjs/expression/reference/BuiltinPropertyAccessExpr.js.map +1 -0
  160. package/dist/mjs/expression/reference/BuiltinRootReferenceExpr.js +25 -0
  161. package/dist/mjs/expression/reference/BuiltinRootReferenceExpr.js.map +1 -0
  162. package/dist/mjs/gen/parser/IfcExpressionLexer.js +101 -104
  163. package/dist/mjs/gen/parser/IfcExpressionLexer.js.map +1 -1
  164. package/dist/mjs/gen/parser/IfcExpressionListener.js +5 -3
  165. package/dist/mjs/gen/parser/IfcExpressionListener.js.map +1 -1
  166. package/dist/mjs/gen/parser/IfcExpressionParser.js +700 -670
  167. package/dist/mjs/gen/parser/IfcExpressionParser.js.map +1 -1
  168. package/dist/mjs/gen/parser/IfcExpressionVisitor.js +2 -3
  169. package/dist/mjs/gen/parser/IfcExpressionVisitor.js.map +1 -1
  170. package/dist/mjs/index.js +1 -1
  171. package/dist/mjs/index.js.map +1 -1
  172. package/dist/mjs/type/ContextObjectType.js +41 -0
  173. package/dist/mjs/type/ContextObjectType.js.map +1 -0
  174. package/dist/mjs/type/Types.js +4 -6
  175. package/dist/mjs/type/Types.js.map +1 -1
  176. package/dist/mjs/value/ContextObjectValue.js +19 -0
  177. package/dist/mjs/value/ContextObjectValue.js.map +1 -0
  178. package/dist/mjs/value/ExpressionValue.js.map +1 -1
  179. package/dist/mjs/value/Value.js.map +1 -1
  180. package/dist/type/ContextObjectType.d.ts +17 -0
  181. package/dist/type/Types.d.ts +2 -6
  182. package/dist/value/ContextObjectValue.d.ts +11 -0
  183. package/dist/value/ExpressionValue.d.ts +2 -1
  184. package/dist/value/Value.d.ts +1 -1
  185.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AAG,IAAI;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;IAEM,SAAS,CAAC,GAAG,IAAI;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,mBAAmB,CAAC,GAAG,IAAI;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAhID,kCAgIC","file":"compiler/TypeManager.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\nimport { Type, Types } from \"../type/Types.js\";\nimport { ExpressionTypeError } from \"../error/ExpressionTypeError.js\";\nimport { ExprType } from \"../type/ExprType.js\";\n\nexport class TypeManager {\n private readonly types = new Map<ParserRuleContext, ExprType>();\n\n constructor() {}\n\n public setType(parserRuleContext: ParserRuleContext, type: ExprType) {\n this.types.set(parserRuleContext, type);\n }\n\n public getType(parserRuleContext: ParserRuleContext): ExprType {\n return this.types.get(parserRuleContext);\n }\n\n public copyTypeFrom(ctx: ParserRuleContext, from: ParserRuleContext) {\n const theType = this.types.get(from as ParserRuleContext);\n this.types.set(ctx, theType);\n }\n\n public requireString(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.STRING,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type string, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireBoolean(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.BOOLEAN,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type boolean, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireLogicalOrBoolean(ctx: ParserRuleContext) {\n return this.requireOneOf(ctx, Type.BOOLEAN, Type.LOGICAL);\n }\n\n public requireOneOf(ctx: ParserRuleContext, ...types: Array<ExprType>) {\n const requiredType = Types.or(...types);\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n requiredType,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type ${requiredType}, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireNumeric(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.NUMERIC,\n actualType,\n () =>\n new ExpressionTypeError(\n `expected type numeric, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireTypesOverlap(ctxA: ParserRuleContext, ctxB: ParserRuleContext) {\n Types.requireTypesOverlap(\n this.types.get(ctxA),\n this.types.get(ctxB),\n () =>\n new ExpressionTypeError(\n `Types ${this.types.get(ctxA).getName()} and ${this.types\n .get(ctxB)\n .getName()} are required to overlap but they don't.`,\n ctxA\n )\n );\n }\n\n public isType(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => Types.isType(this.types.get(ctx), type));\n }\n\n public overlapsWith(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => type.overlapsWith(this.types.get(ctx)));\n }\n\n public isString(...ctxs) {\n return this.isType(Type.STRING, ...ctxs);\n }\n\n public overlapsWithString(...ctxs) {\n return this.overlapsWith(Type.STRING, ...ctxs);\n }\n\n public isBoolean(...ctxs) {\n return this.isType(Type.BOOLEAN, ...ctxs);\n }\n\n public isLogical(...ctxs) {\n return this.isType(Type.LOGICAL, ...ctxs);\n }\n\n public overlapsWithBoolean(...ctxs) {\n return this.overlapsWith(Type.BOOLEAN, ...ctxs);\n }\n\n public overlapsWithLogical(...ctxs) {\n return this.overlapsWith(Type.LOGICAL, ...ctxs);\n }\n\n public isNumeric(...ctxs) {\n return this.isType(Type.NUMERIC, ...ctxs);\n }\n\n public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AAC,CAAC;IAClD,CAAC;IAEM,mBAAmB,CAAC,GAAG,IAAI;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;IAEM,SAAS,CAAC,GAAG,IAAI;QACtB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAC5C,CAAC;IAEM,mBAAmB,CAAC,GAAG,IAAI;QAChC,OAAO,IAAI,CAAC,YAAY,CAAC,eAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAhID,kCAgIC","file":"compiler/TypeManager.js","sourcesContent":["import { ParserRuleContext } from \"antlr4ng\";\nimport { Type, Types } from \"../type/Types.js\";\nimport { ExpressionTypeError } from \"../error/ExpressionTypeError.js\";\nimport { ExprType } from \"../type/ExprType.js\";\n\nexport class TypeManager {\n private readonly types = new Map<ParserRuleContext, ExprType>();\n\n constructor() {}\n\n public setType(parserRuleContext: ParserRuleContext, type: ExprType) {\n this.types.set(parserRuleContext, type);\n }\n\n public getType(parserRuleContext: ParserRuleContext): ExprType {\n return this.types.get(parserRuleContext);\n }\n\n public copyTypeFrom(ctx: ParserRuleContext, from: ParserRuleContext) {\n const theType = this.types.get(from as ParserRuleContext);\n this.types.set(ctx, theType);\n }\n\n public requireString(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.STRING,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type string, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireBoolean(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.BOOLEAN,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type boolean, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireLogicalOrBoolean(ctx: ParserRuleContext) {\n return this.requireOneOf(ctx, Type.BOOLEAN, Type.LOGICAL);\n }\n\n public requireOneOf(ctx: ParserRuleContext, ...types: Array<ExprType>) {\n const requiredType = Types.or(...types);\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n requiredType,\n this.types.get(ctx as ParserRuleContext),\n () =>\n new ExpressionTypeError(\n `expected type ${requiredType}, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireNumeric(ctx: ParserRuleContext) {\n const actualType = this.types.get(ctx as ParserRuleContext);\n Types.requireWeakIsAssignableFrom(\n Type.NUMERIC,\n actualType,\n () =>\n new ExpressionTypeError(\n `expected type numeric, actual type is ${actualType.getName()}`,\n ctx\n )\n );\n }\n\n public requireTypesOverlap(ctxA: ParserRuleContext, ctxB: ParserRuleContext) {\n Types.requireTypesOverlap(\n this.types.get(ctxA),\n this.types.get(ctxB),\n () =>\n new ExpressionTypeError(\n `Types ${this.types.get(ctxA).getName()} and ${this.types\n .get(ctxB)\n .getName()} are required to overlap but they don't.`,\n ctxA\n )\n );\n }\n\n public isType(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => Types.isType(this.types.get(ctx), type));\n }\n\n public overlapsWith(type: ExprType, ...ctxs) {\n return ctxs.every((ctx) => type.overlapsWith(this.types.get(ctx)));\n }\n\n public isString(...ctxs) {\n return this.isType(Type.STRING, ...ctxs);\n }\n\n public overlapsWithString(...ctxs) {\n return this.overlapsWith(Type.STRING, ...ctxs);\n }\n\n public isBoolean(...ctxs) {\n return this.isType(Type.BOOLEAN, ...ctxs);\n }\n\n public isLogical(...ctxs) {\n return this.isType(Type.LOGICAL, ...ctxs);\n }\n\n public overlapsWithBoolean(...ctxs) {\n return this.overlapsWith(Type.BOOLEAN, ...ctxs);\n }\n\n public overlapsWithLogical(...ctxs) {\n return this.overlapsWith(Type.LOGICAL, ...ctxs);\n }\n\n public isNumeric(...ctxs) {\n return this.isType(Type.NUMERIC, ...ctxs);\n }\n\n public overlapsWithNumeric(...ctxs) {\n return this.overlapsWith(Type.NUMERIC, ...ctxs);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/IfcExpressionContext.ts"],"names":[],"mappings":"","file":"context/IfcExpressionContext.js","sourcesContent":["import { IfcPropertyAccessor } from \"./IfcPropertyAccessor.js\";\nimport { IfcElementAccessor } from \"./IfcElementAccessor.js\";\n\nexport interface IfcExpressionContext {\n resolvePropRef(): IfcPropertyAccessor;\n\n resolveElemRef(): IfcElementAccessor;\n}\n"]}
1
+ {"version":3,"sources":["../../src/context/IfcExpressionContext.ts"],"names":[],"mappings":"","file":"context/IfcExpressionContext.js","sourcesContent":["import { ExprType } from \"../type/ExprType.js\";\n\nexport interface IfcExpressionContext {\n resolvePropRef();\n\n resolveElemRef();\n\n resolveBuiltinVariable(name: string): unknown;\n}\n"]}
@@ -8,6 +8,9 @@ class NopContext {
8
8
  resolvePropRef() {
9
9
  throw new Error("No IfcExpressionContext implementation provided - cannot resolve property reference");
10
10
  }
11
+ resolveBuiltinVariable(name) {
12
+ throw new Error(`No IfcExpressionContext implementation provided - cannot resolve builtin variable '${name}'`);
13
+ }
11
14
  }
12
15
  exports.NopContext = NopContext;
13
16
  //# sourceMappingURL=NopContext.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/NopContext.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;IACrB,cAAc;QACZ,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;IACJ,CAAC;IAED,cAAc;QACZ,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;IACJ,CAAC;CACF;AAZD,gCAYC","file":"context/NopContext.js","sourcesContent":["import {\n IfcElementAccessor,\n IfcExpressionContext,\n IfcPropertyAccessor,\n} from \"../IfcExpression.js\";\n\nexport class NopContext implements IfcExpressionContext {\n resolveElemRef(): IfcElementAccessor {\n throw new Error(\n \"No IfcExpressionContext implementation provided - cannot resolve element reference\"\n );\n }\n\n resolvePropRef(): IfcPropertyAccessor {\n throw new Error(\n \"No IfcExpressionContext implementation provided - cannot resolve property reference\"\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/context/NopContext.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;IACrB,cAAc;QACZ,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;IACJ,CAAC;IAED,cAAc;QACZ,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;IACJ,CAAC;IAED,sBAAsB,CAAC,IAAY;QACjC,MAAM,IAAI,KAAK,CACb,sFAAsF,IAAI,GAAG,CAC9F,CAAC;IACJ,CAAC;CACF;AAlBD,gCAkBC","file":"context/NopContext.js","sourcesContent":["import {\n IfcElementAccessor,\n IfcExpressionContext,\n IfcPropertyAccessor,\n} from \"../IfcExpression.js\";\n\nexport class NopContext implements IfcExpressionContext {\n resolveElemRef(): IfcElementAccessor {\n throw new Error(\n \"No IfcExpressionContext implementation provided - cannot resolve element reference\"\n );\n }\n\n resolvePropRef(): IfcPropertyAccessor {\n throw new Error(\n \"No IfcExpressionContext implementation provided - cannot resolve property reference\"\n );\n }\n\n resolveBuiltinVariable(name: string): unknown {\n throw new Error(\n `No IfcExpressionContext implementation provided - cannot resolve builtin variable '${name}'`\n );\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveLocalizedText = void 0;
4
+ function resolveLocalizedText(text, localizer) {
5
+ if (!text) {
6
+ return undefined;
7
+ }
8
+ return localizer ? localizer.t(text.key, text.fallback) : text.fallback;
9
+ }
10
+ exports.resolveLocalizedText = resolveLocalizedText;
11
+ //# sourceMappingURL=Documentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/documentation/Documentation.ts"],"names":[],"mappings":";;;AAcA,SAAgB,oBAAoB,CAClC,IAA+B,EAC/B,SAAkC;IAElC,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC1E,CAAC;AATD,oDASC","file":"documentation/Documentation.js","sourcesContent":["export type LocalizedText = {\n key: string;\n fallback: string;\n};\n\nexport type DocumentationLocalizer = {\n t(key: string, fallback: string): string;\n};\n\nexport type ArgumentDocumentation = {\n label: LocalizedText;\n documentation: LocalizedText;\n};\n\nexport function resolveLocalizedText(\n text: LocalizedText | undefined,\n localizer?: DocumentationLocalizer\n): string | undefined {\n if (!text) {\n return undefined;\n }\n\n return localizer ? localizer.t(text.key, text.fallback) : text.fallback;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error/ExpressionTypeError.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,MAAa,mBAAoB,SAAQ,4CAAmB;IAC1D,YAAY,OAAe,EAAE,GAAsB;QACjD,KAAK,CAAC,eAAe,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;CACF;AAJD,kDAIC","file":"error/ExpressionTypeError.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\nimport { ValidationException } from \"./ValidationException.js\";\n\nexport class ExpressionTypeError extends ValidationException {\n constructor(message: string, ctx: ParserRuleContext) {\n super(`Type error: ${message}`, ctx);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/error/ExpressionTypeError.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,MAAa,mBAAoB,SAAQ,4CAAmB;IAC1D,YAAY,OAAe,EAAE,GAAsB;QACjD,KAAK,CAAC,eAAe,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC;CACF;AAJD,kDAIC","file":"error/ExpressionTypeError.js","sourcesContent":["import { ParserRuleContext } from \"antlr4ng\";\nimport { ValidationException } from \"./ValidationException.js\";\n\nexport class ExpressionTypeError extends ValidationException {\n constructor(message: string, ctx: ParserRuleContext) {\n super(`Type error: ${message}`, ctx);\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IfcExpressionBuiltinConfigException = void 0;
4
+ class IfcExpressionBuiltinConfigException extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ }
8
+ }
9
+ exports.IfcExpressionBuiltinConfigException = IfcExpressionBuiltinConfigException;
10
+ //# sourceMappingURL=IfcExpressionBuiltinConfigException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/error/IfcExpressionBuiltinConfigException.ts"],"names":[],"mappings":";;;AAAA,MAAa,mCAAoC,SAAQ,KAAK;IAC5D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,kFAIC","file":"error/IfcExpressionBuiltinConfigException.js","sourcesContent":["export class IfcExpressionBuiltinConfigException extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error/InvalidSyntaxException.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,MAAa,sBAAuB,SAAQ,4CAAmB;IAE7D,YAAY,cAAsB,EAAE,GAAsB;QACxD,KAAK,CAAC,mBAAmB,cAAc,EAAE,EAAE,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AAND,wDAMC","file":"error/InvalidSyntaxException.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\nimport { ValidationException } from \"./ValidationException.js\";\n\nexport class InvalidSyntaxException extends ValidationException {\n readonly offendingInput: string;\n constructor(offendingInput: string, ctx: ParserRuleContext) {\n super(`Invalid syntax: ${offendingInput}`, ctx);\n this.offendingInput = offendingInput;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/error/InvalidSyntaxException.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,MAAa,sBAAuB,SAAQ,4CAAmB;IAE7D,YAAY,cAAsB,EAAE,GAAsB;QACxD,KAAK,CAAC,mBAAmB,cAAc,EAAE,EAAE,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF;AAND,wDAMC","file":"error/InvalidSyntaxException.js","sourcesContent":["import { ParserRuleContext } from \"antlr4ng\";\nimport { ValidationException } from \"./ValidationException.js\";\n\nexport class InvalidSyntaxException extends ValidationException {\n readonly offendingInput: string;\n constructor(offendingInput: string, ctx: ParserRuleContext) {\n super(`Invalid syntax: ${offendingInput}`, ctx);\n this.offendingInput = offendingInput;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error/NoSuchFunctionException.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,MAAa,uBAAwB,SAAQ,4CAAmB;IAE9D,YAAY,YAAoB,EAAE,GAAsB;QACtD,KAAK,CAAC,kCAAkC,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAND,0DAMC","file":"error/NoSuchFunctionException.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\nimport { ValidationException } from \"./ValidationException.js\";\n\nexport class NoSuchFunctionException extends ValidationException {\n readonly functionName: string;\n constructor(functionName: string, ctx: ParserRuleContext) {\n super(`Not a IFC Expression Function: ${functionName}`, ctx);\n this.functionName = functionName;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/error/NoSuchFunctionException.ts"],"names":[],"mappings":";;;AACA,qEAA+D;AAE/D,MAAa,uBAAwB,SAAQ,4CAAmB;IAE9D,YAAY,YAAoB,EAAE,GAAsB;QACtD,KAAK,CAAC,kCAAkC,YAAY,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAND,0DAMC","file":"error/NoSuchFunctionException.js","sourcesContent":["import { ParserRuleContext } from \"antlr4ng\";\nimport { ValidationException } from \"./ValidationException.js\";\n\nexport class NoSuchFunctionException extends ValidationException {\n readonly functionName: string;\n constructor(functionName: string, ctx: ParserRuleContext) {\n super(`Not a IFC Expression Function: ${functionName}`, ctx);\n this.functionName = functionName;\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NoSuchMemberException = void 0;
4
+ const ValidationException_js_1 = require("./ValidationException.js");
5
+ class NoSuchMemberException extends ValidationException_js_1.ValidationException {
6
+ constructor(memberName, type, ctx) {
7
+ super(`No member ${memberName} found for type ${type}`, ctx);
8
+ this.memberName = memberName;
9
+ this.type = type;
10
+ }
11
+ }
12
+ exports.NoSuchMemberException = NoSuchMemberException;
13
+ //# sourceMappingURL=NoSuchMemberException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/error/NoSuchMemberException.ts"],"names":[],"mappings":";;;AAAA,qEAA+D;AAE/D,MAAa,qBAAsB,SAAQ,4CAAmB;IAI5D,YAAY,UAAkB,EAAE,IAAY,EAAE,GAAG;QAC/C,KAAK,CAAC,aAAa,UAAU,mBAAmB,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;QAC7D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AATD,sDASC","file":"error/NoSuchMemberException.js","sourcesContent":["import { ValidationException } from \"./ValidationException.js\";\n\nexport class NoSuchMemberException extends ValidationException {\n readonly memberName: string;\n readonly type: string;\n\n constructor(memberName: string, type: string, ctx) {\n super(`No member ${memberName} found for type ${type}`, ctx);\n this.memberName = memberName;\n this.type = type;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"s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,CAAC;CACF;AA/BD,kDA+BC","file":"error/ValidationException.js","sourcesContent":["import { ParserRuleContext } from \"antlr4\";\n\nexport class ValidationException extends Error {\n public readonly fromLine: number;\n public readonly toLine: number;\n public readonly fromColumn: number;\n public readonly toColumn: number;\n\n constructor(message: string, ctx: ParserRuleContext) {\n super(\n `Validation Failed: ${message} at ${ValidationException.makeColumnsString(\n ctx\n )}, near '${ctx.getText()}'`\n );\n this.fromLine = ctx.start.line;\n this.fromColumn = ctx.start.column;\n this.toLine = ctx.stop.line;\n this.toColumn = ctx.stop.column + (ctx.stop.text || \"\").length;\n }\n\n private static makeColumnsString(ctx: ParserRuleContext): string {\n const fromLine = ctx.start.line;\n const fromColumn = ctx.start.column;\n const toLine = ctx.stop.line;\n const toColumn = ctx.stop.column + (ctx.stop.text || \"\").length;\n if (fromLine == toLine) {\n return fromColumn == toColumn\n ? `line ${fromLine}, column ${fromColumn}`\n : `line ${fromLine}, columns ${fromColumn}-${toColumn}`;\n } else {\n return `line ${fromLine}, column ${fromColumn} to line ${toLine}, column ${toColumn}`;\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/error/ValidationException.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAoB,SAAQ,KAAK;IAM5C,YAAY,OAAe,EAAE,GAAsB;QACjD,KAAK,CACH,sBAAsB,OAAO,OAAO,mBAAmB,CAAC,iBAAiB,CACvE,GAAG,CACJ,WAAW,GAAG,CAAC,OAAO,EAAE,GAAG,CAC7B,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACjE,CAAC;IAEO,MAAM,CAAC,iBAAiB,CAAC,GAAsB;QACrD,MAAM,QAAQ,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;QAChC,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC;QACpC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAC7B,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;QAChE,IAAI,QAAQ,IAAI,MAAM,EAAE;YACtB,OAAO,UAAU,IAAI,QAAQ;gBAC3B,CAAC,CAAC,QAAQ,QAAQ,YAAY,UAAU,EAAE;gBAC1C,CAAC,CAAC,QAAQ,QAAQ,aAAa,UAAU,IAAI,QAAQ,EAAE,CAAC;SAC3D;aAAM;YACL,OAAO,QAAQ,QAAQ,YAAY,UAAU,YAAY,MAAM,YAAY,QAAQ,EAAE,CAAC;SACvF;IACH,CAAC;CACF;AA/BD,kDA+BC","file":"error/ValidationException.js","sourcesContent":["import { ParserRuleContext } from \"antlr4ng\";\n\nexport class ValidationException extends Error {\n public readonly fromLine: number;\n public readonly toLine: number;\n public readonly fromColumn: number;\n public readonly toColumn: number;\n\n constructor(message: string, ctx: ParserRuleContext) {\n super(\n `Validation Failed: ${message} at ${ValidationException.makeColumnsString(\n ctx\n )}, near '${ctx.getText()}'`\n );\n this.fromLine = ctx.start.line;\n this.fromColumn = ctx.start.column;\n this.toLine = ctx.stop.line;\n this.toColumn = ctx.stop.column + (ctx.stop.text || \"\").length;\n }\n\n private static makeColumnsString(ctx: ParserRuleContext): string {\n const fromLine = ctx.start.line;\n const fromColumn = ctx.start.column;\n const toLine = ctx.stop.line;\n const toColumn = ctx.stop.column + (ctx.stop.text || \"\").length;\n if (fromLine == toLine) {\n return fromColumn == toColumn\n ? `line ${fromLine}, column ${fromColumn}`\n : `line ${fromLine}, columns ${fromColumn}-${toColumn}`;\n } else {\n return `line ${fromLine}, column ${fromColumn} to line ${toLine}, column ${toColumn}`;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/error/WrongFunctionArgumentTypeException.ts"],"names":[],"mappings":";;;AAAA,qEAA+D;AAI/D,MAAa,kCAAmC,SAAQ,4CAAmB;IAOzE,YACE,YAAoB,EACpB,YAAoB,EACpB,YAAsB,EACtB,UAAoB,EACpB,aAAqB,EACrB,GAAsB;QAEtB,KAAK,CACH,YAAY,YAAY,2BAA2B,UAAU,CAAC,OAAO,EAAE,qCAAqC,YAAY,CAAC,OAAO,EAAE,mBAAmB,YAAY,yBAAyB,aAAa,GAAG,EAC1M,GAAG,CACJ,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAzBD,gFAyBC","file":"error/WrongFunctionArgumentTypeException.js","sourcesContent":["import { ExpressionTypeError } from \"./ExpressionTypeError.js\";\nimport { ParserRuleContext } from \"antlr4\";\nimport { ExprType } from \"../type/ExprType.js\";\n\nexport class WrongFunctionArgumentTypeException extends ExpressionTypeError {\n readonly functionName: string;\n readonly argumentName: string;\n readonly expectedType: ExprType;\n readonly actualType: ExprType;\n readonly argumentIndex: number;\n\n constructor(\n functionName: string,\n argumentName: string,\n expectedType: ExprType,\n actualType: ExprType,\n argumentIndex: number,\n ctx: ParserRuleContext\n ) {\n super(\n `Function ${functionName}: Actual argument type '${actualType.getName()}' does not satisfy expected type '${expectedType.getName()}' for argument '${argumentName}' at 0-based position ${argumentIndex}.`,\n ctx\n );\n this.functionName = functionName;\n this.argumentName = argumentName;\n this.expectedType = expectedType;\n this.actualType = actualType;\n this.argumentIndex = argumentIndex;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/error/WrongFunctionArgumentTypeException.ts"],"names":[],"mappings":";;;AAAA,qEAA+D;AAI/D,MAAa,kCAAmC,SAAQ,4CAAmB;IAOzE,YACE,YAAoB,EACpB,YAAoB,EACpB,YAAsB,EACtB,UAAoB,EACpB,aAAqB,EACrB,GAAsB;QAEtB,KAAK,CACH,YAAY,YAAY,2BAA2B,UAAU,CAAC,OAAO,EAAE,qCAAqC,YAAY,CAAC,OAAO,EAAE,mBAAmB,YAAY,yBAAyB,aAAa,GAAG,EAC1M,GAAG,CACJ,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF;AAzBD,gFAyBC","file":"error/WrongFunctionArgumentTypeException.js","sourcesContent":["import { ExpressionTypeError } from \"./ExpressionTypeError.js\";\nimport { ParserRuleContext } from \"antlr4ng\";\nimport { ExprType } from \"../type/ExprType.js\";\n\nexport class WrongFunctionArgumentTypeException extends ExpressionTypeError {\n readonly functionName: string;\n readonly argumentName: string;\n readonly expectedType: ExprType;\n readonly actualType: ExprType;\n readonly argumentIndex: number;\n\n constructor(\n functionName: string,\n argumentName: string,\n expectedType: ExprType,\n actualType: ExprType,\n argumentIndex: number,\n ctx: ParserRuleContext\n ) {\n super(\n `Function ${functionName}: Actual argument type '${actualType.getName()}' does not satisfy expected type '${expectedType.getName()}' for argument '${argumentName}' at 0-based position ${argumentIndex}.`,\n ctx\n );\n this.functionName = functionName;\n this.argumentName = argumentName;\n this.expectedType = expectedType;\n this.actualType = actualType;\n this.argumentIndex = argumentIndex;\n }\n}\n"]}
@@ -17,6 +17,9 @@ var ExprKind;
17
17
  ExprKind["NUM_LITERAL"] = "NUM_LITERAL";
18
18
  ExprKind["REF_ELEMENT"] = "REF_ELEMENT";
19
19
  ExprKind["REF_PROPERTY"] = "REF_PROPERTY";
20
+ ExprKind["REF_BUILTIN_ROOT"] = "REF_BUILTIN_ROOT";
21
+ ExprKind["REF_BUILTIN_MEMBER"] = "REF_BUILTIN_MEMBER";
22
+ ExprKind["REF_BUILTIN_FUNCTION"] = "REF_BUILTIN_FUNCTION";
20
23
  ExprKind["STR_CONCAT"] = "STR_CONCAT";
21
24
  ExprKind["STR_LITERAL"] = "STR_LITERAL";
22
25
  ExprKind["AND"] = "AND";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expression/ExprKind.ts"],"names":[],"mappings":";;;AAAA,IAAY,QA8BX;AA9BD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,qDAAyC,CAAA;IACzC,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,uCAA2B,CAAA;IAC3B,qCAAyB,CAAA;IACzB,yCAA6B,CAAA;IAC7B,iCAAqB,CAAA;IACrB,mCAAuB,CAAA;IACvB,+BAAmB,CAAA;IACnB,2CAA+B,CAAA;IAC/B,uCAA2B,CAAA;IAC3B,uCAA2B,CAAA;IAC3B,yCAA6B,CAAA;IAC7B,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,uBAAW,CAAA;IACX,uBAAW,CAAA;IACX,+CAAmC,CAAA;IACnC,+CAAmC,CAAA;IACnC,qCAAyB,CAAA;IACzB,6CAAiC,CAAA;IACjC,2CAA+B,CAAA;IAC/B,6DAAiD,CAAA;IACjD,iDAAqC,CAAA;IACrC,mEAAuD,CAAA;IACvD,uCAA2B,CAAA,CAAC,0EAA0E;AACxG,CAAC,EA9BW,QAAQ,wBAAR,QAAQ,QA8BnB","file":"expression/ExprKind.js","sourcesContent":["export enum ExprKind {\n FUNCTION = \"FUNCTION\",\n FUNCTION_ARGUMENTS = \"FUNCTION_ARGUMENTS\",\n ARRAY = \"ARRAY\",\n METHOD_CALL = \"METHOD_CALL\",\n PARENTHESIS = \"PARENTHESIS\",\n NUM_DIVIDE = \"NUM_DIVIDE\",\n NUM_MULTIPLY = \"NUM_MULTIPLY\",\n NUM_PLUS = \"NUM_PLUS\",\n NUM_MINUS = \"NUM_MINUS\",\n NUM_POWER = \"POWER\",\n NUM_UNARY_MINUS = \"UNARY_MINUS\",\n NUM_LITERAL = \"NUM_LITERAL\",\n REF_ELEMENT = \"REF_ELEMENT\",\n REF_PROPERTY = \"REF_PROPERTY\",\n STR_CONCAT = \"STR_CONCAT\",\n STR_LITERAL = \"STR_LITERAL\",\n AND = \"AND\",\n OR = \"OR\",\n XOR = \"XOR\",\n NOT = \"NOT\",\n BOOLEAN_LITERAL = \"BOOLEAN_LITERAL\",\n LOGICAL_LITERAL = \"LOGICAL_LITERAL\",\n CMP_EQUALS = \"CMP_EQUALS\",\n CMP_NOT_EQUALS = \"CMP_NOT_EQUALS\",\n CMP_LESS_THAN = \"CMP_LESS_THAN\",\n CMP_LESS_THAN_OR_EQUAL = \"CMP_LESS_THAN_OR_EQUAL\",\n CMP_GREATER_THAN = \"CMP_GREATER_THAN\",\n CMP_GREATER_THAN_OR_EQUAL = \"CMP_GREATER_THAN_OR_EQUAL\",\n PARSE_ERROR = \"PARSE_ERROR\" /* to be used when no expr was compiled due to a parse/validation error */,\n}\n"]}
1
+ {"version":3,"sources":["../../src/expression/ExprKind.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAiCX;AAjCD,WAAY,QAAQ;IAClB,iCAAqB,CAAA;IACrB,qDAAyC,CAAA;IACzC,2BAAe,CAAA;IACf,uCAA2B,CAAA;IAC3B,uCAA2B,CAAA;IAC3B,qCAAyB,CAAA;IACzB,yCAA6B,CAAA;IAC7B,iCAAqB,CAAA;IACrB,mCAAuB,CAAA;IACvB,+BAAmB,CAAA;IACnB,2CAA+B,CAAA;IAC/B,uCAA2B,CAAA;IAC3B,uCAA2B,CAAA;IAC3B,yCAA6B,CAAA;IAC7B,iDAAqC,CAAA;IACrC,qDAAyC,CAAA;IACzC,yDAA6C,CAAA;IAC7C,qCAAyB,CAAA;IACzB,uCAA2B,CAAA;IAC3B,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,uBAAW,CAAA;IACX,uBAAW,CAAA;IACX,+CAAmC,CAAA;IACnC,+CAAmC,CAAA;IACnC,qCAAyB,CAAA;IACzB,6CAAiC,CAAA;IACjC,2CAA+B,CAAA;IAC/B,6DAAiD,CAAA;IACjD,iDAAqC,CAAA;IACrC,mEAAuD,CAAA;IACvD,uCAA2B,CAAA,CAAC,0EAA0E;AACxG,CAAC,EAjCW,QAAQ,wBAAR,QAAQ,QAiCnB","file":"expression/ExprKind.js","sourcesContent":["export enum ExprKind {\n FUNCTION = \"FUNCTION\",\n FUNCTION_ARGUMENTS = \"FUNCTION_ARGUMENTS\",\n ARRAY = \"ARRAY\",\n METHOD_CALL = \"METHOD_CALL\",\n PARENTHESIS = \"PARENTHESIS\",\n NUM_DIVIDE = \"NUM_DIVIDE\",\n NUM_MULTIPLY = \"NUM_MULTIPLY\",\n NUM_PLUS = \"NUM_PLUS\",\n NUM_MINUS = \"NUM_MINUS\",\n NUM_POWER = \"POWER\",\n NUM_UNARY_MINUS = \"UNARY_MINUS\",\n NUM_LITERAL = \"NUM_LITERAL\",\n REF_ELEMENT = \"REF_ELEMENT\",\n REF_PROPERTY = \"REF_PROPERTY\",\n REF_BUILTIN_ROOT = \"REF_BUILTIN_ROOT\",\n REF_BUILTIN_MEMBER = \"REF_BUILTIN_MEMBER\",\n REF_BUILTIN_FUNCTION = \"REF_BUILTIN_FUNCTION\",\n STR_CONCAT = \"STR_CONCAT\",\n STR_LITERAL = \"STR_LITERAL\",\n AND = \"AND\",\n OR = \"OR\",\n XOR = \"XOR\",\n NOT = \"NOT\",\n BOOLEAN_LITERAL = \"BOOLEAN_LITERAL\",\n LOGICAL_LITERAL = \"LOGICAL_LITERAL\",\n CMP_EQUALS = \"CMP_EQUALS\",\n CMP_NOT_EQUALS = \"CMP_NOT_EQUALS\",\n CMP_LESS_THAN = \"CMP_LESS_THAN\",\n CMP_LESS_THAN_OR_EQUAL = \"CMP_LESS_THAN_OR_EQUAL\",\n CMP_GREATER_THAN = \"CMP_GREATER_THAN\",\n CMP_GREATER_THAN_OR_EQUAL = \"CMP_GREATER_THAN_OR_EQUAL\",\n PARSE_ERROR = \"PARSE_ERROR\" /* to be used when no expr was compiled due to a parse/validation error */,\n}\n"]}
@@ -18,6 +18,24 @@ class Func {
18
18
  this.formalArguments = args;
19
19
  this.checkArgs(args);
20
20
  }
21
+ withDocumentation(documentation) {
22
+ this.documentationRef = documentation;
23
+ return this;
24
+ }
25
+ getDocumentation() {
26
+ return this.documentationRef;
27
+ }
28
+ getFormalArguments() {
29
+ return this.formalArguments;
30
+ }
31
+ getSignatureLabel(displayName = this.name) {
32
+ const preferredArguments = this.formalArguments.filter((argument) => argument.displayLabel !== undefined);
33
+ const signatureArguments = preferredArguments.length > 0
34
+ ? preferredArguments
35
+ : this.formalArguments.filter((argument) => argument.required);
36
+ const labels = signatureArguments.map((argument) => argument.displayLabel?.fallback ?? argument.name);
37
+ return `${displayName}(${labels.join(", ")})`;
38
+ }
21
39
  checkArgumentsAndGetReturnType(argumentTypes, ctx) {
22
40
  this.checkArgumentTypes(argumentTypes, ctx);
23
41
  return this.getReturnType(argumentTypes.map((t) => t[1]));
@@ -61,21 +79,7 @@ class Func {
61
79
  }
62
80
  return this.calculateResult(callingExpr, argumentsReadyForUse);
63
81
  }
64
- /**
65
- * Override to transform individual arguments if needed. After this step, if any of the ExprEvalResult objects in the
66
- * returned array is an ExprEvalError, the function evaluation fails.
67
- * @param callingExpr
68
- * @param evaluatedArguments
69
- * @protected
70
- */
71
82
  transformArguments(callingExpr, evaluatedArguments) { }
72
- /**
73
- * Gets the argument values from the list of provided arguments in the form of 'name' -> ExprEvalResult (which may contain errors).
74
- * Generates an error if a required value is missing.
75
- * @param callingExpr
76
- * @param provided
77
- * @protected
78
- */
79
83
  getArgumentValues(callingExpr, provided) {
80
84
  const result = new Map();
81
85
  const numProvided = provided.length;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expression/function/Func.ts"],"names":[],"mappings":";;;AACA,iHAA2G;AAC3G,4EAA6D;AAE7D,4DAM8B;AAC9B,gDAA0C;AAC1C,kDAA4C;AAC5C,yGAAmG;AACnG,6GAAuG;AAKvG,2GAAqG;AAErG,MAAsB,IAAI;IAIxB,YAAsB,IAAY,EAAE,IAA6B;QAC/D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,IAAA,iCAAS,EAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACxB,MAAM,IAAI,8EAAoC,CAC5C,2BAA2B,CAC5B,CAAC;SACH;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAIM,8BAA8B,CACnC,aAAmD,EACnD,GAAG;QAEH,IAAI,CAAC,kBAAkB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;IAES,kBAAkB,CAC1B,qBAA2D,EAC3D,GAAG;QAEH,MAAM,WAAW,GAAG,qBAAqB,CAAC,MAAM,CAAC;QACjD,IAAI,CAAC,IAAA,iCAAS,EAAC,IAAI,CAAC,eAAe,CAAC,EAAE;YACpC,IAAI,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;gBAC7C,MAAM,IAAI,wEAAiC,CACzC,IAAI,CAAC,IAAI,EACT,uBAAuB,EACvB,IAAI,CAAC,eAAe,CAAC,MAAM,EAC3B,G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oBACrC,mBAAmB,GAAG,IAAI,CAAC;iBAC5B;aACF;SACF;IACH,CAAC;CACF;AA9LD,oBA8LC","file":"expression/function/Func.js","sourcesContent":["import { ExpressionValue } from \"../../value/ExpressionValue.js\";\nimport { IfcExpressionFunctionConfigException } from \"../../error/IfcExpressionFunctionConfigException.js\";\nimport { isNullish } from \"../../util/IfcExpressionUtils.js\";\nimport { FuncArg } from \"./FuncArg.js\";\nimport {\n ExprEvalError,\n ExprEvalMissingRequiredFunctionArgumentErrorObj,\n ExprEvalResult,\n ExprEvalSuccessObj,\n isExprEvalError,\n} from \"../ExprEvalResult.js\";\nimport { ExprKind } from \"../ExprKind.js\";\nimport { Types } from \"../../type/Types.js\";\nimport { MissingFunctionArgumentException } from \"../../error/MissingFunctionArgumentException.js\";\nimport { WrongFunctionArgumentTypeException } from \"../../error/WrongFunctionArgumentTypeException.js\";\nimport { ExprType } from \"../../type/ExprType.js\";\nimport { ParserRuleContext } from \"antlr4\";\nimport { FunctionExpr } from \"./FunctionExpr.js\";\nimport { Expr } from \"../Expr.js\";\nimport { SpuriousFunctionArgumentException } from \"../../error/SpuriousFunctionArgumentException.js\";\n\nexport abstract class Func {\n protected name: string;\n protected formalArguments: Array<FuncArg<unknown>>;\n\n protected constructor(name: string, args: Array<FuncArg<unknown>>) {\n this.name = name;\n if (isNullish(this.name)) {\n throw new IfcExpressionFunctionConfigException(\n \"Function must have a name\"\n );\n }\n this.formalArguments = args;\n this.checkArgs(args);\n }\n\n public abstract getReturnType(argumentTypes: Array<ExprType>): ExprType;\n\n public checkArgumentsAndGetReturnType(\n argumentTypes: Array<[ParserRuleContext, ExprType]>,\n ctx\n ): ExprType {\n this.checkArgumentTypes(argumentTypes, ctx);\n return this.getReturnType(argumentTypes.map((t) => t[1]));\n }\n\n protected checkArgumentTypes(\n providedArgumentTypes: Array<[ParserRuleContext, ExprType]>,\n ctx\n ): void {\n const numProvided = providedArgumentTypes.length;\n if (!isNullish(this.formalArguments)) {\n if (numProvided > this.formalArguments.length) {\n throw new SpuriousFunctionArgumentException(\n this.name,\n \"[unexpected argument]\",\n this.formalArguments.length,\n ctx,\n `Function expects (at most) ${this.formalArguments.length} arguments`\n );\n }\n for (let i = 0; i < this.formalArguments.length; i++) {\n const currentArg: FuncArg<unknown> = this.formalArguments[i];\n if (numProvided > i) {\n Types.requireWeakIsAssignableFrom(\n this.formalArguments[i].getType(),\n providedArgumentTypes[i][1],\n () =>\n new WrongFunctionArgumentTypeException(\n this.name,\n this.formalArguments[i].name,\n this.formalArguments[i].getType(),\n providedArgumentTypes[i][1],\n i,\n providedArgumentTypes[i][0]\n )\n );\n } else {\n if (currentArg.hasDefaultValue()) {\n //should be fine.\n }\n if (currentArg.required) {\n throw new MissingFunctionArgumentException(\n this.name,\n currentArg.name,\n i,\n ctx\n );\n }\n }\n }\n }\n }\n\n public getName(): string {\n return this.name;\n }\n\n public evaluate(\n callingExpr: FunctionExpr,\n funcArgs: Array<ExprEvalResult<ExpressionValue>>\n ): ExprEvalResult<ExpressionValue> {\n const evaluatedArguments = this.getArgumentValues(callingExpr, funcArgs);\n if (isExprEvalError(evaluatedArguments)) {\n return evaluatedArguments;\n }\n const argumentsReadyForUse = new Map<string, ExpressionValue>();\n for (const [argName, argValue] of evaluatedArguments.entries()) {\n if (isExprEvalError(argValue)) {\n return argValue;\n }\n argumentsReadyForUse.set(argName, argValue.result);\n }\n return this.calculateResult(callingExpr, argumentsReadyForUse);\n }\n\n /**\n * Subclasses must provide the funcation evaluation code here.\n * @param callingExpr\n * @param evaluatedArguments\n * @protected\n */\n protected abstract calculateResult(\n callingExpr: FunctionExpr,\n evaluatedArguments: Map<string, ExpressionValue>\n ): ExprEvalResult<ExpressionValue>;\n\n /**\n * Override to transform individual arguments if needed. After this step, if any of the ExprEvalResult objects in the\n * returned array is an ExprEvalError, the function evaluation fails.\n * @param callingExpr\n * @param evaluatedArguments\n * @protected\n */\n protected transformArguments(\n callingExpr: Expr<any>,\n evaluatedArguments: Map<string, ExprEvalResult<ExpressionValue>>\n ): void {}\n\n /**\n * Gets the argument values from the list of provided arguments in the form of 'name' -> ExprEvalResult (which may contain errors).\n * Generates an error if a required value is missing.\n * @param callingExpr\n * @param provided\n * @protected\n */\n protected getArgumentValues(\n callingExpr: FunctionExpr,\n provided: Array<ExprEvalResult<ExpressionValue>>\n ): Map<string, ExprEvalResult<ExpressionValue>> | ExprEvalError {\n const result = new Map<string, ExprEvalResult<ExpressionValue>>();\n const numProvided = provided.length;\n if (!isNullish(this.formalArguments)) {\n for (let i = 0; i < this.formalArguments.length; i++) {\n const currentArg: FuncArg<unknown> = this.formalArguments[i];\n if (numProvided > i) {\n result.set(\n currentArg.name,\n currentArg.transformValue(callingExpr, provided[i])\n );\n } else {\n if (currentArg.hasDefaultValue()) {\n result.set(\n currentArg.name,\n new ExprEvalSuccessObj(currentArg.defaultValue as ExpressionValue)\n );\n }\n if (currentArg.required) {\n return new ExprEvalMissingRequiredFunctionArgumentErrorObj(\n ExprKind.FUNCTION_ARGUMENTS,\n `Required argument ${currentArg.name}, expected at position ${i} (starting at 0), is missing`,\n this.name,\n currentArg.name,\n i,\n callingExpr.getTextSpan()\n );\n }\n }\n }\n }\n this.transformArguments(callingExpr, result);\n return result;\n }\n\n private checkArgs(args: Array<FuncArg<unknown>>): void {\n if (!Array.isArray(this.formalArguments)) {\n throw new IfcExpressionFunctionConfigException(\n \"Formal function arguments is not an array\"\n );\n }\n let optionalArgsReached: boolean = false;\n const names = new Set<string>();\n for (let i = 0; i < this.formalArguments.length; i++) {\n if (names.has(this.formalArguments[i].name)) {\n throw new IfcExpressionFunctionConfigException(\n `Duplicate argument name '${this.formalArguments[i].name}'.`\n );\n }\n if (optionalArgsReached) {\n if (this.formalArguments[i].required) {\n throw new IfcExpressionFunctionConfigException(\n `Optional arguments must follow required ones. Argument '${this.formalArguments[i].name}' is required but follows an optional one`\n );\n }\n } else {\n if (!this.formalArguments[i].required) {\n optionalArgsReached = true;\n }\n }\n }\n }\n}\n"]}
1
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KAAK,CAAC;QACzC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpD,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE;gBAC3C,MAAM,IAAI,8EAAoC,CAC5C,4BAA4B,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAC7D,CAAC;aACH;YACD,IAAI,mBAAmB,EAAE;gBACvB,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;oBACpC,MAAM,IAAI,8EAAoC,CAC5C,2DAA2D,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,2CAA2C,CACnI,CAAC;iBACH;aACF;iBAAM;gBACL,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;oBACrC,mBAAmB,GAAG,IAAI,CAAC;iBAC5B;aACF;SACF;IACH,CAAC;CACF;AAtMD,oBAsMC","file":"expression/function/Func.js","sourcesContent":["import { ExpressionValue } from \"../../value/ExpressionValue.js\";\nimport { IfcExpressionFunctionConfigException } from \"../../error/IfcExpressionFunctionConfigException.js\";\nimport { isNullish } from \"../../util/IfcExpressionUtils.js\";\nimport { FuncArg } from \"./FuncArg.js\";\nimport {\n ExprEvalError,\n ExprEvalMissingRequiredFunctionArgumentErrorObj,\n ExprEvalResult,\n ExprEvalSuccessObj,\n isExprEvalError,\n} from \"../ExprEvalResult.js\";\nimport { ExprKind } from \"../ExprKind.js\";\nimport { Types } from \"../../type/Types.js\";\nimport { MissingFunctionArgumentException } from \"../../error/MissingFunctionArgumentException.js\";\nimport { WrongFunctionArgumentTypeException } from \"../../error/WrongFunctionArgumentTypeException.js\";\nimport { ExprType } from \"../../type/ExprType.js\";\nimport { ParserRuleContext } from \"antlr4ng\";\nimport { FunctionExpr } from \"./FunctionExpr.js\";\nimport { Expr } from \"../Expr.js\";\nimport { SpuriousFunctionArgumentException } from \"../../error/SpuriousFunctionArgumentException.js\";\nimport { LocalizedText } from \"../../documentation/Documentation.js\";\n\nexport abstract class Func {\n protected name: string;\n protected formalArguments: Array<FuncArg<unknown>>;\n protected documentationRef?: LocalizedText;\n\n protected constructor(name: string, args: Array<FuncArg<unknown>>) {\n this.name = name;\n if (isNullish(this.name)) {\n throw new IfcExpressionFunctionConfigException(\n \"Function must have a name\"\n );\n }\n this.formalArguments = args;\n this.checkArgs(args);\n }\n\n public abstract getReturnType(argumentTypes: Array<ExprType>): ExprType;\n\n public withDocumentation(documentation: LocalizedText): this {\n this.documentationRef = documentation;\n return this;\n }\n\n public getDocumentation(): LocalizedText | undefined {\n return this.documentationRef;\n }\n\n public getFormalArguments(): ReadonlyArray<FuncArg<unknown>> {\n return this.formalArguments;\n }\n\n public getSignatureLabel(displayName = this.name): string {\n const preferredArguments = this.formalArguments.filter(\n (argument) => argument.displayLabel !== undefined\n );\n const signatureArguments =\n preferredArguments.length > 0\n ? preferredArguments\n : this.formalArguments.filter((argument) => argument.required);\n const labels = signatureArguments.map(\n (argument) => argument.displayLabel?.fallback ?? argument.name\n );\n return `${displayName}(${labels.join(\", \")})`;\n }\n\n public checkArgumentsAndGetReturnType(\n argumentTypes: Array<[ParserRuleContext, ExprType]>,\n ctx\n ): ExprType {\n this.checkArgumentTypes(argumentTypes, ctx);\n return this.getReturnType(argumentTypes.map((t) => t[1]));\n }\n\n protected checkArgumentTypes(\n providedArgumentTypes: Array<[ParserRuleContext, ExprType]>,\n ctx\n ): void {\n const numProvided = providedArgumentTypes.length;\n if (!isNullish(this.formalArguments)) {\n if (numProvided > this.formalArguments.length) {\n throw new SpuriousFunctionArgumentException(\n this.name,\n \"[unexpected argument]\",\n this.formalArguments.length,\n ctx,\n `Function expects (at most) ${this.formalArguments.length} arguments`\n );\n }\n for (let i = 0; i < this.formalArguments.length; i++) {\n const currentArg: FuncArg<unknown> = this.formalArguments[i];\n if (numProvided > i) {\n Types.requireWeakIsAssignableFrom(\n this.formalArguments[i].getType(),\n providedArgumentTypes[i][1],\n () =>\n new WrongFunctionArgumentTypeException(\n this.name,\n this.formalArguments[i].name,\n this.formalArguments[i].getType(),\n providedArgumentTypes[i][1],\n i,\n providedArgumentTypes[i][0]\n )\n );\n } else {\n if (currentArg.hasDefaultValue()) {\n //should be fine.\n }\n if (currentArg.required) {\n throw new MissingFunctionArgumentException(\n this.name,\n currentArg.name,\n i,\n ctx\n );\n }\n }\n }\n }\n }\n\n public getName(): string {\n return this.name;\n }\n\n public evaluate(\n callingExpr: FunctionExpr,\n funcArgs: Array<ExprEvalResult<ExpressionValue>>\n ): ExprEvalResult<ExpressionValue> {\n const evaluatedArguments = this.getArgumentValues(callingExpr, funcArgs);\n if (isExprEvalError(evaluatedArguments)) {\n return evaluatedArguments;\n }\n const argumentsReadyForUse = new Map<string, ExpressionValue>();\n for (const [argName, argValue] of evaluatedArguments.entries()) {\n if (isExprEvalError(argValue)) {\n return argValue;\n }\n argumentsReadyForUse.set(argName, argValue.result);\n }\n return this.calculateResult(callingExpr, argumentsReadyForUse);\n }\n\n protected abstract calculateResult(\n callingExpr: FunctionExpr,\n evaluatedArguments: Map<string, ExpressionValue>\n ): ExprEvalResult<ExpressionValue>;\n\n protected transformArguments(\n callingExpr: Expr<any>,\n evaluatedArguments: Map<string, ExprEvalResult<ExpressionValue>>\n ): void {}\n\n protected getArgumentValues(\n callingExpr: FunctionExpr,\n provided: Array<ExprEvalResult<ExpressionValue>>\n ): Map<string, ExprEvalResult<ExpressionValue>> | ExprEvalError {\n const result = new Map<string, ExprEvalResult<ExpressionValue>>();\n const numProvided = provided.length;\n if (!isNullish(this.formalArguments)) {\n for (let i = 0; i < this.formalArguments.length; i++) {\n const currentArg: FuncArg<unknown> = this.formalArguments[i];\n if (numProvided > i) {\n result.set(\n currentArg.name,\n currentArg.transformValue(callingExpr, provided[i])\n );\n } else {\n if (currentArg.hasDefaultValue()) {\n result.set(\n currentArg.name,\n new ExprEvalSuccessObj(currentArg.defaultValue as ExpressionValue)\n );\n }\n if (currentArg.required) {\n return new ExprEvalMissingRequiredFunctionArgumentErrorObj(\n ExprKind.FUNCTION_ARGUMENTS,\n `Required argument ${currentArg.name}, expected at position ${i} (starting at 0), is missing`,\n this.name,\n currentArg.name,\n i,\n callingExpr.getTextSpan()\n );\n }\n }\n }\n }\n this.transformArguments(callingExpr, result);\n return result;\n }\n\n private checkArgs(args: Array<FuncArg<unknown>>): void {\n if (!Array.isArray(this.formalArguments)) {\n throw new IfcExpressionFunctionConfigException(\n \"Formal function arguments is not an array\"\n );\n }\n let optionalArgsReached: boolean = false;\n const names = new Set<string>();\n for (let i = 0; i < this.formalArguments.length; i++) {\n if (names.has(this.formalArguments[i].name)) {\n throw new IfcExpressionFunctionConfigException(\n `Duplicate argument name '${this.formalArguments[i].name}'.`\n );\n }\n if (optionalArgsReached) {\n if (this.formalArguments[i].required) {\n throw new IfcExpressionFunctionConfigException(\n `Optional arguments must follow required ones. Argument '${this.formalArguments[i].name}' is required but follows an optional one`\n );\n }\n } else {\n if (!this.formalArguments[i].required) {\n optionalArgsReached = true;\n }\n }\n }\n }\n}\n"]}
@@ -12,11 +12,11 @@ class FuncArg {
12
12
  getType() {
13
13
  return Types_js_1.Type.ANY;
14
14
  }
15
- /**
16
- * For the value provided for a specific invocation of the function, return an appropriate result (maybe some kind of type conversion or type check might happen here)
17
- *
18
- * @param invocationValue
19
- */
15
+ withDocumentation(displayLabel, documentation) {
16
+ this._displayLabel = displayLabel;
17
+ this._documentation = documentation;
18
+ return this;
19
+ }
20
20
  transformValue(callingExpr, invocationValue) {
21
21
  return invocationValue;
22
22
  }
@@ -29,6 +29,12 @@ class FuncArg {
29
29
  get defaultValue() {
30
30
  return this._defaultValue;
31
31
  }
32
+ get displayLabel() {
33
+ return this._displayLabel;
34
+ }
35
+ get documentation() {
36
+ return this._documentation;
37
+ }
32
38
  hasDefaultValue() {
33
39
  return !(0, IfcExpressionUtils_js_1.isNullish)(this._defaultValue);
34
40
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/expression/function/FuncArg.ts"],"names":[],"mappings":";;;AAEA,4EAA6D;AAC7D,kDAA2C;AAI3C,MAAa,OAAO;IAKlB,YAAY,QAAiB,EAAE,IAAY,EAAE,YAAgB;QAC3D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAEM,OAAO;QACZ,OAAO,eAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,cAAc,CACnB,WAAyB,EACzB,eAAgD;QAEhD,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,eAAe;QACb,OAAO,CAAC,IAAA,iCAAS,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF;AA1CD,0BA0CC","file":"expression/function/FuncArg.js","sourcesContent":["import { ExpressionValue } from \"../../value/ExpressionValue.js\";\nimport { ExprEvalResult } from \"../ExprEvalResult.js\";\nimport { isNullish } from \"../../util/IfcExpressionUtils.js\";\nimport { Type } from \"../../type/Types.js\";\nimport { ExprType } from \"../../type/ExprType.js\";\nimport { FunctionExpr } from \"./FunctionExpr.js\";\n\nexport class FuncArg<T> {\n protected _required: boolean;\n protected _name: string;\n protected _defaultValue?: T;\n\n constructor(required: boolean, name: string, defaultValue?: T) {\n this._required = required;\n this._name = name;\n this._defaultValue = defaultValue;\n }\n\n public getType(): ExprType {\n return Type.ANY;\n }\n\n /**\n * For the value provided for a specific invocation of the function, return an appropriate result (maybe some kind of type conversion or type check might happen here)\n *\n * @param invocationValue\n */\n public transformValue(\n callingExpr: FunctionExpr,\n invocationValue: ExprEvalResult<ExpressionValue>\n ): ExprEvalResult<ExpressionValue> {\n return invocationValue;\n }\n\n get required(): boolean {\n return this._required;\n }\n\n get name(): string {\n return this._name;\n }\n\n get defaultValue(): T | undefined {\n return this._defaultValue;\n }\n\n hasDefaultValue(): boolean {\n return !isNullish(this._defaultValue);\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/expression/function/FuncArg.ts"],"names":[],"mappings":";;;AAEA,4EAA6D;AAC7D,kDAA2C;AAK3C,MAAa,OAAO;IAOlB,YAAY,QAAiB,EAAE,IAAY,EAAE,YAAgB;QAC3D,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAEM,OAAO;QACZ,OAAO,eAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEM,iBAAiB,CACtB,YAA2B,EAC3B,aAA4B;QAE5B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,cAAc,CACnB,WAAyB,EACzB,eAAgD;QAEhD,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,eAAe;QACb,OAAO,CAAC,IAAA,iCAAS,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF;AAxDD,0BAwDC","file":"expression/function/FuncArg.js","sourcesContent":["import { ExpressionValue } from \"../../value/ExpressionValue.js\";\nimport { ExprEvalResult } from \"../ExprEvalResult.js\";\nimport { isNullish } from \"../../util/IfcExpressionUtils.js\";\nimport { Type } from \"../../type/Types.js\";\nimport { ExprType } from \"../../type/ExprType.js\";\nimport { FunctionExpr } from \"./FunctionExpr.js\";\nimport { LocalizedText } from \"../../documentation/Documentation.js\";\n\nexport class FuncArg<T> {\n protected _required: boolean;\n protected _name: string;\n protected _defaultValue?: T;\n protected _displayLabel?: LocalizedText;\n protected _documentation?: LocalizedText;\n\n constructor(required: boolean, name: string, defaultValue?: T) {\n this._required = required;\n this._name = name;\n this._defaultValue = defaultValue;\n }\n\n public getType(): ExprType {\n return Type.ANY;\n }\n\n public withDocumentation(\n displayLabel: LocalizedText,\n documentation: LocalizedText\n ): this {\n this._displayLabel = displayLabel;\n this._documentation = documentation;\n return this;\n }\n\n public transformValue(\n callingExpr: FunctionExpr,\n invocationValue: ExprEvalResult<ExpressionValue>\n ): ExprEvalResult<ExpressionValue> {\n return invocationValue;\n }\n\n get required(): boolean {\n return this._required;\n }\n\n get name(): string {\n return this._name;\n }\n\n get defaultValue(): T | undefined {\n return this._defaultValue;\n }\n\n get displayLabel(): LocalizedText | undefined {\n return this._displayLabel;\n }\n\n get documentation(): LocalizedText | undefined {\n return this._documentation;\n }\n\n hasDefaultValue(): boolean {\n return !isNullish(this._defaultValue);\n }\n}\n"]}
@@ -41,12 +41,44 @@ function registerOrDie(fnKey, func) {
41
41
  }
42
42
  builtinFunctions.set(fnKey, func);
43
43
  }
44
+ function toDocKey(label) {
45
+ return label.replace(/[^a-zA-Z0-9]+/g, "_");
46
+ }
47
+ function withDocumentation(func, summary, args = []) {
48
+ func.withDocumentation({
49
+ key: `function.${func.getName()}.summary`,
50
+ fallback: summary,
51
+ });
52
+ args.forEach((argument, index) => {
53
+ const formalArgument = func.getFormalArguments()[index];
54
+ if (!formalArgument) {
55
+ return;
56
+ }
57
+ const docKey = toDocKey(argument.label);
58
+ formalArgument.withDocumentation({
59
+ key: `function.${func.getName()}.arg.${docKey}.label`,
60
+ fallback: argument.label,
61
+ }, {
62
+ key: `function.${func.getName()}.arg.${docKey}.summary`,
63
+ fallback: argument.documentation,
64
+ });
65
+ });
66
+ return func;
67
+ }
44
68
  function registerFunc(func, ...aliases) {
45
69
  const fnKey = func.getName();
46
70
  const keys = [...aliases];
47
71
  keys.unshift(fnKey);
48
72
  keys.forEach((key) => registerOrDie(IfcExpressionFunctions.normalizeName(key), func));
49
73
  }
74
+ function documentAttributeAccessor(name, summary) {
75
+ return withDocumentation(new AttributeAccessorFunction_js_1.AttributeAccessorFunction(name, Types_js_1.Type.STRING), summary, [
76
+ {
77
+ label: "object",
78
+ documentation: "The IFC object to read from",
79
+ },
80
+ ]);
81
+ }
50
82
  class IfcExpressionFunctions {
51
83
  static normalizeName(name) {
52
84
  if ((0, IfcExpressionUtils_js_1.isNullish)(name)) {
@@ -66,50 +98,174 @@ class IfcExpressionFunctions {
66
98
  }
67
99
  return builtinFunctions.get(this.normalizeName(name));
68
100
  }
101
+ static getBuiltinFunctionNames() {
102
+ return [...builtinFunctions.keys()].sort((left, right) => left.localeCompare(right));
103
+ }
69
104
  }
70
105
  exports.IfcExpressionFunctions = IfcExpressionFunctions;
71
- registerFunc(new MAP_js_1.MAP());
72
- registerFunc(new CHOOSE_js_1.CHOOSE());
73
- registerFunc(new AT_js_1.AT());
74
- registerFunc(new IF_js_1.IF());
75
- registerFunc(new ROUND_js_1.ROUND());
76
- registerFunc(new AttributeAccessorFunction_js_1.AttributeAccessorFunction("name", Types_js_1.Type.STRING));
77
- registerFunc(new AttributeAccessorFunction_js_1.AttributeAccessorFunction("guid", Types_js_1.Type.STRING));
78
- registerFunc(new AttributeAccessorFunction_js_1.AttributeAccessorFunction("ifcClass", Types_js_1.Type.STRING));
79
- registerFunc(new AttributeAccessorFunction_js_1.AttributeAccessorFunction("description", Types_js_1.Type.STRING));
80
- registerFunc(new AttributeAccessorFunction_js_1.AttributeAccessorFunction("value", Types_js_1.Types.or(Types_js_1.Type.STRING, Types_js_1.Type.NUMERIC, Types_js_1.Type.BOOLEAN, Types_js_1.Type.ARRAY)));
81
- registerFunc(new PROPERTYSET_js_1.PROPERTYSET());
82
- registerFunc(new PROPERTY_js_1.PROPERTY());
83
- registerFunc(new TYPE_js_1.TYPE());
84
- registerFunc(new NOT_js_1.NOT());
85
- registerFunc(new TOSTRING_js_1.TOSTRING());
86
- registerFunc(new TONUMERIC_js_1.TONUMERIC(), "TONUMBER");
87
- registerFunc(new TOBOOLEAN_js_1.TOBOOLEAN());
88
- registerFunc(new TOLOGICAL_js_1.TOLOGICAL(), "NOTFOUNDASUNKNOWN");
89
- registerFunc(new TOIFCDATE_js_1.TOIFCDATE());
90
- registerFunc(new TOIFCTIME_js_1.TOIFCTIME());
91
- registerFunc(new TOIFCDATETIME_js_1.TOIFCDATETIME());
92
- registerFunc(new TOIFCDURATION_js_1.TOIFCDURATION());
93
- registerFunc(new TOIFCTIMESTAMP_js_1.TOIFCTIMESTAMP());
94
- registerFunc(new ADDDURATION_js_1.ADDDURATION());
95
- registerFunc(new TOLOWERCASE_js_1.TOLOWERCASE());
96
- registerFunc(new TOUPPERCASE_js_1.TOUPPERCASE());
97
- registerFunc(new SUBSTRING_js_1.SUBSTRING());
98
- registerFunc(new SPLIT_js_1.SPLIT());
99
- registerFunc(new EXISTS_js_1.EXISTS());
100
- registerFunc(new FuncBooleanBinary_js_1.FuncBooleanBinary("AND", "and"));
101
- registerFunc(new FuncBooleanBinary_js_1.FuncBooleanBinary("OR", "or"));
102
- registerFunc(new FuncBooleanBinary_js_1.FuncBooleanBinary("XOR", "xor"));
103
- registerFunc(new FuncBooleanBinary_js_1.FuncBooleanBinary("IMPLIES", "implies"));
104
- registerFunc(new EQUALS_js_1.EQUALS());
105
- registerFunc(new CompareMagnitudes_js_1.CompareMagnitudes("GREATERTHAN", (cmp) => cmp > 0));
106
- registerFunc(new CompareMagnitudes_js_1.CompareMagnitudes("GREATERTHANOREQUAL", (cmp) => cmp >= 0));
107
- registerFunc(new CompareMagnitudes_js_1.CompareMagnitudes("LESSTHAN", (cmp) => cmp < 0));
108
- registerFunc(new CompareMagnitudes_js_1.CompareMagnitudes("LESSTHANOREQUAL", (cmp) => cmp <= 0));
109
- registerFunc(new MatchesPattern_js_1.MatchesPattern("CONTAINS", true, false));
110
- registerFunc(new MatchesPattern_js_1.MatchesPattern("MATCHES", true, true));
111
- registerFunc(new MatchesPattern_js_1.MatchesPattern("REGEXCONTAINS", false, false));
112
- registerFunc(new MatchesPattern_js_1.MatchesPattern("REGEXMATCHES", false, true));
106
+ registerFunc(withDocumentation(new MAP_js_1.MAP(), "map an input value through a list of key/value mappings", [
107
+ { label: "input", documentation: "The value to look up" },
108
+ {
109
+ label: "mappings",
110
+ documentation: "The mapping table as [key, value] pairs",
111
+ },
112
+ {
113
+ label: "defaultValue",
114
+ documentation: "The fallback value to return when no mapping matches",
115
+ },
116
+ ]));
117
+ registerFunc(withDocumentation(new CHOOSE_js_1.CHOOSE(), "return the value from the first matching boolean case", [
118
+ {
119
+ label: "cases",
120
+ documentation: "The candidate [condition, value] pairs to evaluate in order",
121
+ },
122
+ {
123
+ label: "defaultValue",
124
+ documentation: "The fallback value when no case evaluates to true",
125
+ },
126
+ ]));
127
+ registerFunc(withDocumentation(new AT_js_1.AT(), "return the item at the specified index from an array or tuple", [
128
+ { label: "input", documentation: "The array or tuple to read from" },
129
+ { label: "index", documentation: "The zero-based index to read" },
130
+ ]));
131
+ registerFunc(withDocumentation(new IF_js_1.IF(), "choose one of two or three values based on a boolean or logical condition", [
132
+ { label: "condition", documentation: "The condition to evaluate" },
133
+ {
134
+ label: "thenValue",
135
+ documentation: "The value returned when the condition is true",
136
+ },
137
+ {
138
+ label: "elseValue",
139
+ documentation: "The value returned when the condition is false",
140
+ },
141
+ {
142
+ label: "unknownValue",
143
+ documentation: "The value returned when a logical condition is unknown",
144
+ },
145
+ ]));
146
+ registerFunc(withDocumentation(new ROUND_js_1.ROUND(), "round a numeric value to the requested number of decimal places", [
147
+ { label: "input", documentation: "The numeric value to round" },
148
+ {
149
+ label: "decimals",
150
+ documentation: "The number of decimal places to keep",
151
+ },
152
+ ]));
153
+ registerFunc(documentAttributeAccessor("name", "read the name attribute from an IFC object"));
154
+ registerFunc(documentAttributeAccessor("guid", "read the global identifier from an IFC object"));
155
+ registerFunc(documentAttributeAccessor("ifcClass", "read the IFC class name from an IFC object"));
156
+ registerFunc(documentAttributeAccessor("description", "read the description attribute from an IFC object"));
157
+ registerFunc(withDocumentation(new AttributeAccessorFunction_js_1.AttributeAccessorFunction("value", Types_js_1.Types.or(Types_js_1.Type.STRING, Types_js_1.Type.NUMERIC, Types_js_1.Type.BOOLEAN, Types_js_1.Type.ARRAY)), "read the value of an IFC property object", [{ label: "object", documentation: "The IFC property object to read from" }]));
158
+ registerFunc(withDocumentation(new PROPERTYSET_js_1.PROPERTYSET(), "resolve a property set on an IFC object", [
159
+ { label: "object", documentation: "The IFC object to inspect" },
160
+ {
161
+ label: "name",
162
+ documentation: "The name of the property set to resolve",
163
+ },
164
+ ]));
165
+ registerFunc(withDocumentation(new PROPERTY_js_1.PROPERTY(), "resolve a property on an IFC element, type object, or property set", [
166
+ { label: "object", documentation: "The IFC object to inspect" },
167
+ { label: "name", documentation: "The name of the property to resolve" },
168
+ ]));
169
+ registerFunc(withDocumentation(new TYPE_js_1.TYPE(), "resolve the IFC type object of an element", [
170
+ { label: "object", documentation: "The IFC element to inspect" },
171
+ ]));
172
+ registerFunc(withDocumentation(new NOT_js_1.NOT(), "negate a boolean or logical value", [
173
+ { label: "value", documentation: "The value to negate" },
174
+ ]));
175
+ registerFunc(withDocumentation(new TOSTRING_js_1.TOSTRING(), "convert a value to its string representation", [{ label: "input", documentation: "The value to convert" }]));
176
+ registerFunc(withDocumentation(new TONUMERIC_js_1.TONUMERIC(), "convert a value to a numeric representation", [{ label: "input", documentation: "The value to convert" }]), "TONUMBER");
177
+ registerFunc(withDocumentation(new TOBOOLEAN_js_1.TOBOOLEAN(), "convert a value to a boolean representation", [{ label: "input", documentation: "The value to convert" }]));
178
+ registerFunc(withDocumentation(new TOLOGICAL_js_1.TOLOGICAL(), "convert a value to a logical representation that can be true, false, or unknown", [{ label: "input", documentation: "The value to convert" }]), "NOTFOUNDASUNKNOWN");
179
+ registerFunc(withDocumentation(new TOIFCDATE_js_1.TOIFCDATE(), "convert a value to an IFC date", [
180
+ { label: "input", documentation: "The value to convert" },
181
+ ]));
182
+ registerFunc(withDocumentation(new TOIFCTIME_js_1.TOIFCTIME(), "convert a value to an IFC time", [
183
+ { label: "input", documentation: "The value to convert" },
184
+ ]));
185
+ registerFunc(withDocumentation(new TOIFCDATETIME_js_1.TOIFCDATETIME(), "convert a value to an IFC date-time", [{ label: "input", documentation: "The value to convert" }]));
186
+ registerFunc(withDocumentation(new TOIFCDURATION_js_1.TOIFCDURATION(), "convert a value to an IFC duration", [
187
+ { label: "input", documentation: "The value to convert" },
188
+ ]));
189
+ registerFunc(withDocumentation(new TOIFCTIMESTAMP_js_1.TOIFCTIMESTAMP(), "convert a value to an IFC timestamp", [{ label: "input", documentation: "The value to convert" }]));
190
+ registerFunc(withDocumentation(new ADDDURATION_js_1.ADDDURATION(), "add a duration to an IFC date-time or timestamp", [
191
+ {
192
+ label: "pointInTime",
193
+ documentation: "The IFC date-time or timestamp to shift",
194
+ },
195
+ { label: "duration", documentation: "The duration to add" },
196
+ ]));
197
+ registerFunc(withDocumentation(new TOLOWERCASE_js_1.TOLOWERCASE(), "convert a string to lowercase", [
198
+ { label: "input", documentation: "The string to transform" },
199
+ ]));
200
+ registerFunc(withDocumentation(new TOUPPERCASE_js_1.TOUPPERCASE(), "convert a string to uppercase", [
201
+ { label: "input", documentation: "The string to transform" },
202
+ ]));
203
+ registerFunc(withDocumentation(new SUBSTRING_js_1.SUBSTRING(), "extract a substring from a string", [
204
+ { label: "input", documentation: "The source string" },
205
+ { label: "from", documentation: "The inclusive start index" },
206
+ { label: "to", documentation: "The exclusive end index" },
207
+ ]));
208
+ registerFunc(withDocumentation(new SPLIT_js_1.SPLIT(), "split a string into an array of substrings", [
209
+ { label: "input", documentation: "The source string" },
210
+ { label: "separator", documentation: "The separator string to split on" },
211
+ { label: "limit", documentation: "The maximum number of resulting items" },
212
+ ]));
213
+ registerFunc(withDocumentation(new EXISTS_js_1.EXISTS(), "check whether an IFC reference can be resolved", [{ label: "object", documentation: "The IFC reference to test" }]));
214
+ registerFunc(withDocumentation(new FuncBooleanBinary_js_1.FuncBooleanBinary("AND", "and"), "return true only when both inputs are true", [
215
+ { label: "left", documentation: "The left logical operand" },
216
+ { label: "right", documentation: "The right logical operand" },
217
+ ]));
218
+ registerFunc(withDocumentation(new FuncBooleanBinary_js_1.FuncBooleanBinary("OR", "or"), "return true when at least one input is true", [
219
+ { label: "left", documentation: "The left logical operand" },
220
+ { label: "right", documentation: "The right logical operand" },
221
+ ]));
222
+ registerFunc(withDocumentation(new FuncBooleanBinary_js_1.FuncBooleanBinary("XOR", "xor"), "return true when exactly one input is true", [
223
+ { label: "left", documentation: "The left logical operand" },
224
+ { label: "right", documentation: "The right logical operand" },
225
+ ]));
226
+ registerFunc(withDocumentation(new FuncBooleanBinary_js_1.FuncBooleanBinary("IMPLIES", "implies"), "evaluate logical implication from left to right", [
227
+ { label: "left", documentation: "The premise" },
228
+ { label: "right", documentation: "The consequence" },
229
+ ]));
230
+ registerFunc(withDocumentation(new EQUALS_js_1.EQUALS(), "compare two values for equality", [
231
+ { label: "left", documentation: "The left value to compare" },
232
+ { label: "right", documentation: "The right value to compare" },
233
+ ]));
234
+ registerFunc(withDocumentation(new CompareMagnitudes_js_1.CompareMagnitudes("GREATERTHAN", (cmp) => cmp > 0), "return true when the left value is greater than the right value", [
235
+ { label: "left", documentation: "The left value to compare" },
236
+ { label: "right", documentation: "The right value to compare" },
237
+ ]));
238
+ registerFunc(withDocumentation(new CompareMagnitudes_js_1.CompareMagnitudes("GREATERTHANOREQUAL", (cmp) => cmp >= 0), "return true when the left value is greater than or equal to the right value", [
239
+ { label: "left", documentation: "The left value to compare" },
240
+ { label: "right", documentation: "The right value to compare" },
241
+ ]));
242
+ registerFunc(withDocumentation(new CompareMagnitudes_js_1.CompareMagnitudes("LESSTHAN", (cmp) => cmp < 0), "return true when the left value is less than the right value", [
243
+ { label: "left", documentation: "The left value to compare" },
244
+ { label: "right", documentation: "The right value to compare" },
245
+ ]));
246
+ registerFunc(withDocumentation(new CompareMagnitudes_js_1.CompareMagnitudes("LESSTHANOREQUAL", (cmp) => cmp <= 0), "return true when the left value is less than or equal to the right value", [
247
+ { label: "left", documentation: "The left value to compare" },
248
+ { label: "right", documentation: "The right value to compare" },
249
+ ]));
250
+ registerFunc(withDocumentation(new MatchesPattern_js_1.MatchesPattern("CONTAINS", true, false), "check whether the input contains a simple wildcard pattern", [
251
+ { label: "input", documentation: "The source string" },
252
+ { label: "pattern", documentation: "The wildcard pattern to search for" },
253
+ ]));
254
+ registerFunc(withDocumentation(new MatchesPattern_js_1.MatchesPattern("MATCHES", true, true), "check whether the input fully matches a simple wildcard pattern", [
255
+ { label: "input", documentation: "The source string" },
256
+ { label: "pattern", documentation: "The wildcard pattern to match" },
257
+ ]));
258
+ registerFunc(withDocumentation(new MatchesPattern_js_1.MatchesPattern("REGEXCONTAINS", false, false), "check whether the input contains a regular-expression match", [
259
+ { label: "input", documentation: "The source string" },
260
+ {
261
+ label: "pattern",
262
+ documentation: "The regular expression to search for",
263
+ },
264
+ ]));
265
+ registerFunc(withDocumentation(new MatchesPattern_js_1.MatchesPattern("REGEXMATCHES", false, true), "check whether the input fully matches a regular expression", [
266
+ { label: "input", documentation: "The source string" },
267
+ { label: "pattern", documentation: "The regular expression to match" },
268
+ ]));
113
269
  registerFunc(new ReplacePattern_js_1.ReplacePattern("REPLACE", true));
114
270
  registerFunc(new ReplacePattern_js_1.ReplacePattern("REGEXREPLACE", false));
115
271
  //# sourceMappingURL=IfcExpressionFunctions.js.map