@rsconcept/domain 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{analyzer-B35QsI3L.d.ts → analyzer-BcPMzR38.d.ts} +2 -2
- package/dist/{api-DgecYHjR.d.ts → api-BRrnB6yd.d.ts} +4 -2
- package/dist/{ast-annotations-DclU1Ser.d.ts → ast-annotations-B0XO6380.d.ts} +2 -2
- package/dist/{calculator-B-1p712X.d.ts → calculator-SVf1trzN.d.ts} +2 -2
- package/dist/cctext/index.js +1 -2
- package/dist/cctext/language-api.d.ts +11 -12
- package/dist/cctext/language.d.ts +13 -14
- package/dist/{diagnostics-D4_B7rt2.d.ts → diagnostics-DC6QECex.d.ts} +3 -3
- package/dist/{diagnostics-D1Cp21nP.js → diagnostics-D_4TpAH4.js} +4 -5
- package/dist/{diagnostics-D1Cp21nP.js.map → diagnostics-D_4TpAH4.js.map} +1 -1
- package/dist/{error-S1JghCNN.d.ts → error-DBbO_NIg.d.ts} +2 -1
- package/dist/graph/index.js +1 -2
- package/dist/{index-DzvllU3P.d.ts → index-CEOeehqz.d.ts} +5 -5
- package/dist/{index-D-w-bgei.d.ts → index-CEUOBGLn.d.ts} +6 -5
- package/dist/index.d.ts +8 -7
- package/dist/index.js +4 -3
- package/dist/library/diagnostics.d.ts +1 -1
- package/dist/library/diagnostics.js +1 -2
- package/dist/library/folder-tree.d.ts +2 -3
- package/dist/library/index.d.ts +5 -5
- package/dist/library/index.js +1 -1
- package/dist/library/library-api.d.ts +2 -3
- package/dist/library/oss-api.d.ts +5 -6
- package/dist/library/oss-api.js +2 -4
- package/dist/library/oss-api.js.map +1 -1
- package/dist/library/oss-layout-api.d.ts +4 -5
- package/dist/library/oss.d.ts +16 -16
- package/dist/library/oss.js +1 -1
- package/dist/library/rsengine.d.ts +6 -7
- package/dist/library/rsengine.js +23 -24
- package/dist/library/rsengine.js.map +1 -1
- package/dist/library/rsform-api/index.d.ts +1 -1
- package/dist/library/rsform-api/index.js +1 -2
- package/dist/library/rsform.d.ts +1 -1
- package/dist/library/rsmodel-api.d.ts +17 -18
- package/dist/library/rsmodel-api.js +6 -4
- package/dist/library/rsmodel-api.js.map +1 -1
- package/dist/library/rsmodel.d.ts +1 -1
- package/dist/library/structure-planner.d.ts +4 -5
- package/dist/library/structure-planner.js +1 -1
- package/dist/parsing/lezer-tree.js.map +1 -1
- package/dist/rslang/api.d.ts +2 -2
- package/dist/rslang/api.js +12 -7
- package/dist/rslang/api.js.map +1 -1
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/error.d.ts +1 -1
- package/dist/rslang/error.js +1 -0
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/calculator.js +1 -1
- package/dist/rslang/eval/evaluation-cache.d.ts +3 -4
- package/dist/rslang/eval/evaluation-cache.js +1 -3
- package/dist/rslang/eval/evaluation-cache.js.map +1 -1
- package/dist/rslang/eval/evaluator.d.ts +3 -4
- package/dist/rslang/eval/evaluator.js +5 -3
- package/dist/rslang/eval/evaluator.js.map +1 -1
- package/dist/rslang/eval/value-api.js +1 -2
- package/dist/rslang/eval/value.js +1 -2
- package/dist/rslang/index.d.ts +8 -7
- package/dist/rslang/index.js +3 -2
- package/dist/rslang/labels.d.ts +5 -6
- package/dist/rslang/parser/normalize.d.ts +1 -2
- package/dist/rslang/parser/normalize.js.map +1 -1
- package/dist/rslang/parser/parser.terms.d.ts +1 -2
- package/dist/rslang/parser/parser.terms.js.map +1 -1
- package/dist/rslang/parser/syntax-errors/index.d.ts +3 -4
- package/dist/rslang/parser/syntax-errors/index.js +1 -2
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/analyzer.js +1 -1
- package/dist/rslang/semantic/arguments-extractor.js +6 -4
- package/dist/rslang/semantic/arguments-extractor.js.map +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +2 -3
- package/dist/rslang/semantic/type-auditor.js +20 -16
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/typification-api.d.ts +10 -11
- package/dist/rslang/semantic/typification-api.js +10 -9
- package/dist/rslang/semantic/typification-api.js.map +1 -1
- package/dist/rslang/semantic/typification-parser.js +4 -1
- package/dist/rslang/semantic/typification-parser.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +2 -3
- package/dist/shared/index.js +1 -2
- package/dist/{syntax-errors-BN_bqTaX.js → syntax-errors-WGLQNaNe.js} +19 -4
- package/dist/{syntax-errors-BN_bqTaX.js.map → syntax-errors-WGLQNaNe.js.map} +1 -1
- package/dist/{value-COprb2Je.js → value-BDISzQqI.js} +3 -2
- package/dist/{value-COprb2Je.js.map → value-BDISzQqI.js.map} +1 -1
- package/package.json +24 -25
- package/src/index.ts +2 -1
- package/src/library/rsengine.test.ts +164 -0
- package/src/library/rsengine.ts +25 -24
- package/src/rslang/api.ts +3 -0
- package/src/rslang/error.ts +1 -0
- package/src/rslang/index.ts +2 -1
- package/src/rslang/parser/parser.test.ts +38 -0
- package/src/rslang/parser/syntax-errors/README.md +2 -2
- package/src/rslang/parser/syntax-errors/expression-errors.ts +18 -0
- package/src/rslang/parser/syntax-errors/index.ts +11 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsengine.js","names":[],"sources":["../../src/library/rsengine.ts"],"sourcesContent":["import { type AstNode } from '../parsing';\nimport { type CalculatorEvaluateOptions, type CalculatorResult, RSCalculator, TypeID, type Value } from '../rslang';\nimport { compare } from '../rslang/eval/value';\nimport { normalizeType } from '../rslang/labels';\n\nimport { CstType, type RSForm } from './rsform';\nimport { getAnalysisFor, isBaseSet, isBasicConcept, isFunctional } from './rsform-api';\nimport { type BasicBinding, type BasicsContext, type EvalStatus, type RSModel, TYPE_BASIC } from './rsmodel';\nimport { inferEvalStatus, isInferrable, tryFixValue } from './rsmodel-api';\n\nconst INVALID_TYPE_MARKER = 'INVALID';\n\n/** Services for {@link RSEngine}. */\nexport interface RSEngineServices {\n setCstValue: (args: {\n itemID: number;\n data: { target: number; type: string; data: Value | BasicBinding }[];\n }) => Promise<unknown>;\n clearValues: (args: { itemID: number; data: { items: number[] } }) => Promise<unknown>;\n}\n\n/** Notifications for {@link RSEngine}. */\nexport interface RSEngineNotifications {\n onInvalidSetValue: () => void;\n onCalculationSuccess: (timeSpent: string) => void;\n}\n\n/** Calculation engine for {@link RSModel}. */\nexport class RSEngine {\n public modelID: number;\n public schema: RSForm | null = null;\n public data: RSModel | null = null;\n public calculator = new RSCalculator();\n public basics: BasicsContext = new Map<number, BasicBinding>();\n\n private services: RSEngineServices;\n private notifications: RSEngineNotifications | null;\n private invalidData = new Set<number>();\n private calculatedSet = new Set<number>();\n private valueSubscribers = new Map<number, Set<() => void>>();\n private statusSubscribers = new Map<number, Set<() => void>>();\n private changeSubscribers = new Set<() => void>();\n private changeGeneration = 0;\n private pendingChange = false;\n private coalescedEmitTimeout: ReturnType<typeof setTimeout> | null = null;\n\n constructor(modelID: number, services: RSEngineServices, notifications: RSEngineNotifications | null = null) {\n this.services = services;\n this.notifications = notifications;\n this.modelID = modelID;\n }\n\n /** Updates data for {@link RSEngine}. */\n public loadData(schema: RSForm, model: RSModel): void {\n const oldSchema = this.schema;\n const newSchema = oldSchema !== schema;\n this.schema = schema;\n if (newSchema) {\n const changedCst = this.collectChanged(oldSchema, schema);\n this.prepareAst();\n this.setupEmptySets();\n this.onChangeDefinitions(changedCst);\n }\n if (this.data !== model) {\n this.data = model;\n this.prepareValues();\n }\n this.notifyAll();\n }\n\n /** Updates services for {@link RSEngine}. */\n public updateServices(services: RSEngineServices): void {\n this.services = services;\n }\n\n /** Updates notifications for {@link RSEngine}. */\n public updateNotifications(notifications: RSEngineNotifications | null): void {\n this.notifications = notifications;\n }\n\n /** Gets value of {@link Constituenta}. */\n public getCstValue(cstID: number): Value | null {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst) {\n return null;\n }\n return this.calculator.getValue(cst.alias);\n }\n\n /** Gets status of {@link Constituenta}. */\n public getCstStatus(cstID: number): EvalStatus {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst) {\n return inferEvalStatus(null, CstType.NOMINAL, false);\n }\n const value = this.calculator.getValue(cst.alias);\n return inferEvalStatus(value, cst.cst_type, this.calculatedSet.has(cstID), this.invalidData.has(cstID));\n }\n\n /** Subscribe to value change of {@link Constituenta}. */\n public subscribeValue(cstID: number, callbackFn: () => void): () => void {\n let subs = this.valueSubscribers.get(cstID);\n if (!subs) {\n subs = new Set();\n this.valueSubscribers.set(cstID, subs);\n }\n subs.add(callbackFn);\n return () => {\n const current = this.valueSubscribers.get(cstID);\n if (!current) {\n return;\n }\n current.delete(callbackFn);\n if (current.size === 0) {\n this.valueSubscribers.delete(cstID);\n }\n };\n }\n\n /** Subscribe to status change of {@link Constituenta}. */\n public subscribeStatus(cstID: number, callbackFn: () => void): () => void {\n let subs = this.statusSubscribers.get(cstID);\n if (!subs) {\n subs = new Set();\n this.statusSubscribers.set(cstID, subs);\n }\n subs.add(callbackFn);\n return () => {\n const current = this.statusSubscribers.get(cstID);\n if (!current) {\n return;\n }\n current.delete(callbackFn);\n if (current.size === 0) {\n this.statusSubscribers.delete(cstID);\n }\n };\n }\n\n /**\n * Subscribe to any engine change that can affect evaluation (values, status, or loaded data).\n */\n public subscribeChanges(callbackFn: () => void): () => void {\n this.changeSubscribers.add(callbackFn);\n return () => {\n this.changeSubscribers.delete(callbackFn);\n };\n }\n\n /** Monotonic counter bumped whenever the engine emits a change to {@link RSEngine.subscribeChanges} listeners. */\n public getChangeGeneration(): number {\n return this.changeGeneration;\n }\n\n /**\n * Runs pending {@link RSEngine.subscribeChanges} notifications immediately and clears the coalescing queue.\n * Use after a synchronous batch of engine updates when listeners must observe a bumped {@link getChangeGeneration}\n * in the same turn.\n */\n public flushPendingChanges(): void {\n if (this.coalescedEmitTimeout !== null) {\n clearTimeout(this.coalescedEmitTimeout);\n this.coalescedEmitTimeout = null;\n }\n if (!this.pendingChange) {\n return;\n }\n this.pendingChange = false;\n this.emitChange();\n }\n\n /** Sets value for {@link Constituenta} from {@link Value}. */\n public async setStructureValue(cstID: number, data: Value): Promise<void> {\n const cst = this.schema?.cstByID.get(cstID);\n if (!this.schema || !cst || isInferrable(cst.cst_type)) {\n this.notifications?.onInvalidSetValue();\n return;\n }\n\n const typeStr = cst.effectiveType ? normalizeType(cst.effectiveType) : INVALID_TYPE_MARKER;\n const payload = [{ target: cstID, type: typeStr, data }];\n await this.services.setCstValue({ itemID: this.modelID, data: payload });\n\n if (!cst.effectiveType || !this.calculator.validate(data, cst.effectiveType)) {\n this.invalidData.add(cstID);\n } else {\n this.invalidData.delete(cstID);\n }\n this.calculator.setValue(cst.alias, data);\n this.notifyCst(cstID);\n this.cascadeReset([cstID]);\n }\n\n /** Sets value for {@link Constituenta} from {@link BasicBinding}. */\n public async setBasicValue(cstID: number, data: BasicBinding): Promise<void> {\n const cst = this.schema?.cstByID.get(cstID);\n if (!this.schema || !cst || !isBaseSet(cst.cst_type)) {\n this.notifications?.onInvalidSetValue();\n return;\n }\n const oldValue = this.calculator.getValue(cst.alias);\n const newValue = Object.keys(data).map(Number);\n\n const updateList: Parameters<RSEngineServices['setCstValue']>[0]['data'] = [\n { target: cstID, type: TYPE_BASIC, data }\n ];\n const resetList: number[] = [];\n\n if (oldValue !== null && compare(newValue, oldValue) !== 0) {\n const dependencies = this.schema.graph.expandAllOutputs([cstID]);\n for (const childID of dependencies) {\n const child = this.schema.cstByID.get(childID)!;\n if (child.cst_type === CstType.STRUCTURED && !!child.effectiveType) {\n const value = this.calculator.getValue(child.alias);\n if (value !== null) {\n const fix = tryFixValue(value, child.effectiveType, cst.alias, newValue);\n if (fix === null) {\n resetList.push(childID);\n } else if (fix === true) {\n const typeStr = normalizeType(child.effectiveType);\n updateList.push({ target: childID, type: typeStr, data: [...(value as Value[])] });\n }\n }\n }\n }\n }\n\n if (resetList.length > 0) {\n await Promise.all([\n this.services.setCstValue({ itemID: this.modelID, data: updateList }),\n this.services.clearValues({ itemID: this.modelID, data: { items: resetList } })\n ]);\n } else {\n await this.services.setCstValue({ itemID: this.modelID, data: updateList });\n }\n const changed = [...resetList, ...updateList.map(item => item.target)];\n\n this.basics.set(cstID, data);\n this.calculator.setValue(cst.alias, Object.keys(data).map(Number));\n\n for (const item of resetList) {\n this.calculator.resetValue(this.schema.cstByID.get(item)!.alias);\n this.notifyCst(item);\n }\n for (const updateData of updateList) {\n if (updateData.target !== cstID) {\n this.calculator.setValue(\n this.schema.cstByID.get(updateData.target)!.alias,\n updateData.data as unknown as Value\n );\n this.notifyCst(updateData.target);\n }\n }\n for (const item of changed) {\n this.notifyCst(item);\n }\n this.cascadeReset(changed);\n }\n\n /** Resets value for {@link Constituenta}. */\n public async resetValue(cstID: number): Promise<void> {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst) {\n return;\n }\n await this.services.clearValues({ itemID: this.modelID, data: { items: [cstID] } });\n this.calculator.resetValue(cst.alias);\n this.basics.delete(cstID);\n this.calculatedSet.delete(cstID);\n this.invalidData.delete(cstID);\n this.notifyCst(cstID);\n }\n\n /** Evaluates expression for {@link RSEngine}. */\n public evaluateExpression(expression: string, cstType: CstType): CalculatorResult {\n return getEvaluationFor(expression, cstType, this.schema!, this.calculator);\n }\n\n /** Evaluates AST for {@link RSEngine}. */\n public evaluateAst(ast: AstNode, options?: CalculatorEvaluateOptions): CalculatorResult {\n return this.calculator.evaluateFull(ast, options);\n }\n\n /** Calculates value for {@link Constituenta}. */\n public calculateCst(cstID: number): CalculatorResult {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst || !this.schema) {\n return { value: null, iterations: 0, errors: [], cacheHits: 0 };\n }\n\n if (!this.calculatedSet.has(cstID)) {\n const predecessors = this.schema.graph.expandAllInputs([cstID]);\n this.prepareEvaluation(predecessors);\n }\n const result = getEvaluationFor(cst.definition_formal, cst.cst_type, this.schema, this.calculator);\n\n if (result.value === null) {\n this.calculator.resetValue(cst.alias);\n } else {\n this.calculator.setValue(cst.alias, result.value);\n }\n\n this.calculatedSet.add(cstID);\n this.notifyCst(cstID);\n\n return result;\n }\n\n /** Recalculate model for all inferrable expressions. */\n recalculateAll(): void {\n const start = performance.now();\n this.calculatedSet.clear();\n this.recalculateInternal();\n const end = performance.now();\n const timeSpent = ((end - start) / 1000).toFixed(2);\n this.notifications?.onCalculationSuccess(timeSpent);\n }\n\n /** Notify subscribers about value and status change of {@link Constituenta}. */\n private notifyCst(cstID: number) {\n this.notifyStatus(cstID);\n this.notifyValue(cstID);\n this.scheduleCoalescedEmitChange();\n }\n\n /** Notify all subscribers about value change. */\n private notifyValue(cstID: number) {\n const subs = this.valueSubscribers.get(cstID);\n if (subs) {\n for (const cb of subs) cb();\n }\n }\n\n /** Notify all subscribers about status change. */\n private notifyStatus(cstID: number) {\n const subs = this.statusSubscribers.get(cstID);\n if (subs) {\n for (const cb of subs) cb();\n }\n }\n\n /** Notify all subscribers about value and status change. */\n private notifyAll(): void {\n for (const subs of this.valueSubscribers.values()) {\n for (const cb of subs) cb();\n }\n for (const subs of this.statusSubscribers.values()) {\n for (const cb of subs) cb();\n }\n this.scheduleCoalescedEmitChange();\n }\n\n private scheduleCoalescedEmitChange(): void {\n this.pendingChange = true;\n if (this.coalescedEmitTimeout !== null) {\n return;\n }\n this.coalescedEmitTimeout = setTimeout(\n function runCoalescedEmitChange(this: RSEngine) {\n this.coalescedEmitTimeout = null;\n if (!this.pendingChange) {\n return;\n }\n this.pendingChange = false;\n this.emitChange();\n }.bind(this),\n 0\n );\n }\n\n private emitChange(): void {\n this.changeGeneration += 1;\n for (const cb of this.changeSubscribers) {\n cb();\n }\n }\n\n private prepareAst(): void {\n this.calculator.clearAllAst();\n const functions = this.schema!.items.filter(cst => isFunctional(cst.cst_type) && cst.analysis?.success);\n for (const cst of functions) {\n const fullAnalysis = getAnalysisFor(cst.definition_formal, cst.cst_type, this.schema!);\n if (fullAnalysis.ast) {\n this.calculator.setAST(cst.alias, fullAnalysis.ast);\n }\n }\n }\n\n private prepareValues(): void {\n this.basics.clear();\n this.invalidData.clear();\n this.calculatedSet.clear();\n\n for (const item of this.data!.items) {\n const cst = this.schema!.cstByID.get(item.id)!;\n if (item.type === TYPE_BASIC) {\n if (cst.cst_type !== CstType.BASE && cst.cst_type !== CstType.CONSTANT) {\n throw new Error(`Invalid data for ${cst.alias}`);\n }\n const data = item.value as BasicBinding;\n this.basics.set(cst.id, data);\n this.calculator.setValue(cst.alias, Object.keys(data).map(Number));\n }\n }\n for (const item of this.data!.items) {\n const cst = this.schema!.cstByID.get(item.id)!;\n if (item.type !== TYPE_BASIC) {\n this.calculator.setValue(cst.alias, item.value as Value);\n if (!cst.effectiveType || !this.calculator.validate(item.value as Value, cst.effectiveType)) {\n this.invalidData.add(item.id);\n }\n }\n }\n this.setupEmptySets();\n }\n\n private setupEmptySets(): void {\n for (const cst of this.schema!.items) {\n if (isBasicConcept(cst.cst_type) && this.schema!.analyzer.getType(cst.alias)?.typeID === TypeID.collection) {\n if (this.calculator.getValue(cst.alias) === null) {\n this.calculator.setValue(cst.alias, []);\n }\n }\n }\n }\n\n private collectChanged(previousSchema: RSForm | null, nextSchema: RSForm): number[] {\n if (!previousSchema) {\n return [];\n }\n const changedIDs: number[] = [];\n for (const cst of nextSchema.items) {\n const prev = previousSchema.cstByID.get(cst.id);\n if (prev && (prev.definition_formal !== cst.definition_formal || prev.alias !== cst.alias)) {\n changedIDs.push(cst.id);\n }\n }\n return changedIDs;\n }\n\n private onChangeDefinitions(cstIDs: number[]): void {\n if (!this.schema || cstIDs.length === 0) {\n return;\n }\n for (const cstID of cstIDs) {\n const cst = this.schema.cstByID.get(cstID);\n if (!cst || !isInferrable(cst.cst_type)) {\n continue;\n }\n this.calculatedSet.delete(cstID);\n this.calculator.resetValue(cst.alias);\n this.notifyCst(cstID);\n }\n this.cascadeReset(cstIDs);\n }\n\n private cascadeReset(cstIDs: number[]): void {\n if (!this.schema) {\n return;\n }\n const dependencies = this.schema.graph.expandAllOutputs(cstIDs);\n for (const cstID of dependencies) {\n const cst = this.schema.cstByID.get(cstID);\n if (!cst || !isInferrable(cst.cst_type)) {\n continue;\n }\n this.calculatedSet.delete(cstID);\n this.calculator.resetValue(this.schema.cstByID.get(cstID)!.alias);\n this.notifyCst(cstID);\n }\n }\n\n private prepareEvaluation(dependencies: number[]): void {\n for (const cstID of this.schema!.graph.topologicalOrder()) {\n if (dependencies.includes(cstID)) {\n const cst = this.schema!.cstByID.get(cstID)!;\n if (isInferrable(cst.cst_type)) {\n const value = fastEvaluation(cst.definition_formal, cst.cst_type, this.schema!, this.calculator);\n if (value !== null) {\n this.calculator.setValue(cst.alias, value);\n } else {\n this.calculator.resetValue(cst.alias);\n }\n this.notifyCst(cstID);\n }\n this.calculatedSet.add(cstID);\n }\n }\n }\n\n private recalculateInternal(): void {\n const processedIDs = [];\n for (const cst of this.schema!.cstByID.values()) {\n if (isInferrable(cst.cst_type)) {\n this.calculator.resetValue(cst.alias);\n }\n }\n\n for (const cstID of this.schema!.graph.topologicalOrder()) {\n processedIDs.push(cstID);\n const cst = this.schema!.cstByID.get(cstID)!;\n if (isInferrable(cst.cst_type)) {\n const value = fastEvaluation(cst.definition_formal, cst.cst_type, this.schema!, this.calculator);\n this.calculatedSet.add(cstID);\n if (value !== null) {\n this.calculator.setValue(cst.alias, value);\n }\n }\n }\n this.notifyAll();\n }\n}\n\n// ==== Internal functions ==== /\n\n/** Evaluates expression for {@link Constituenta}, including error handling. */\nfunction getEvaluationFor(\n expression: string,\n cstType: CstType,\n schema: RSForm,\n calculator: RSCalculator\n): CalculatorResult {\n const parse = getAnalysisFor(expression, cstType, schema);\n if (!parse.success || !parse.ast) {\n return {\n value: null,\n iterations: 0,\n cacheHits: 0,\n errors: parse.errors\n };\n }\n const result = calculator.evaluateFull(parse.ast);\n return {\n value: result.value,\n iterations: result.iterations,\n cacheHits: result.cacheHits,\n errors: [...parse.errors, ...result.errors]\n };\n}\n\n/** Evaluates expression for {@link RSModel}. */\nfunction fastEvaluation(expression: string, cstType: CstType, schema: RSForm, calculator: RSCalculator): Value | null {\n const parse = getAnalysisFor(expression, cstType, schema);\n if (!parse.success || !parse.ast) {\n return null;\n }\n return calculator.evaluateFast(parse.ast);\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,sBAAsB;;AAkB5B,IAAa,WAAb,MAAsB;CACpB;CACA,SAA+B;CAC/B,OAA8B;CAC9B,aAAoB,IAAI,aAAa;CACrC,yBAA+B,IAAI,IAA0B;CAE7D;CACA;CACA,8BAAsB,IAAI,IAAY;CACtC,gCAAwB,IAAI,IAAY;CACxC,mCAA2B,IAAI,IAA6B;CAC5D,oCAA4B,IAAI,IAA6B;CAC7D,oCAA4B,IAAI,IAAgB;CAChD,mBAA2B;CAC3B,gBAAwB;CACxB,uBAAqE;CAErE,YAAY,SAAiB,UAA4B,gBAA8C,MAAM;EAC3G,KAAK,WAAW;EAChB,KAAK,gBAAgB;EACrB,KAAK,UAAU;CACjB;;CAGA,SAAgB,QAAgB,OAAsB;EACpD,MAAM,YAAY,KAAK;EACvB,MAAM,YAAY,cAAc;EAChC,KAAK,SAAS;EACd,IAAI,WAAW;GACb,MAAM,aAAa,KAAK,eAAe,WAAW,MAAM;GACxD,KAAK,WAAW;GAChB,KAAK,eAAe;GACpB,KAAK,oBAAoB,UAAU;EACrC;EACA,IAAI,KAAK,SAAS,OAAO;GACvB,KAAK,OAAO;GACZ,KAAK,cAAc;EACrB;EACA,KAAK,UAAU;CACjB;;CAGA,eAAsB,UAAkC;EACtD,KAAK,WAAW;CAClB;;CAGA,oBAA2B,eAAmD;EAC5E,KAAK,gBAAgB;CACvB;;CAGA,YAAmB,OAA6B;EAC9C,MAAM,MAAM,KAAK,QAAQ,QAAQ,IAAI,KAAK;EAC1C,IAAI,CAAC,KACH,OAAO;EAET,OAAO,KAAK,WAAW,SAAS,IAAI,KAAK;CAC3C;;CAGA,aAAoB,OAA2B;EAC7C,MAAM,MAAM,KA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CAAC,MAAM,WAAW,CAAC,MAAM,KAC3B,OAAO;CAET,OAAO,WAAW,aAAa,MAAM,GAAG;AAC1C"}
|
|
1
|
+
{"version":3,"file":"rsengine.js","names":[],"sources":["../../src/library/rsengine.ts"],"sourcesContent":["import { type AstNode } from '../parsing';\nimport { type CalculatorEvaluateOptions, type CalculatorResult, RSCalculator, TypeID, type Value } from '../rslang';\nimport { compare } from '../rslang/eval/value';\nimport { normalizeType } from '../rslang/labels';\n\nimport { CstType, type RSForm } from './rsform';\nimport { getAnalysisFor, isBaseSet, isBasicConcept, isFunctional } from './rsform-api';\nimport { type BasicBinding, type BasicsContext, type EvalStatus, type RSModel, TYPE_BASIC } from './rsmodel';\nimport { inferEvalStatus, isInferrable, tryFixValue } from './rsmodel-api';\n\nconst INVALID_TYPE_MARKER = 'INVALID';\n\n/** Services for {@link RSEngine}. */\nexport interface RSEngineServices {\n setCstValue: (args: {\n itemID: number;\n data: { target: number; type: string; data: Value | BasicBinding }[];\n }) => Promise<unknown>;\n clearValues: (args: { itemID: number; data: { items: number[] } }) => Promise<unknown>;\n}\n\n/** Notifications for {@link RSEngine}. */\nexport interface RSEngineNotifications {\n onInvalidSetValue: () => void;\n onCalculationSuccess: (timeSpent: string) => void;\n}\n\n/** Calculation engine for {@link RSModel}. */\nexport class RSEngine {\n public modelID: number;\n public schema: RSForm | null = null;\n public data: RSModel | null = null;\n public calculator = new RSCalculator();\n public basics: BasicsContext = new Map<number, BasicBinding>();\n\n private services: RSEngineServices;\n private notifications: RSEngineNotifications | null;\n private invalidData = new Set<number>();\n private calculatedSet = new Set<number>();\n private valueSubscribers = new Map<number, Set<() => void>>();\n private statusSubscribers = new Map<number, Set<() => void>>();\n private changeSubscribers = new Set<() => void>();\n private changeGeneration = 0;\n private pendingChange = false;\n private coalescedEmitTimeout: ReturnType<typeof setTimeout> | null = null;\n\n constructor(modelID: number, services: RSEngineServices, notifications: RSEngineNotifications | null = null) {\n this.services = services;\n this.notifications = notifications;\n this.modelID = modelID;\n }\n\n /** Updates data for {@link RSEngine}. */\n public loadData(schema: RSForm, model: RSModel): void {\n const oldSchema = this.schema;\n const newSchema = oldSchema !== schema;\n this.schema = schema;\n if (newSchema) {\n const changedCst = this.collectChanged(oldSchema, schema);\n this.prepareAst();\n this.setupEmptySets();\n this.onChangeDefinitions(changedCst);\n }\n if (this.data !== model) {\n this.prepareValues(model);\n this.data = model;\n }\n this.notifyAll();\n }\n\n /** Updates services for {@link RSEngine}. */\n public updateServices(services: RSEngineServices): void {\n this.services = services;\n }\n\n /** Updates notifications for {@link RSEngine}. */\n public updateNotifications(notifications: RSEngineNotifications | null): void {\n this.notifications = notifications;\n }\n\n /** Gets value of {@link Constituenta}. */\n public getCstValue(cstID: number): Value | null {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst) {\n return null;\n }\n return this.calculator.getValue(cst.alias);\n }\n\n /** Gets status of {@link Constituenta}. */\n public getCstStatus(cstID: number): EvalStatus {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst) {\n return inferEvalStatus(null, CstType.NOMINAL, false);\n }\n const value = this.calculator.getValue(cst.alias);\n return inferEvalStatus(value, cst.cst_type, this.calculatedSet.has(cstID), this.invalidData.has(cstID));\n }\n\n /** Subscribe to value change of {@link Constituenta}. */\n public subscribeValue(cstID: number, callbackFn: () => void): () => void {\n let subs = this.valueSubscribers.get(cstID);\n if (!subs) {\n subs = new Set();\n this.valueSubscribers.set(cstID, subs);\n }\n subs.add(callbackFn);\n return () => {\n const current = this.valueSubscribers.get(cstID);\n if (!current) {\n return;\n }\n current.delete(callbackFn);\n if (current.size === 0) {\n this.valueSubscribers.delete(cstID);\n }\n };\n }\n\n /** Subscribe to status change of {@link Constituenta}. */\n public subscribeStatus(cstID: number, callbackFn: () => void): () => void {\n let subs = this.statusSubscribers.get(cstID);\n if (!subs) {\n subs = new Set();\n this.statusSubscribers.set(cstID, subs);\n }\n subs.add(callbackFn);\n return () => {\n const current = this.statusSubscribers.get(cstID);\n if (!current) {\n return;\n }\n current.delete(callbackFn);\n if (current.size === 0) {\n this.statusSubscribers.delete(cstID);\n }\n };\n }\n\n /**\n * Subscribe to any engine change that can affect evaluation (values, status, or loaded data).\n */\n public subscribeChanges(callbackFn: () => void): () => void {\n this.changeSubscribers.add(callbackFn);\n return () => {\n this.changeSubscribers.delete(callbackFn);\n };\n }\n\n /** Monotonic counter bumped whenever the engine emits a change to {@link RSEngine.subscribeChanges} listeners. */\n public getChangeGeneration(): number {\n return this.changeGeneration;\n }\n\n /**\n * Runs pending {@link RSEngine.subscribeChanges} notifications immediately and clears the coalescing queue.\n * Use after a synchronous batch of engine updates when listeners must observe a bumped {@link getChangeGeneration}\n * in the same turn.\n */\n public flushPendingChanges(): void {\n if (this.coalescedEmitTimeout !== null) {\n clearTimeout(this.coalescedEmitTimeout);\n this.coalescedEmitTimeout = null;\n }\n if (!this.pendingChange) {\n return;\n }\n this.pendingChange = false;\n this.emitChange();\n }\n\n /** Sets value for {@link Constituenta} from {@link Value}. */\n public async setStructureValue(cstID: number, data: Value): Promise<void> {\n const cst = this.schema?.cstByID.get(cstID);\n if (!this.schema || !cst || isInferrable(cst.cst_type)) {\n this.notifications?.onInvalidSetValue();\n return;\n }\n\n const typeStr = cst.effectiveType ? normalizeType(cst.effectiveType) : INVALID_TYPE_MARKER;\n const payload = [{ target: cstID, type: typeStr, data }];\n await this.services.setCstValue({ itemID: this.modelID, data: payload });\n\n if (!cst.effectiveType || !this.calculator.validate(data, cst.effectiveType)) {\n this.invalidData.add(cstID);\n } else {\n this.invalidData.delete(cstID);\n }\n this.calculator.setValue(cst.alias, data);\n this.notifyCst(cstID);\n this.cascadeReset([cstID]);\n }\n\n /** Sets value for {@link Constituenta} from {@link BasicBinding}. */\n public async setBasicValue(cstID: number, data: BasicBinding): Promise<void> {\n const cst = this.schema?.cstByID.get(cstID);\n if (!this.schema || !cst || !isBaseSet(cst.cst_type)) {\n this.notifications?.onInvalidSetValue();\n return;\n }\n const oldValue = this.calculator.getValue(cst.alias);\n const newValue = Object.keys(data).map(Number);\n\n const updateList: Parameters<RSEngineServices['setCstValue']>[0]['data'] = [\n { target: cstID, type: TYPE_BASIC, data }\n ];\n const resetList: number[] = [];\n\n if (oldValue !== null && compare(newValue, oldValue) !== 0) {\n const dependencies = this.schema.graph.expandAllOutputs([cstID]);\n for (const childID of dependencies) {\n const child = this.schema.cstByID.get(childID)!;\n if (child.cst_type === CstType.STRUCTURED && !!child.effectiveType) {\n const value = this.calculator.getValue(child.alias);\n if (value !== null) {\n const fix = tryFixValue(value, child.effectiveType, cst.alias, newValue);\n if (fix === null) {\n resetList.push(childID);\n } else if (fix === true) {\n const typeStr = normalizeType(child.effectiveType);\n updateList.push({ target: childID, type: typeStr, data: [...(value as Value[])] });\n }\n }\n }\n }\n }\n\n // Sequential writes: both endpoints share the model concurrency token.\n // A parallel pair would send the same expected time_update and the second would 409.\n await this.services.setCstValue({ itemID: this.modelID, data: updateList });\n if (resetList.length > 0) {\n await this.services.clearValues({ itemID: this.modelID, data: { items: resetList } });\n }\n const changed = [...resetList, ...updateList.map(item => item.target)];\n\n this.basics.set(cstID, data);\n this.calculator.setValue(cst.alias, Object.keys(data).map(Number));\n\n for (const item of resetList) {\n this.calculator.resetValue(this.schema.cstByID.get(item)!.alias);\n this.notifyCst(item);\n }\n for (const updateData of updateList) {\n if (updateData.target !== cstID) {\n this.calculator.setValue(\n this.schema.cstByID.get(updateData.target)!.alias,\n updateData.data as unknown as Value\n );\n this.notifyCst(updateData.target);\n }\n }\n for (const item of changed) {\n this.notifyCst(item);\n }\n this.cascadeReset(changed);\n }\n\n /** Resets value for {@link Constituenta}. */\n public async resetValue(cstID: number): Promise<void> {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst) {\n return;\n }\n await this.services.clearValues({ itemID: this.modelID, data: { items: [cstID] } });\n this.calculator.resetValue(cst.alias);\n this.basics.delete(cstID);\n this.calculatedSet.delete(cstID);\n this.invalidData.delete(cstID);\n this.notifyCst(cstID);\n }\n\n /** Evaluates expression for {@link RSEngine}. */\n public evaluateExpression(expression: string, cstType: CstType): CalculatorResult {\n return getEvaluationFor(expression, cstType, this.schema!, this.calculator);\n }\n\n /** Evaluates AST for {@link RSEngine}. */\n public evaluateAst(ast: AstNode, options?: CalculatorEvaluateOptions): CalculatorResult {\n return this.calculator.evaluateFull(ast, options);\n }\n\n /** Calculates value for {@link Constituenta}. */\n public calculateCst(cstID: number): CalculatorResult {\n const cst = this.schema?.cstByID.get(cstID);\n if (!cst || !this.schema) {\n return { value: null, iterations: 0, errors: [], cacheHits: 0 };\n }\n\n if (!this.calculatedSet.has(cstID)) {\n const predecessors = this.schema.graph.expandAllInputs([cstID]);\n this.prepareEvaluation(predecessors);\n }\n const result = getEvaluationFor(cst.definition_formal, cst.cst_type, this.schema, this.calculator);\n\n if (result.value === null) {\n this.calculator.resetValue(cst.alias);\n } else {\n this.calculator.setValue(cst.alias, result.value);\n }\n\n this.calculatedSet.add(cstID);\n this.notifyCst(cstID);\n\n return result;\n }\n\n /** Recalculate model for all inferrable expressions. */\n recalculateAll(): void {\n const start = performance.now();\n this.calculatedSet.clear();\n this.recalculateInternal();\n const end = performance.now();\n const timeSpent = ((end - start) / 1000).toFixed(2);\n this.notifications?.onCalculationSuccess(timeSpent);\n }\n\n /** Notify subscribers about value and status change of {@link Constituenta}. */\n private notifyCst(cstID: number) {\n this.notifyStatus(cstID);\n this.notifyValue(cstID);\n this.scheduleCoalescedEmitChange();\n }\n\n /** Notify all subscribers about value change. */\n private notifyValue(cstID: number) {\n const subs = this.valueSubscribers.get(cstID);\n if (subs) {\n for (const cb of subs) cb();\n }\n }\n\n /** Notify all subscribers about status change. */\n private notifyStatus(cstID: number) {\n const subs = this.statusSubscribers.get(cstID);\n if (subs) {\n for (const cb of subs) cb();\n }\n }\n\n /** Notify all subscribers about value and status change. */\n private notifyAll(): void {\n for (const subs of this.valueSubscribers.values()) {\n for (const cb of subs) cb();\n }\n for (const subs of this.statusSubscribers.values()) {\n for (const cb of subs) cb();\n }\n this.scheduleCoalescedEmitChange();\n }\n\n private scheduleCoalescedEmitChange(): void {\n this.pendingChange = true;\n if (this.coalescedEmitTimeout !== null) {\n return;\n }\n this.coalescedEmitTimeout = setTimeout(\n function runCoalescedEmitChange(this: RSEngine) {\n this.coalescedEmitTimeout = null;\n if (!this.pendingChange) {\n return;\n }\n this.pendingChange = false;\n this.emitChange();\n }.bind(this),\n 0\n );\n }\n\n private emitChange(): void {\n this.changeGeneration += 1;\n for (const cb of this.changeSubscribers) {\n cb();\n }\n }\n\n private prepareAst(): void {\n this.calculator.clearAllAst();\n const functions = this.schema!.items.filter(cst => isFunctional(cst.cst_type) && cst.analysis?.success);\n for (const cst of functions) {\n const fullAnalysis = getAnalysisFor(cst.definition_formal, cst.cst_type, this.schema!);\n if (fullAnalysis.ast) {\n this.calculator.setAST(cst.alias, fullAnalysis.ast);\n }\n }\n }\n\n private prepareValues(model: RSModel): void {\n this.basics.clear();\n this.invalidData.clear();\n this.calculatedSet.clear();\n\n for (const item of model.items) {\n const cst = this.schema?.cstByID.get(item.id);\n if (!cst || item.type !== TYPE_BASIC) {\n continue;\n }\n if (!isBaseSet(cst.cst_type)) {\n this.invalidData.add(item.id);\n continue;\n }\n const data = item.value as BasicBinding;\n this.basics.set(cst.id, data);\n this.calculator.setValue(cst.alias, Object.keys(data).map(Number));\n }\n for (const item of model.items) {\n const cst = this.schema?.cstByID.get(item.id);\n if (!cst || item.type === TYPE_BASIC) {\n continue;\n }\n this.calculator.setValue(cst.alias, item.value as Value);\n if (!cst.effectiveType || !this.calculator.validate(item.value as Value, cst.effectiveType)) {\n this.invalidData.add(item.id);\n }\n }\n this.setupEmptySets();\n }\n\n private setupEmptySets(): void {\n for (const cst of this.schema!.items) {\n if (isBasicConcept(cst.cst_type) && this.schema!.analyzer.getType(cst.alias)?.typeID === TypeID.collection) {\n if (this.calculator.getValue(cst.alias) === null) {\n this.calculator.setValue(cst.alias, []);\n }\n }\n }\n }\n\n private collectChanged(previousSchema: RSForm | null, nextSchema: RSForm): number[] {\n if (!previousSchema) {\n return [];\n }\n const changedIDs: number[] = [];\n for (const cst of nextSchema.items) {\n const prev = previousSchema.cstByID.get(cst.id);\n if (prev && (prev.definition_formal !== cst.definition_formal || prev.alias !== cst.alias)) {\n changedIDs.push(cst.id);\n }\n }\n return changedIDs;\n }\n\n private onChangeDefinitions(cstIDs: number[]): void {\n if (!this.schema || cstIDs.length === 0) {\n return;\n }\n for (const cstID of cstIDs) {\n const cst = this.schema.cstByID.get(cstID);\n if (!cst || !isInferrable(cst.cst_type)) {\n continue;\n }\n this.calculatedSet.delete(cstID);\n this.calculator.resetValue(cst.alias);\n this.notifyCst(cstID);\n }\n this.cascadeReset(cstIDs);\n }\n\n private cascadeReset(cstIDs: number[]): void {\n if (!this.schema) {\n return;\n }\n const dependencies = this.schema.graph.expandAllOutputs(cstIDs);\n for (const cstID of dependencies) {\n const cst = this.schema.cstByID.get(cstID);\n if (!cst || !isInferrable(cst.cst_type)) {\n continue;\n }\n this.calculatedSet.delete(cstID);\n this.calculator.resetValue(this.schema.cstByID.get(cstID)!.alias);\n this.notifyCst(cstID);\n }\n }\n\n private prepareEvaluation(dependencies: number[]): void {\n for (const cstID of this.schema!.graph.topologicalOrder()) {\n if (dependencies.includes(cstID)) {\n const cst = this.schema!.cstByID.get(cstID)!;\n if (isInferrable(cst.cst_type)) {\n const value = fastEvaluation(cst.definition_formal, cst.cst_type, this.schema!, this.calculator);\n if (value !== null) {\n this.calculator.setValue(cst.alias, value);\n } else {\n this.calculator.resetValue(cst.alias);\n }\n this.notifyCst(cstID);\n }\n this.calculatedSet.add(cstID);\n }\n }\n }\n\n private recalculateInternal(): void {\n const processedIDs = [];\n for (const cst of this.schema!.cstByID.values()) {\n if (isInferrable(cst.cst_type)) {\n this.calculator.resetValue(cst.alias);\n }\n }\n\n for (const cstID of this.schema!.graph.topologicalOrder()) {\n processedIDs.push(cstID);\n const cst = this.schema!.cstByID.get(cstID)!;\n if (isInferrable(cst.cst_type)) {\n const value = fastEvaluation(cst.definition_formal, cst.cst_type, this.schema!, this.calculator);\n this.calculatedSet.add(cstID);\n if (value !== null) {\n this.calculator.setValue(cst.alias, value);\n }\n }\n }\n this.notifyAll();\n }\n}\n\n// ==== Internal functions ==== /\n\n/** Evaluates expression for {@link Constituenta}, including error handling. */\nfunction getEvaluationFor(\n expression: string,\n cstType: CstType,\n schema: RSForm,\n calculator: RSCalculator\n): CalculatorResult {\n const parse = getAnalysisFor(expression, cstType, schema);\n if (!parse.success || !parse.ast) {\n return {\n value: null,\n iterations: 0,\n cacheHits: 0,\n errors: parse.errors\n };\n }\n const result = calculator.evaluateFull(parse.ast);\n return {\n value: result.value,\n iterations: result.iterations,\n cacheHits: result.cacheHits,\n errors: [...parse.errors, ...result.errors]\n };\n}\n\n/** Evaluates expression for {@link RSModel}. */\nfunction fastEvaluation(expression: string, cstType: CstType, schema: RSForm, calculator: RSCalculator): Value | null {\n const parse = getAnalysisFor(expression, cstType, schema);\n if (!parse.success || !parse.ast) {\n return null;\n }\n return calculator.evaluateFast(parse.ast);\n}\n"],"mappings":";;;;;;;;;;AAUA,MAAM,sBAAsB;;AAkB5B,IAAa,WAAb,MAAsB;CACpB;CACA,SAA+B;CAC/B,OAA8B;CAC9B,aAAoB,IAAI,aAAa;CACrC,yBAA+B,IAAI,IAA0B;CAE7D;CACA;CACA,8BAAsB,IAAI,IAAY;CACtC,gCAAwB,IAAI,IAAY;CACxC,mCAA2B,IAAI,IAA6B;CAC5D,oCAA4B,IAAI,IAA6B;CAC7D,oCAA4B,IAAI,IAAgB;CAChD,mBAA2B;CAC3B,gBAAwB;CACxB,uBAAqE;CAErE,YAAY,SAAiB,UAA4B,gBAA8C,MAAM;EAC3G,KAAK,WAAW;EAChB,KAAK,gBAAgB;EACrB,KAAK,UAAU;CACjB;;CAGA,SAAgB,QAAgB,OAAsB;EACpD,MAAM,YAAY,KAAK;EACvB,MAAM,YAAY,cAAc;EAChC,KAAK,SAAS;EACd,IA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,QAAQ,eAAe,YAAY,SAAS,MAAM;CACxD,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,KAC3B,OAAO;EACL,OAAO;EACP,YAAY;EACZ,WAAW;EACX,QAAQ,MAAM;CAChB;CAEF,MAAM,SAAS,WAAW,aAAa,MAAM,GAAG;CAChD,OAAO;EACL,OAAO,OAAO;EACd,YAAY,OAAO;EACnB,WAAW,OAAO;EAClB,QAAQ,CAAC,GAAG,MAAM,QAAQ,GAAG,OAAO,MAAM;CAC5C;AACF;;AAGA,SAAS,eAAe,YAAoB,SAAkB,QAAgB,YAAwC;CACpH,MAAM,QAAQ,eAAe,YAAY,SAAS,MAAM;CACxD,IAAI,CAAC,MAAM,WAAW,CAAC,MAAM,KAC3B,OAAO;CAET,OAAO,WAAW,aAAa,MAAM,GAAG;AAC1C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as removeAliasReference, A as canProduceStructure, B as filterAttributions, C as restoreConstituentOrder, D as inferTemplatedType, E as inferTemplate, F as isBasicConcept, G as MappableFields, H as remapAttributionsUnderSubstitution, I as isFunctional, J as applyMappingToConstituents, K as addAliasReference, L as isLogical, M as guessCstType, N as inferClass, O as normalizeExpression, P as isBaseSet, Q as maxAliasIndex, R as isTemplateCst, S as buildFormalDependencyGraph, T as inferStatus, U as getAnalysisFor, V as importAttributions, W as refineAnalysisForDependencyCycles, X as buildSequentialAliasMapping, Y as argumentValuesToMapping, Z as generateAlias, _ as findCstByStructure, a as buildDefinitionReferenceGraph, at as DiagnosticSourceFields, b as calculateSchemaStats, c as resolveConstituentTextChange, ct as SchemaIssueFields, d as SynthesizableFields, dt as SpawnPathFields, et as validateAliasFormat, f as inlineSynthesis, ft as StructureCapableFields, g as remapSubstitutionsAfterImport, h as applyConstituentSubstitutions, ht as TextResolvableFields, i as TextChangeOptions, it as DescribableFields, j as getCstTypePrefix, k as canHaveManualTypification, l as InlineSynthesisInput, lt as SearchableFields, m as SubstitutionResult, mt as TemplateSourceFields, n as moveIdsInOrder, nt as AliasTypedFields, o as buildTermReferenceGraph, ot as FormalOrderFields, p as sortItemsForInlineSynthesis, pt as TemplateParamSourceFields, q as allocateImportAliases, r as reorderItemsByIds, rt as BasicTextCheckFields, s as resolveAllConstituentTexts, st as ModelEvalFields, t as insertItemAfter, tt as validateNewAlias, u as InlineSynthesisResult, ut as SemanticRelations, v as getStructureName, w as applyFilterCategory, x as isSchemaIssue, y as inferNewSpawnPosition, z as typeClassForCstType } from "../../index-
|
|
1
|
+
import { $ as removeAliasReference, A as canProduceStructure, B as filterAttributions, C as restoreConstituentOrder, D as inferTemplatedType, E as inferTemplate, F as isBasicConcept, G as MappableFields, H as remapAttributionsUnderSubstitution, I as isFunctional, J as applyMappingToConstituents, K as addAliasReference, L as isLogical, M as guessCstType, N as inferClass, O as normalizeExpression, P as isBaseSet, Q as maxAliasIndex, R as isTemplateCst, S as buildFormalDependencyGraph, T as inferStatus, U as getAnalysisFor, V as importAttributions, W as refineAnalysisForDependencyCycles, X as buildSequentialAliasMapping, Y as argumentValuesToMapping, Z as generateAlias, _ as findCstByStructure, a as buildDefinitionReferenceGraph, at as DiagnosticSourceFields, b as calculateSchemaStats, c as resolveConstituentTextChange, ct as SchemaIssueFields, d as SynthesizableFields, dt as SpawnPathFields, et as validateAliasFormat, f as inlineSynthesis, ft as StructureCapableFields, g as remapSubstitutionsAfterImport, h as applyConstituentSubstitutions, ht as TextResolvableFields, i as TextChangeOptions, it as DescribableFields, j as getCstTypePrefix, k as canHaveManualTypification, l as InlineSynthesisInput, lt as SearchableFields, m as SubstitutionResult, mt as TemplateSourceFields, n as moveIdsInOrder, nt as AliasTypedFields, o as buildTermReferenceGraph, ot as FormalOrderFields, p as sortItemsForInlineSynthesis, pt as TemplateParamSourceFields, q as allocateImportAliases, r as reorderItemsByIds, rt as BasicTextCheckFields, s as resolveAllConstituentTexts, st as ModelEvalFields, t as insertItemAfter, tt as validateNewAlias, u as InlineSynthesisResult, ut as SemanticRelations, v as getStructureName, w as applyFilterCategory, x as isSchemaIssue, y as inferNewSpawnPosition, z as typeClassForCstType } from "../../index-CEOeehqz.js";
|
|
2
2
|
export { type AliasTypedFields, type BasicTextCheckFields, type DescribableFields, type DiagnosticSourceFields, type FormalOrderFields, type InlineSynthesisInput, type InlineSynthesisResult, type MappableFields, type ModelEvalFields, type SchemaIssueFields, type SearchableFields, type SemanticRelations, type SpawnPathFields, type StructureCapableFields, type SubstitutionResult, type SynthesizableFields, type TemplateParamSourceFields, type TemplateSourceFields, type TextChangeOptions, type TextResolvableFields, addAliasReference, allocateImportAliases, applyConstituentSubstitutions, applyFilterCategory, applyMappingToConstituents, argumentValuesToMapping, buildDefinitionReferenceGraph, buildFormalDependencyGraph, buildSequentialAliasMapping, buildTermReferenceGraph, calculateSchemaStats, canHaveManualTypification, canProduceStructure, filterAttributions, findCstByStructure, generateAlias, getAnalysisFor, getCstTypePrefix, getStructureName, guessCstType, importAttributions, inferClass, inferNewSpawnPosition, inferStatus, inferTemplate, inferTemplatedType, inlineSynthesis, insertItemAfter, isBaseSet, isBasicConcept, isFunctional, isLogical, isSchemaIssue, isTemplateCst, maxAliasIndex, moveIdsInOrder, normalizeExpression, refineAnalysisForDependencyCycles, remapAttributionsUnderSubstitution, remapSubstitutionsAfterImport, removeAliasReference, reorderItemsByIds, resolveAllConstituentTexts, resolveConstituentTextChange, restoreConstituentOrder, sortItemsForInlineSynthesis, typeClassForCstType, validateAliasFormat, validateNewAlias };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { addAliasReference, allocateImportAliases, applyConstituentSubstitutions, applyFilterCategory, applyMappingToConstituents, argumentValuesToMapping, buildDefinitionReferenceGraph, buildFormalDependencyGraph, buildSequentialAliasMapping, buildTermReferenceGraph, calculateSchemaStats, canHaveManualTypification, canProduceStructure, filterAttributions, findCstByStructure, generateAlias, getAnalysisFor, getCstTypePrefix, getStructureName, guessCstType, importAttributions, inferClass, inferNewSpawnPosition, inferStatus, inferTemplate, inferTemplatedType, inlineSynthesis, insertItemAfter, isBaseSet, isBasicConcept, isFunctional, isLogical, isSchemaIssue, isTemplateCst, maxAliasIndex, moveIdsInOrder, normalizeExpression, refineAnalysisForDependencyCycles, remapAttributionsUnderSubstitution, remapSubstitutionsAfterImport, removeAliasReference, reorderItemsByIds, resolveAllConstituentTexts, resolveConstituentTextChange, restoreConstituentOrder, sortItemsForInlineSynthesis, typeClassForCstType, validateAliasFormat, validateNewAlias };
|
|
1
|
+
export { I as addAliasReference, L as allocateImportAliases, _ as applyConstituentSubstitutions, E as applyFilterCategory, R as applyMappingToConstituents, z as argumentValuesToMapping, p as buildDefinitionReferenceGraph, w as buildFormalDependencyGraph, B as buildSequentialAliasMapping, m as buildTermReferenceGraph, S as calculateSchemaStats, K as canHaveManualTypification, q as canProduceStructure, j as filterAttributions, y as findCstByStructure, V as generateAlias, P as getAnalysisFor, J as getCstTypePrefix, b as getStructureName, Y as guessCstType, M as importAttributions, X as inferClass, x as inferNewSpawnPosition, D as inferStatus, O as inferTemplate, k as inferTemplatedType, d as inlineSynthesis, c as insertItemAfter, Z as isBaseSet, Q as isBasicConcept, $ as isFunctional, et as isLogical, C as isSchemaIssue, tt as isTemplateCst, H as maxAliasIndex, l as moveIdsInOrder, A as normalizeExpression, F as refineAnalysisForDependencyCycles, N as remapAttributionsUnderSubstitution, v as remapSubstitutionsAfterImport, U as removeAliasReference, u as reorderItemsByIds, h as resolveAllConstituentTexts, g as resolveConstituentTextChange, T as restoreConstituentOrder, f as sortItemsForInlineSynthesis, nt as typeClassForCstType, W as validateAliasFormat, G as validateNewAlias } from "../../diagnostics-D_4TpAH4.js";
|
package/dist/library/rsform.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-
|
|
1
|
+
import { C as RSFormStats, E as TypeInfo, S as RSForm, T as TermForm, _ as Attribution, b as CstStatus, g as ArgumentValue, v as Constituenta, w as Substitution, x as CstType, y as CstClass } from "../diagnostics-DC6QECex.js";
|
|
2
2
|
export { ArgumentValue, Attribution, Constituenta, CstClass, CstStatus, CstType, RSForm, RSFormStats, Substitution, TermForm, TypeInfo };
|
|
@@ -1,40 +1,39 @@
|
|
|
1
1
|
import { b as Typification, f as ExpressionType } from "../typification-hWUoWCba.js";
|
|
2
2
|
import { d as ValuePath, l as Value } from "../value-XpJOVzMP.js";
|
|
3
|
-
import "../index-
|
|
4
|
-
import { S as RSForm, f as EvalStatus, l as BasicBinding, m as RSModelStats, x as CstType } from "../diagnostics-
|
|
3
|
+
import "../index-CEUOBGLn.js";
|
|
4
|
+
import { S as RSForm, f as EvalStatus, l as BasicBinding, m as RSModelStats, x as CstType } from "../diagnostics-DC6QECex.js";
|
|
5
5
|
import { RSEngine } from "./rsengine.js";
|
|
6
|
-
import { st as ModelEvalFields } from "../index-
|
|
6
|
+
import { st as ModelEvalFields } from "../index-CEOeehqz.js";
|
|
7
7
|
//#region src/library/rsmodel-api.d.ts
|
|
8
8
|
/** Evaluate if parsed data is a basic binding data. */
|
|
9
|
-
declare function validateBasicBindingData(data: unknown): data is Record<string, string>;
|
|
9
|
+
export declare function validateBasicBindingData(data: unknown): data is Record<string, string>;
|
|
10
10
|
/** Convert parsed data to a basic binding. */
|
|
11
|
-
declare function toBasicBinding(data: Record<string | number, string>): BasicBinding;
|
|
11
|
+
export declare function toBasicBinding(data: Record<string | number, string>): BasicBinding;
|
|
12
12
|
/** Evaluate if parsed data is a {@link Value} data. */
|
|
13
|
-
declare function validateValueData(data: unknown): data is Value;
|
|
14
|
-
declare function generateRandomValue(type: Typification, basics: Map<number, BasicBinding>, cstByAlias: Map<string, {
|
|
13
|
+
export declare function validateValueData(data: unknown): data is Value;
|
|
14
|
+
export declare function generateRandomValue(type: Typification, basics: Map<number, BasicBinding>, cstByAlias: Map<string, {
|
|
15
15
|
id: number;
|
|
16
16
|
}>, setElementsCount?: number): Value | null;
|
|
17
17
|
/** Calculate statistics for {@link RSModel}. */
|
|
18
|
-
declare function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats;
|
|
18
|
+
export declare function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats;
|
|
19
19
|
/** Checks whether evaluation status contributes to model status issues. */
|
|
20
|
-
declare function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean;
|
|
20
|
+
export declare function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean;
|
|
21
21
|
/** Filters items whose evaluation status contributes to model issues. */
|
|
22
|
-
declare function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[];
|
|
22
|
+
export declare function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[];
|
|
23
23
|
/** Evaluate if {@link CstType} is interpretable. */
|
|
24
|
-
declare function isInterpretable(type: CstType): boolean;
|
|
24
|
+
export declare function isInterpretable(type: CstType): boolean;
|
|
25
25
|
/** Evaluate if {@link CstType} is inferrable. */
|
|
26
|
-
declare function isInferrable(type: CstType): boolean;
|
|
26
|
+
export declare function isInferrable(type: CstType): boolean;
|
|
27
27
|
/** Infers status of a given {@link Value} and {@link CstType}. */
|
|
28
|
-
declare function inferEvalStatus(value: Value | null, cstType: CstType, wasCalculated?: boolean, isInvalid?: boolean): EvalStatus;
|
|
28
|
+
export declare function inferEvalStatus(value: Value | null, cstType: CstType, wasCalculated?: boolean, isInvalid?: boolean): EvalStatus;
|
|
29
29
|
/** Tries to fix value removing invalid base elements not present in the target value.
|
|
30
30
|
* returns null if no fixing is possible.
|
|
31
31
|
* returns true if fixing was successful.
|
|
32
32
|
* returns false if fixing was not needed.
|
|
33
33
|
*/
|
|
34
|
-
declare function tryFixValue(value: Value, type: ExpressionType, targetAlias: string, targetValue: Value[]): boolean | null;
|
|
35
|
-
declare function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null;
|
|
36
|
-
declare function deleteValueElement(value: Value | null, path: ValuePath, type: Typification, target: number): Value | null;
|
|
37
|
-
declare function addValueElement(value: Value | null, path: ValuePath, type: Typification, currentType: Typification): Value | null;
|
|
34
|
+
export declare function tryFixValue(value: Value, type: ExpressionType, targetAlias: string, targetValue: Value[]): boolean | null;
|
|
35
|
+
export declare function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null;
|
|
36
|
+
export declare function deleteValueElement(value: Value | null, path: ValuePath, type: Typification, target: number): Value | null;
|
|
37
|
+
export declare function addValueElement(value: Value | null, path: ValuePath, type: Typification, currentType: Typification): Value | null;
|
|
38
38
|
//#endregion
|
|
39
|
-
export { addValueElement, calculateModelStats, deleteValueElement, generateRandomValue, getEvalIssueItems, inferEvalStatus, isInferrable, isInterpretable, isModelIssue, toBasicBinding, tryFixValue, updateValueElement, validateBasicBindingData, validateValueData };
|
|
40
39
|
//# sourceMappingURL=rsmodel-api.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TypeID } from "../rslang/semantic/typification.js";
|
|
2
2
|
import { CstType } from "./rsform.js";
|
|
3
|
-
import { O as setNestedValue, _ as extractValue, b as isTupleValue, d as set, f as tuple, l as compare, x as makeDefaultValue } from "../value-
|
|
3
|
+
import { O as setNestedValue, _ as extractValue, b as isTupleValue, d as set, f as tuple, l as compare, x as makeDefaultValue } from "../value-BDISzQqI.js";
|
|
4
4
|
import "../rslang/index.js";
|
|
5
|
-
import { Q as isBasicConcept, S as calculateSchemaStats, Z as isBaseSet, s as modelStatusCstDiagnostic } from "../diagnostics-
|
|
5
|
+
import { Q as isBasicConcept, S as calculateSchemaStats, Z as isBaseSet, s as modelStatusCstDiagnostic } from "../diagnostics-D_4TpAH4.js";
|
|
6
6
|
import { EvalStatus } from "./rsmodel.js";
|
|
7
7
|
//#region src/library/rsmodel-api.ts
|
|
8
8
|
const RANDOM_INTEGER_MIN = -100;
|
|
@@ -181,11 +181,13 @@ function deleteValueElement(value, path, type, target) {
|
|
|
181
181
|
if (path.length === 0 && type.typeID !== TypeID.collection) return null;
|
|
182
182
|
const arrayValue = extractValue(value, path);
|
|
183
183
|
if (!Array.isArray(arrayValue)) return null;
|
|
184
|
-
|
|
184
|
+
const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];
|
|
185
|
+
return setNestedValue(value, path, updatedArray);
|
|
185
186
|
}
|
|
186
187
|
function addValueElement(value, path, type, currentType) {
|
|
187
188
|
if (path.length === 0 && type.typeID !== TypeID.collection) return makeDefaultValue(type);
|
|
188
|
-
|
|
189
|
+
const updatedArray = [makeDefaultValue(currentType.base), ...extractValue(value, path) ?? []];
|
|
190
|
+
return setNestedValue(value, path, updatedArray);
|
|
189
191
|
}
|
|
190
192
|
function canGenerateRandomValue(type, basics, cstByAlias) {
|
|
191
193
|
switch (type.typeID) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsmodel-api.js","names":[],"sources":["../../src/library/rsmodel-api.ts"],"sourcesContent":["import { type ExpressionType, TypeID, type Typification, type Value } from '../rslang';\nimport { compare, set, tuple, TUPLE_ID, VALUE_TRUE, type ValuePath } from '../rslang/eval/value';\nimport { extractValue, isTupleValue, makeDefaultValue, setNestedValue } from '../rslang/eval/value-api';\nimport { type EchelonCollection } from '../rslang/semantic/typification';\n\nimport { modelStatusCstDiagnostic } from './diagnostics';\nimport { type RSEngine } from './rsengine';\nimport { CstType, type RSForm } from './rsform';\nimport { calculateSchemaStats, isBaseSet, isBasicConcept, type ModelEvalFields } from './rsform-api';\nimport { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';\n\nconst RANDOM_INTEGER_MIN = -100;\nconst RANDOM_INTEGER_MAX = 100;\nconst DEFAULT_RANDOM_SET_ELEMENTS_COUNT = 5;\n\n/** Evaluate if parsed data is a basic binding data. */\nexport function validateBasicBindingData(data: unknown): data is Record<string, string> {\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return false;\n }\n return Object.entries(data).every(([key, value]) => typeof value === 'string' && Number.isInteger(Number(key)));\n}\n\n/** Convert parsed data to a basic binding. */\nexport function toBasicBinding(data: Record<string | number, string>): BasicBinding {\n const result: BasicBinding = {};\n for (const [k, v] of Object.entries(data)) {\n result[Number(k)] = v;\n }\n return result;\n}\n\n/** Evaluate if parsed data is a {@link Value} data. */\nexport function validateValueData(data: unknown): data is Value {\n if (typeof data === 'number') {\n return Number.isFinite(data);\n }\n if (!Array.isArray(data)) {\n return false;\n }\n return data.every(item => validateValueData(item));\n}\n\nexport function generateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>,\n setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT\n): Value | null {\n switch (type.typeID) {\n case TypeID.integer:\n return Math.floor(Math.random() * (RANDOM_INTEGER_MAX - RANDOM_INTEGER_MIN + 1)) + RANDOM_INTEGER_MIN;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n const ids = Object.keys(binding ?? {}).map(Number);\n if (ids.length === 0) {\n return null;\n }\n return ids[Math.floor(Math.random() * ids.length)];\n }\n case TypeID.tuple: {\n const factors: Value[] = [];\n for (const factor of type.factors) {\n const sample = generateRandomValue(factor, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n factors.push(sample);\n }\n return tuple(factors);\n }\n case TypeID.collection: {\n // Empty set is a valid sample only when the element domain itself is generatable.\n // When the count happens to be 0 we would otherwise skip sampling and miss empty basics.\n if (!canGenerateRandomValue(type.base, basics, cstByAlias)) {\n return null;\n }\n const result: Value[] = [];\n const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));\n for (let i = 0; i < randomElementsCount; i++) {\n const sample = generateRandomValue(type.base, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n result.push(sample);\n }\n // Sets must be unique; sampling with replacement can produce duplicates.\n return set(result);\n }\n case TypeID.anyTypification:\n return null;\n }\n}\n\n/** Calculate statistics for {@link RSModel}. */\nexport function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats {\n const items = schema.items;\n const statusByID = new Map<number, EvalStatus>();\n for (const cst of items) {\n statusByID.set(cst.id, engine.getCstStatus(cst.id));\n }\n return {\n ...calculateSchemaStats(schema),\n base_elements: items.reduce((sum, cst) => sum + countBaseElements(cst, engine), 0),\n count_missing_base: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && isBasicConcept(cst.cst_type) ? 1 : 0),\n 0\n ),\n count_false_axioms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.AXIOM_FALSE ? 1 : 0),\n 0\n ),\n count_invalid_data: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.INVALID_DATA ? 1 : 0),\n 0\n ),\n count_invalid_calculations: items.reduce(\n (sum, cst) =>\n sum +\n (statusByID.get(cst.id) === EvalStatus.EVAL_FAIL || statusByID.get(cst.id) === EvalStatus.NOT_PROCESSED\n ? 1\n : 0),\n 0\n ),\n count_empty_terms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && cst.cst_type === CstType.TERM ? 1 : 0),\n 0\n )\n };\n}\n\n/** Checks whether evaluation status contributes to model status issues. */\nexport function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean {\n return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;\n}\n\n/** Filters items whose evaluation status contributes to model issues. */\nexport function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[] {\n return items.filter(cst => isModelIssue(engine, cst));\n}\n\n/** Evaluate if {@link CstType} is interpretable. */\nexport function isInterpretable(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is inferrable. */\nexport function isInferrable(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.TERM:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Infers status of a given {@link Value} and {@link CstType}. */\nexport function inferEvalStatus(\n value: Value | null,\n cstType: CstType,\n wasCalculated: boolean = true,\n isInvalid: boolean = false\n): EvalStatus {\n if (isBaseSet(cstType) || cstType === CstType.STRUCTURED) {\n if (isInvalid) {\n return EvalStatus.INVALID_DATA;\n }\n if (value === null || (Array.isArray(value) && value.length === 0)) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n }\n if (!isInferrable(cstType)) {\n return EvalStatus.NO_EVAL;\n }\n if (!wasCalculated) {\n return EvalStatus.NOT_PROCESSED;\n }\n if (value === null) {\n return EvalStatus.EVAL_FAIL;\n }\n if (cstType === CstType.AXIOM && value !== VALUE_TRUE) {\n return EvalStatus.AXIOM_FALSE;\n }\n if (Array.isArray(value) && value.length === 0) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n}\n\n/** Tries to fix value removing invalid base elements not present in the target value.\n * returns null if no fixing is possible.\n * returns true if fixing was successful.\n * returns false if fixing was not needed.\n */\nexport function tryFixValue(\n value: Value,\n type: ExpressionType,\n targetAlias: string,\n targetValue: Value[]\n): boolean | null {\n switch (type.typeID) {\n case TypeID.integer:\n return false;\n case TypeID.basic:\n if (type.baseID !== targetAlias) {\n return false;\n }\n if (typeof value !== 'number') {\n return null;\n }\n if (!targetValue.includes(value)) {\n return null;\n }\n return false;\n case TypeID.tuple: {\n if (!isTupleValue(value)) {\n return null;\n }\n let wasChanged = false;\n for (let i = 0; i < type.factors.length; i++) {\n const componentChanged = tryFixValue(value[i + 1], type.factors[i], targetAlias, targetValue);\n if (componentChanged === null) {\n return null;\n }\n if (componentChanged) {\n wasChanged = true;\n }\n }\n return wasChanged;\n }\n case TypeID.collection:\n if (!Array.isArray(value) || (value.length > 1 && value[0] === TUPLE_ID)) {\n return null;\n }\n let wasChanged = false;\n const removeElements: Value[] = [];\n for (const item of value) {\n const elementChanged = tryFixValue(item, type.base, targetAlias, targetValue);\n if (elementChanged === null || elementChanged === true) {\n wasChanged = true;\n if (elementChanged === null) {\n removeElements.push(item);\n }\n }\n }\n for (const item of removeElements) {\n const index = value.indexOf(item);\n if (index !== -1) {\n value.splice(index, 1);\n }\n }\n if (wasChanged) {\n value.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < value.length) {\n if (compare(value[i], value[i - 1]) === 0) {\n value.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n return wasChanged;\n\n case TypeID.logic:\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return null;\n }\n}\n\nexport function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null {\n return setNestedValue(value, path, newValue);\n}\n\nexport function deleteValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n target: number\n): Value | null {\n if (value === null) {\n return null;\n }\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value, path);\n if (!Array.isArray(arrayValue)) {\n return null;\n }\n const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];\n return setNestedValue(value, path, updatedArray);\n}\n\nexport function addValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n currentType: Typification\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return makeDefaultValue(type);\n }\n\n const newElem = makeDefaultValue((currentType as EchelonCollection).base);\n const arrayValue = (extractValue(value!, path) as Value[] | null) ?? [];\n const updatedArray = [newElem, ...arrayValue];\n return setNestedValue(value, path, updatedArray);\n}\n\n// ========= Internal functions ==========\n\nfunction canGenerateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>\n): boolean {\n switch (type.typeID) {\n case TypeID.integer:\n return true;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n return Object.keys(binding ?? {}).length > 0;\n }\n case TypeID.tuple:\n return type.factors.every(factor => canGenerateRandomValue(factor, basics, cstByAlias));\n case TypeID.collection:\n return canGenerateRandomValue(type.base, basics, cstByAlias);\n case TypeID.anyTypification:\n return false;\n }\n}\n\nfunction countBaseElements(cst: ModelEvalFields, engine: RSEngine): number {\n if (!isBasicConcept(cst.cst_type)) {\n return 0;\n }\n const value = engine.getCstValue(cst.id);\n if (value === null) {\n return 0;\n }\n if (!Array.isArray(value) || value[0] === TUPLE_ID) {\n return 1;\n }\n return value.length;\n}\n"],"mappings":";;;;;;;AAWA,MAAM,qBAAqB;AAE3B,MAAM,oCAAoC;;AAG1C,SAAgB,yBAAyB,MAA+C;CACtF,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GACzD,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,OAAO,GAAG,CAAC,CAAC;AAChH;;AAGA,SAAgB,eAAe,MAAqD;CAClF,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,IAAI,GACtC,OAAO,OAAO,CAAC,KAAK;CAEtB,OAAO;AACT;;AAGA,SAAgB,kBAAkB,MAA8B;CAC9D,IAAI,OAAO,SAAS,UAClB,OAAO,OAAO,SAAS,IAAI;CAE7B,IAAI,CAAC,MAAM,QAAQ,IAAI,GACrB,OAAO;CAET,OAAO,KAAK,OAAM,SAAQ,kBAAkB,IAAI,CAAC;AACnD;AAEA,SAAgB,oBACd,MACA,QAC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,CAAY;AACjD;AAEA,SAAgB,gBACd,OACA,MACA,MACA,aACc;CACd,IAAI,KAAK,WAAW,KAAK,KAAK,WAAW,OAAO,YAC9C,OAAO,iBAAiB,IAAI;CAM9B,OAAO,eAAe,OAAO,MAAM,CAHnB,iBAAkB,YAAkC,IAE9C,GAAS,GADX,aAAa,OAAQ,IAAI,KAAwB,CAAC,CAEnC,CAAY;AACjD;AAIA,SAAS,uBACP,MACA,QACA,YACS;CACT,QAAQ,KAAK,QAAb;EACE,KAAK,OAAO,SACV,OAAO;EACT,KAAK,OAAO,OAAO;GACjB,MAAM,MAAM,WAAW,IAAI,KAAK,MAAM;GACtC,MAAM,UAAU,MAAM,OAAO,IAAI,IAAI,EAAE,IAAI;GAC3C,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS;EAC7C;EACA,KAAK,OAAO,OACV,OAAO,KAAK,QAAQ,OAAM,WAAU,uBAAuB,QAAQ,QAAQ,UAAU,CAAC;EACxF,KAAK,OAAO,YACV,OAAO,uBAAuB,KAAK,MAAM,QAAQ,UAAU;EAC7D,KAAK,OAAO,iBACV,OAAO;CACX;AACF;AAEA,SAAS,kBAAkB,KAAsB,QAA0B;CACzE,IAAI,CAAC,eAAe,IAAI,QAAQ,GAC9B,OAAO;CAET,MAAM,QAAQ,OAAO,YAAY,IAAI,EAAE;CACvC,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAA,MACjC,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
1
|
+
{"version":3,"file":"rsmodel-api.js","names":[],"sources":["../../src/library/rsmodel-api.ts"],"sourcesContent":["import { type ExpressionType, TypeID, type Typification, type Value } from '../rslang';\nimport { compare, set, tuple, TUPLE_ID, VALUE_TRUE, type ValuePath } from '../rslang/eval/value';\nimport { extractValue, isTupleValue, makeDefaultValue, setNestedValue } from '../rslang/eval/value-api';\nimport { type EchelonCollection } from '../rslang/semantic/typification';\n\nimport { modelStatusCstDiagnostic } from './diagnostics';\nimport { type RSEngine } from './rsengine';\nimport { CstType, type RSForm } from './rsform';\nimport { calculateSchemaStats, isBaseSet, isBasicConcept, type ModelEvalFields } from './rsform-api';\nimport { type BasicBinding, EvalStatus, type RSModelStats } from './rsmodel';\n\nconst RANDOM_INTEGER_MIN = -100;\nconst RANDOM_INTEGER_MAX = 100;\nconst DEFAULT_RANDOM_SET_ELEMENTS_COUNT = 5;\n\n/** Evaluate if parsed data is a basic binding data. */\nexport function validateBasicBindingData(data: unknown): data is Record<string, string> {\n if (!data || typeof data !== 'object' || Array.isArray(data)) {\n return false;\n }\n return Object.entries(data).every(([key, value]) => typeof value === 'string' && Number.isInteger(Number(key)));\n}\n\n/** Convert parsed data to a basic binding. */\nexport function toBasicBinding(data: Record<string | number, string>): BasicBinding {\n const result: BasicBinding = {};\n for (const [k, v] of Object.entries(data)) {\n result[Number(k)] = v;\n }\n return result;\n}\n\n/** Evaluate if parsed data is a {@link Value} data. */\nexport function validateValueData(data: unknown): data is Value {\n if (typeof data === 'number') {\n return Number.isFinite(data);\n }\n if (!Array.isArray(data)) {\n return false;\n }\n return data.every(item => validateValueData(item));\n}\n\nexport function generateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>,\n setElementsCount: number = DEFAULT_RANDOM_SET_ELEMENTS_COUNT\n): Value | null {\n switch (type.typeID) {\n case TypeID.integer:\n return Math.floor(Math.random() * (RANDOM_INTEGER_MAX - RANDOM_INTEGER_MIN + 1)) + RANDOM_INTEGER_MIN;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n const ids = Object.keys(binding ?? {}).map(Number);\n if (ids.length === 0) {\n return null;\n }\n return ids[Math.floor(Math.random() * ids.length)];\n }\n case TypeID.tuple: {\n const factors: Value[] = [];\n for (const factor of type.factors) {\n const sample = generateRandomValue(factor, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n factors.push(sample);\n }\n return tuple(factors);\n }\n case TypeID.collection: {\n // Empty set is a valid sample only when the element domain itself is generatable.\n // When the count happens to be 0 we would otherwise skip sampling and miss empty basics.\n if (!canGenerateRandomValue(type.base, basics, cstByAlias)) {\n return null;\n }\n const result: Value[] = [];\n const randomElementsCount = Math.floor(Math.random() * (setElementsCount + 1));\n for (let i = 0; i < randomElementsCount; i++) {\n const sample = generateRandomValue(type.base, basics, cstByAlias, setElementsCount);\n if (sample === null) {\n return null;\n }\n result.push(sample);\n }\n // Sets must be unique; sampling with replacement can produce duplicates.\n return set(result);\n }\n case TypeID.anyTypification:\n return null;\n }\n}\n\n/** Calculate statistics for {@link RSModel}. */\nexport function calculateModelStats(schema: RSForm, engine: RSEngine, _engineGeneration?: number): RSModelStats {\n const items = schema.items;\n const statusByID = new Map<number, EvalStatus>();\n for (const cst of items) {\n statusByID.set(cst.id, engine.getCstStatus(cst.id));\n }\n return {\n ...calculateSchemaStats(schema),\n base_elements: items.reduce((sum, cst) => sum + countBaseElements(cst, engine), 0),\n count_missing_base: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && isBasicConcept(cst.cst_type) ? 1 : 0),\n 0\n ),\n count_false_axioms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.AXIOM_FALSE ? 1 : 0),\n 0\n ),\n count_invalid_data: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.INVALID_DATA ? 1 : 0),\n 0\n ),\n count_invalid_calculations: items.reduce(\n (sum, cst) =>\n sum +\n (statusByID.get(cst.id) === EvalStatus.EVAL_FAIL || statusByID.get(cst.id) === EvalStatus.NOT_PROCESSED\n ? 1\n : 0),\n 0\n ),\n count_empty_terms: items.reduce(\n (sum, cst) => sum + (statusByID.get(cst.id) === EvalStatus.EMPTY && cst.cst_type === CstType.TERM ? 1 : 0),\n 0\n )\n };\n}\n\n/** Checks whether evaluation status contributes to model status issues. */\nexport function isModelIssue(engine: RSEngine, cst: ModelEvalFields): boolean {\n return modelStatusCstDiagnostic(engine.getCstStatus(cst.id), cst.cst_type) !== null;\n}\n\n/** Filters items whose evaluation status contributes to model issues. */\nexport function getEvalIssueItems(items: readonly ModelEvalFields[], engine: RSEngine): ModelEvalFields[] {\n return items.filter(cst => isModelIssue(engine, cst));\n}\n\n/** Evaluate if {@link CstType} is interpretable. */\nexport function isInterpretable(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is inferrable. */\nexport function isInferrable(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.TERM:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Infers status of a given {@link Value} and {@link CstType}. */\nexport function inferEvalStatus(\n value: Value | null,\n cstType: CstType,\n wasCalculated: boolean = true,\n isInvalid: boolean = false\n): EvalStatus {\n if (isBaseSet(cstType) || cstType === CstType.STRUCTURED) {\n if (isInvalid) {\n return EvalStatus.INVALID_DATA;\n }\n if (value === null || (Array.isArray(value) && value.length === 0)) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n }\n if (!isInferrable(cstType)) {\n return EvalStatus.NO_EVAL;\n }\n if (!wasCalculated) {\n return EvalStatus.NOT_PROCESSED;\n }\n if (value === null) {\n return EvalStatus.EVAL_FAIL;\n }\n if (cstType === CstType.AXIOM && value !== VALUE_TRUE) {\n return EvalStatus.AXIOM_FALSE;\n }\n if (Array.isArray(value) && value.length === 0) {\n return EvalStatus.EMPTY;\n }\n return EvalStatus.HAS_DATA;\n}\n\n/** Tries to fix value removing invalid base elements not present in the target value.\n * returns null if no fixing is possible.\n * returns true if fixing was successful.\n * returns false if fixing was not needed.\n */\nexport function tryFixValue(\n value: Value,\n type: ExpressionType,\n targetAlias: string,\n targetValue: Value[]\n): boolean | null {\n switch (type.typeID) {\n case TypeID.integer:\n return false;\n case TypeID.basic:\n if (type.baseID !== targetAlias) {\n return false;\n }\n if (typeof value !== 'number') {\n return null;\n }\n if (!targetValue.includes(value)) {\n return null;\n }\n return false;\n case TypeID.tuple: {\n if (!isTupleValue(value)) {\n return null;\n }\n let wasChanged = false;\n for (let i = 0; i < type.factors.length; i++) {\n const componentChanged = tryFixValue(value[i + 1], type.factors[i], targetAlias, targetValue);\n if (componentChanged === null) {\n return null;\n }\n if (componentChanged) {\n wasChanged = true;\n }\n }\n return wasChanged;\n }\n case TypeID.collection:\n if (!Array.isArray(value) || (value.length > 1 && value[0] === TUPLE_ID)) {\n return null;\n }\n let wasChanged = false;\n const removeElements: Value[] = [];\n for (const item of value) {\n const elementChanged = tryFixValue(item, type.base, targetAlias, targetValue);\n if (elementChanged === null || elementChanged === true) {\n wasChanged = true;\n if (elementChanged === null) {\n removeElements.push(item);\n }\n }\n }\n for (const item of removeElements) {\n const index = value.indexOf(item);\n if (index !== -1) {\n value.splice(index, 1);\n }\n }\n if (wasChanged) {\n value.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < value.length) {\n if (compare(value[i], value[i - 1]) === 0) {\n value.splice(i, 1);\n } else {\n i++;\n }\n }\n }\n return wasChanged;\n\n case TypeID.logic:\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return null;\n }\n}\n\nexport function updateValueElement(value: Value | null, path: ValuePath, newValue: number): Value | null {\n return setNestedValue(value, path, newValue);\n}\n\nexport function deleteValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n target: number\n): Value | null {\n if (value === null) {\n return null;\n }\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return null;\n }\n\n const arrayValue = extractValue(value, path);\n if (!Array.isArray(arrayValue)) {\n return null;\n }\n const updatedArray = [...arrayValue.slice(0, target), ...arrayValue.slice(target + 1)];\n return setNestedValue(value, path, updatedArray);\n}\n\nexport function addValueElement(\n value: Value | null,\n path: ValuePath,\n type: Typification,\n currentType: Typification\n): Value | null {\n if (path.length === 0 && type.typeID !== TypeID.collection) {\n return makeDefaultValue(type);\n }\n\n const newElem = makeDefaultValue((currentType as EchelonCollection).base);\n const arrayValue = (extractValue(value!, path) as Value[] | null) ?? [];\n const updatedArray = [newElem, ...arrayValue];\n return setNestedValue(value, path, updatedArray);\n}\n\n// ========= Internal functions ==========\n\nfunction canGenerateRandomValue(\n type: Typification,\n basics: Map<number, BasicBinding>,\n cstByAlias: Map<string, { id: number }>\n): boolean {\n switch (type.typeID) {\n case TypeID.integer:\n return true;\n case TypeID.basic: {\n const cst = cstByAlias.get(type.baseID);\n const binding = cst ? basics.get(cst.id) : undefined;\n return Object.keys(binding ?? {}).length > 0;\n }\n case TypeID.tuple:\n return type.factors.every(factor => canGenerateRandomValue(factor, basics, cstByAlias));\n case TypeID.collection:\n return canGenerateRandomValue(type.base, basics, cstByAlias);\n case TypeID.anyTypification:\n return false;\n }\n}\n\nfunction countBaseElements(cst: ModelEvalFields, engine: RSEngine): number {\n if (!isBasicConcept(cst.cst_type)) {\n return 0;\n }\n const value = engine.getCstValue(cst.id);\n if (value === null) {\n return 0;\n }\n if (!Array.isArray(value) || value[0] === TUPLE_ID) {\n return 1;\n }\n return value.length;\n}\n"],"mappings":";;;;;;;AAWA,MAAM,qBAAqB;AAE3B,MAAM,oCAAoC;;AAG1C,SAAgB,yBAAyB,MAA+C;CACtF,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,MAAM,QAAQ,IAAI,GACzD,OAAO;CAET,OAAO,OAAO,QAAQ,IAAI,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,OAAO,UAAU,YAAY,OAAO,UAAU,OAAO,GAAG,CAA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AAM,QAAQ,OAAO,YAAY,IAAI,EAAE;CACvC,IAAI,UAAU,MACZ,OAAO;CAET,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAA,MACjC,OAAO;CAET,OAAO,MAAM;AACf"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { d as DEFAULT_VALUE_TEXT, f as EvalStatus, h as TYPE_BASIC, l as BasicBinding, m as RSModelStats, p as RSModel, u as BasicsContext } from "../diagnostics-
|
|
1
|
+
import { d as DEFAULT_VALUE_TEXT, f as EvalStatus, h as TYPE_BASIC, l as BasicBinding, m as RSModelStats, p as RSModel, u as BasicsContext } from "../diagnostics-DC6QECex.js";
|
|
2
2
|
export { BasicBinding, BasicsContext, DEFAULT_VALUE_TEXT, EvalStatus, RSModel, RSModelStats, TYPE_BASIC };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { b as Typification, y as TypePath } from "../typification-hWUoWCba.js";
|
|
2
|
-
import "../index-
|
|
3
|
-
import { S as RSForm, v as Constituenta } from "../diagnostics-
|
|
2
|
+
import "../index-CEUOBGLn.js";
|
|
3
|
+
import { S as RSForm, v as Constituenta } from "../diagnostics-DC6QECex.js";
|
|
4
4
|
//#region src/library/structure-planner.d.ts
|
|
5
5
|
/** Represents a node in the structure planner. */
|
|
6
|
-
interface SPNode {
|
|
6
|
+
export interface SPNode {
|
|
7
7
|
key: string;
|
|
8
8
|
path: TypePath;
|
|
9
9
|
type: Typification;
|
|
@@ -12,7 +12,7 @@ interface SPNode {
|
|
|
12
12
|
existing: Constituenta | null;
|
|
13
13
|
}
|
|
14
14
|
/** Structure planner for {@link Constituenta}. */
|
|
15
|
-
declare class StructurePlanner {
|
|
15
|
+
export declare class StructurePlanner {
|
|
16
16
|
private items;
|
|
17
17
|
private schema;
|
|
18
18
|
private target;
|
|
@@ -23,5 +23,4 @@ declare class StructurePlanner {
|
|
|
23
23
|
private pushNode;
|
|
24
24
|
}
|
|
25
25
|
//#endregion
|
|
26
|
-
export { SPNode, StructurePlanner };
|
|
27
26
|
//# sourceMappingURL=structure-planner.d.ts.map
|
|
@@ -3,7 +3,7 @@ import { labelType } from "../rslang/labels.js";
|
|
|
3
3
|
import { splitTemplateDefinition } from "../rslang/api.js";
|
|
4
4
|
import { CstType } from "./rsform.js";
|
|
5
5
|
import "../rslang/index.js";
|
|
6
|
-
import { y as findCstByStructure } from "../diagnostics-
|
|
6
|
+
import { y as findCstByStructure } from "../diagnostics-D_4TpAH4.js";
|
|
7
7
|
//#region src/library/structure-planner.ts
|
|
8
8
|
/** Structure planner for {@link Constituenta}. */
|
|
9
9
|
var StructurePlanner = class {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lezer-tree.js","names":[],"sources":["../../src/parsing/lezer-tree.ts"],"sourcesContent":["import { type NodeType, type Tree, type TreeCursor } from '@lezer/common';\nexport { type TreeCursor } from '@lezer/common';\n\n/** Represents syntax tree node data. */\nexport interface CMSyntaxNode {\n type: NodeType;\n from: number;\n to: number;\n}\n\n/** Prints tree to compact string. */\nexport function printTree(tree: Tree): string {\n const state = {\n output: '',\n prefixes: [] as string[]\n };\n traverseTree(tree, {\n onEnter: node => {\n state.output += '[';\n state.output += node.type.name;\n },\n onLeave: () => {\n state.output += ']';\n }\n });\n return state.output;\n}\n\n// ======== Internals ========\n\ninterface CursorNode extends CMSyntaxNode {\n isLeaf: boolean;\n}\n\nfunction cursorNode({ type, from, to }: TreeCursor, isLeaf = false): CursorNode {\n return { type, from, to, isLeaf };\n}\n\ninterface TreeTraversalOptions {\n beforeEnter?: (cursor: TreeCursor) => void;\n onEnter: (node: CursorNode) => false | void;\n onLeave?: (node: CursorNode) => false | void;\n}\n\n/** Implements depth-first traversal. */\nfunction traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: TreeTraversalOptions) {\n const cursor = tree.cursor();\n for (;;) {\n let node = cursorNode(cursor);\n let leave = false;\n const enter = !node.type.isAnonymous;\n if (enter && beforeEnter) beforeEnter(cursor);\n node.isLeaf = !cursor.firstChild();\n if (enter) {\n leave = true;\n if (onEnter(node) === false) return;\n }\n if (!node.isLeaf) continue;\n for (;;) {\n node = cursorNode(cursor, node.isLeaf);\n if (leave && onLeave) if (onLeave(node) === false) return;\n leave = cursor.type.isAnonymous;\n node.isLeaf = false;\n if (cursor.nextSibling()) break;\n if (!cursor.parent()) return;\n leave = true;\n }\n }\n}\n"],"mappings":";;AAWA,SAAgB,UAAU,MAAoB;CAC5C,MAAM,QAAQ;EACZ,QAAQ;EACR,UAAU,CAAC;CACb;CACA,aAAa,MAAM;EACjB,UAAS,SAAQ;GACf,MAAM,UAAU;GAChB,MAAM,UAAU,KAAK,KAAK;EAC5B;EACA,eAAe;GACb,MAAM,UAAU;EAClB;CACF,CAAC;CACD,OAAO,MAAM;AACf;AAQA,SAAS,WAAW,EAAE,MAAM,MAAM,MAAkB,SAAS,OAAmB;CAC9E,OAAO;EAAE;EAAM;EAAM;EAAI;CAAO;AAClC;;AASA,SAAS,aAAa,MAAY,EAAE,aAAa,SAAS,WAAiC;CACzF,MAAM,SAAS,KAAK,OAAO;CAC3B,SAAS;EACP,IAAI,OAAO,WAAW,MAAM;EAC5B,IAAI,QAAQ;EACZ,MAAM,QAAQ,CAAC,KAAK,KAAK;EACzB,IAAI,SAAS,aAAa,YAAY,MAAM;EAC5C,KAAK,SAAS,CAAC,OAAO,WAAW;EACjC,IAAI,OAAO;GACT,QAAQ;GACR,IAAI,QAAQ,IAAI,MAAM,OAAO;EAC/B;EACA,IAAI,CAAC,KAAK,QAAQ;EAClB,SAAS;GACP,OAAO,WAAW,QAAQ,KAAK,MAAM;GACrC,IAAI,SAAS;
|
|
1
|
+
{"version":3,"file":"lezer-tree.js","names":[],"sources":["../../src/parsing/lezer-tree.ts"],"sourcesContent":["import { type NodeType, type Tree, type TreeCursor } from '@lezer/common';\nexport { type TreeCursor } from '@lezer/common';\n\n/** Represents syntax tree node data. */\nexport interface CMSyntaxNode {\n type: NodeType;\n from: number;\n to: number;\n}\n\n/** Prints tree to compact string. */\nexport function printTree(tree: Tree): string {\n const state = {\n output: '',\n prefixes: [] as string[]\n };\n traverseTree(tree, {\n onEnter: node => {\n state.output += '[';\n state.output += node.type.name;\n },\n onLeave: () => {\n state.output += ']';\n }\n });\n return state.output;\n}\n\n// ======== Internals ========\n\ninterface CursorNode extends CMSyntaxNode {\n isLeaf: boolean;\n}\n\nfunction cursorNode({ type, from, to }: TreeCursor, isLeaf = false): CursorNode {\n return { type, from, to, isLeaf };\n}\n\ninterface TreeTraversalOptions {\n beforeEnter?: (cursor: TreeCursor) => void;\n onEnter: (node: CursorNode) => false | void;\n onLeave?: (node: CursorNode) => false | void;\n}\n\n/** Implements depth-first traversal. */\nfunction traverseTree(tree: Tree, { beforeEnter, onEnter, onLeave }: TreeTraversalOptions) {\n const cursor = tree.cursor();\n for (;;) {\n let node = cursorNode(cursor);\n let leave = false;\n const enter = !node.type.isAnonymous;\n if (enter && beforeEnter) beforeEnter(cursor);\n node.isLeaf = !cursor.firstChild();\n if (enter) {\n leave = true;\n if (onEnter(node) === false) return;\n }\n if (!node.isLeaf) continue;\n for (;;) {\n node = cursorNode(cursor, node.isLeaf);\n if (leave && onLeave) if (onLeave(node) === false) return;\n leave = cursor.type.isAnonymous;\n node.isLeaf = false;\n if (cursor.nextSibling()) break;\n if (!cursor.parent()) return;\n leave = true;\n }\n }\n}\n"],"mappings":";;AAWA,SAAgB,UAAU,MAAoB;CAC5C,MAAM,QAAQ;EACZ,QAAQ;EACR,UAAU,CAAC;CACb;CACA,aAAa,MAAM;EACjB,UAAS,SAAQ;GACf,MAAM,UAAU;GAChB,MAAM,UAAU,KAAK,KAAK;EAC5B;EACA,eAAe;GACb,MAAM,UAAU;EAClB;CACF,CAAC;CACD,OAAO,MAAM;AACf;AAQA,SAAS,WAAW,EAAE,MAAM,MAAM,MAAkB,SAAS,OAAmB;CAC9E,OAAO;EAAE;EAAM;EAAM;EAAI;CAAO;AAClC;;AASA,SAAS,aAAa,MAAY,EAAE,aAAa,SAAS,WAAiC;CACzF,MAAM,SAAS,KAAK,OAAO;CAC3B,SAAS;EACP,IAAI,OAAO,WAAW,MAAM;EAC5B,IAAI,QAAQ;EACZ,MAAM,QAAQ,CAAC,KAAK,KAAK;EACzB,IAAI,SAAS,aAAa,YAAY,MAAM;EAC5C,KAAK,SAAS,CAAC,OAAO,WAAW;EACjC,IAAI,OAAO;GACT,QAAQ;GACR,IAAI,QAAQ,IAAI,MAAM,OAAO;EAC/B;EACA,IAAI,CAAC,KAAK,QAAQ;EAClB,SAAS;GACP,OAAO,WAAW,QAAQ,KAAK,MAAM;GACrC,IAAI,SAAS,SAAa;QAAA,QAAQ,IAAI,MAAM,OAAO;GAAA;GACnD,QAAQ,OAAO,KAAK;GACpB,KAAK,SAAS;GACd,IAAI,OAAO,YAAY,GAAG;GAC1B,IAAI,CAAC,OAAO,OAAO,GAAG;GACtB,QAAQ;EACV;CACF;AACF"}
|
package/dist/rslang/api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as generateExpressionFromAst } from "../expression-generator-CADzBw-C.js";
|
|
2
|
-
import { a as
|
|
3
|
-
export { AliasMapping, applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isGlobalAlias, isSetTypification, isSimpleExpression, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs };
|
|
2
|
+
import { a as extractArguments, c as isSetTypification, d as splitTemplateDefinition, f as substituteLocalAliases, i as applyTypificationMapping, l as isSimpleExpression, n as DELETED_ALIAS, o as extractGlobals, p as substituteTemplateArgs, r as applyAliasMapping, s as isGlobalAlias, t as AliasMapping, u as parseRSLangExpression } from "../api-BRrnB6yd.js";
|
|
3
|
+
export { AliasMapping, DELETED_ALIAS, applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isGlobalAlias, isSetTypification, isSimpleExpression, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs };
|
package/dist/rslang/api.js
CHANGED
|
@@ -8,6 +8,8 @@ import { generateExpressionFromAst } from "./parser/expression-generator.js";
|
|
|
8
8
|
/**
|
|
9
9
|
* Module: API for RSLanguage.
|
|
10
10
|
*/
|
|
11
|
+
/** Placeholder alias written into expressions in place of references to deleted constituents. */
|
|
12
|
+
const DELETED_ALIAS = "DEL";
|
|
11
13
|
const LOCALS_REGEXP = /[_a-zα-ω][a-zα-ω]*\d*/g;
|
|
12
14
|
const GLOBAL_ALIAS_SOURCE = "[XCSADFPTN]\\d+";
|
|
13
15
|
const GLOBALS_REGEXP = new RegExp(GLOBAL_ALIAS_SOURCE, "g");
|
|
@@ -26,7 +28,8 @@ function isGlobalAlias(value) {
|
|
|
26
28
|
*/
|
|
27
29
|
function parseRSLangExpression(expression) {
|
|
28
30
|
if (!expression.trim()) return null;
|
|
29
|
-
const
|
|
31
|
+
const tree = parser.parse(expression);
|
|
32
|
+
const ast = buildTree(tree.cursor());
|
|
30
33
|
normalizeAST(ast, expression);
|
|
31
34
|
return ast;
|
|
32
35
|
}
|
|
@@ -65,11 +68,13 @@ function splitTemplateDefinition(target) {
|
|
|
65
68
|
for (; start < target.length && target[start] !== "["; ++start);
|
|
66
69
|
if (start < target.length) {
|
|
67
70
|
for (let counter = 0, end = start + 1; end < target.length; ++end) if (target[end] === "[") ++counter;
|
|
68
|
-
else if (target[end] === "]")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
else if (target[end] === "]") {
|
|
72
|
+
if (counter !== 0) --counter;
|
|
73
|
+
else return {
|
|
74
|
+
head: target.substring(start + 1, end).trim(),
|
|
75
|
+
body: target.substring(end + 1).trim()
|
|
76
|
+
};
|
|
77
|
+
}
|
|
73
78
|
}
|
|
74
79
|
return {
|
|
75
80
|
head: "",
|
|
@@ -157,6 +162,6 @@ function applyPattern(text, mapping, pattern) {
|
|
|
157
162
|
return output;
|
|
158
163
|
}
|
|
159
164
|
//#endregion
|
|
160
|
-
export { applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isGlobalAlias, isSetTypification, isSimpleExpression, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs };
|
|
165
|
+
export { DELETED_ALIAS, applyAliasMapping, applyTypificationMapping, extractArguments, extractGlobals, generateExpressionFromAst, isGlobalAlias, isSetTypification, isSimpleExpression, parseRSLangExpression, splitTemplateDefinition, substituteLocalAliases, substituteTemplateArgs };
|
|
161
166
|
|
|
162
167
|
//# sourceMappingURL=api.js.map
|
package/dist/rslang/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":["rslangParser"],"sources":["../../src/rslang/api.ts"],"sourcesContent":["/**\n * Module: API for RSLanguage.\n */\nimport { type AstNode, buildTree } from '../parsing';\n\nimport { normalizeAST } from './parser/normalize';\nimport { parser as rslangParser } from './parser/parser';\nimport { ArgumentsExtractor, type ArgumentsType } from './semantic/arguments-extractor';\nexport { generateExpressionFromAst } from './parser/expression-generator';\n\n/** Represents alias mapping. */\nexport type AliasMapping = Record<string, string>;\n\n// cspell:disable\nconst LOCALS_REGEXP = /[_a-zα-ω][a-zα-ω]*\\d*/g;\nconst GLOBAL_ALIAS_SOURCE = '[XCSADFPTN]\\\\d+';\nconst GLOBALS_REGEXP = new RegExp(GLOBAL_ALIAS_SOURCE, 'g');\nconst GLOBAL_ALIAS_ANCHORED_REGEXP = new RegExp(`^${GLOBAL_ALIAS_SOURCE}$`);\nconst COMPLEX_SYMBOLS_REGEXP = /[∀∃×ℬ;|:]/g;\nconst TYPIFICATION_SET = /^ℬ+\\([ℬ\\(((X|C)\\d+|Z)\\)×]*\\)$/g;\n// cspell:enable\n\n/** Whether {@link value} is a single schema global alias (e.g. `X1`, `F42`). */\nexport function isGlobalAlias(value: string): boolean {\n return GLOBAL_ALIAS_ANCHORED_REGEXP.test(value);\n}\n\n/**\n * Parse a RSLang expression into a normalized AST.\n *\n * Returns `null` for blank input. Parses the original `expression` string so node\n * offsets match the source text (required for slice-based AST walks).\n */\nexport function parseRSLangExpression(expression: string): AstNode | null {\n if (!expression.trim()) {\n return null;\n }\n const tree = rslangParser.parse(expression);\n const ast = buildTree(tree.cursor());\n normalizeAST(ast, expression);\n return ast;\n}\n\n/** Extract arguments from AST. */\nexport function extractArguments(ast: AstNode): ArgumentsType[] {\n return new ArgumentsExtractor().run(ast);\n}\n\n/** Extracts global variable names from a given expression. */\nexport function extractGlobals(expression: string): Set<string> {\n return new Set(expression.match(GLOBALS_REGEXP) ?? []);\n}\n\n/** Check if expression is simple derivation. */\nexport function isSimpleExpression(text: string): boolean {\n return !text.match(COMPLEX_SYMBOLS_REGEXP);\n}\n\n/** Check if expression is set typification. */\nexport function isSetTypification(text: string): boolean {\n return !!text.match(TYPIFICATION_SET);\n}\n\n/**\n * Splits a string containing a template definition into its head and body parts.\n *\n * A template definition is expected to have the following format: `[head] body`.\n * If the input string does not contain the opening square bracket '[', the entire\n * string is treated as the body, and an empty string is assigned to the head.\n * If the opening bracket is present, the function attempts to find the matching\n * closing bracket ']' to determine the head and body parts.\n *\n * @example\n * const template = '[header] body content';\n * const result = splitTemplateDefinition(template);\n * // result: `{ head: 'header', body: 'body content' }`\n */\nexport function splitTemplateDefinition(target: string) {\n let start = 0;\n for (; start < target.length && target[start] !== '['; ++start);\n if (start < target.length) {\n for (let counter = 0, end = start + 1; end < target.length; ++end) {\n if (target[end] === '[') {\n ++counter;\n } else if (target[end] === ']') {\n if (counter !== 0) {\n --counter;\n } else {\n return {\n head: target.substring(start + 1, end).trim(),\n body: target.substring(end + 1).trim()\n };\n }\n }\n }\n }\n return {\n head: '',\n body: target\n };\n}\n\n/**\n * Substitutes values for template arguments in a given expression.\n *\n * This function takes an input mathematical expression and a list of argument values.\n * It replaces template argument placeholders in the expression with their corresponding values\n * from the provided arguments.\n */\nexport function substituteTemplateArgs(expression: string, mapping: AliasMapping): string {\n if (Object.keys(mapping).length === 0) {\n return expression;\n }\n let { head, body } = splitTemplateDefinition(expression);\n body = applyPattern(body, mapping, LOCALS_REGEXP);\n const argTexts = head.split(',').map(text => text.trim());\n head = argTexts\n .filter(arg => [...arg.matchAll(LOCALS_REGEXP)].every(local => local.every(match => !(match in mapping))))\n .join(', ');\n\n if (!head) {\n return body;\n } else {\n return `[${head}] ${body}`;\n }\n}\n\n/** Substitute local parameter aliases in an expression fragment. */\nexport function substituteLocalAliases(expression: string, mapping: AliasMapping): string {\n return applyPattern(expression, mapping, LOCALS_REGEXP);\n}\n\n/** Apply alias mapping. */\nexport function applyAliasMapping(target: string, mapping: AliasMapping): string {\n return applyPattern(target, mapping, GLOBALS_REGEXP);\n}\n\n/** Apply alias typification mapping. */\nexport function applyTypificationMapping(target: string, mapping: AliasMapping): string {\n const modified = applyAliasMapping(target, mapping);\n if (modified === target) {\n return target;\n }\n\n const deleteBrackets: number[] = [];\n const positions: number[] = [];\n const booleans: number[] = [];\n let boolCount: number = 0;\n let stackSize: number = 0;\n\n for (let i = 0; i < modified.length; i++) {\n const char = modified[i];\n if (char === 'ℬ') {\n boolCount++;\n continue;\n }\n if (char === '(') {\n stackSize++;\n positions.push(i);\n booleans.push(boolCount);\n }\n boolCount = 0;\n if (char === ')') {\n if (\n i < modified.length - 1 &&\n modified[i + 1] === ')' &&\n stackSize > 1 &&\n positions[stackSize - 2] + booleans[stackSize - 1] + 1 === positions[stackSize - 1]\n ) {\n deleteBrackets.push(i);\n deleteBrackets.push(positions[stackSize - 2]);\n }\n if (i === modified.length - 1 && stackSize === 1 && positions[0] === 0) {\n deleteBrackets.push(i);\n deleteBrackets.push(positions[0]);\n }\n stackSize--;\n positions.pop();\n booleans.pop();\n }\n }\n\n let result = '';\n for (let i = 0; i < modified.length; i++) {\n if (!deleteBrackets.includes(i)) {\n result += modified[i];\n }\n }\n\n return result;\n}\n\n// ====== Internals =========\n/** Text substitution guided by mapping and regular expression. */\nfunction applyPattern(text: string, mapping: AliasMapping, pattern: RegExp): string {\n if (text === '' || pattern === null) {\n return text;\n }\n let posInput = 0;\n let output = '';\n const patternMatches = text.matchAll(pattern);\n for (const segment of patternMatches) {\n const entity = segment[0];\n const start = segment.index ?? 0;\n if (entity in mapping) {\n output += text.substring(posInput, start);\n output += mapping[entity];\n posInput = start + segment[0].length;\n }\n }\n output += text.substring(posInput);\n return output;\n}\n"],"mappings":";;;;;;;;;;AAcA,MAAM,gBAAgB;AACtB,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB,IAAI,OAAO,qBAAqB,GAAG;AAC1D,MAAM,+BAA+B,IAAI,OAAO,IAAI,oBAAoB,EAAE;AAC1E,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;;AAIzB,SAAgB,cAAc,OAAwB;CACpD,OAAO,6BAA6B,KAAK,KAAK;AAChD;;;;;;;AAQA,SAAgB,sBAAsB,YAAoC;CACxE,IAAI,CAAC,WAAW,KAAK,GACnB,OAAO;CAGT,MAAM,MAAM,UADCA,OAAa,MAAM,UACV,CAAA,CAAK,OAAO,CAAC;CACnC,aAAa,KAAK,UAAU;CAC5B,OAAO;AACT;;AAGA,SAAgB,iBAAiB,KAA+B;CAC9D,OAAO,IAAI,mBAAmB,CAAC,CAAC,IAAI,GAAG;AACzC;;AAGA,SAAgB,eAAe,YAAiC;CAC9D,OAAO,IAAI,IAAI,WAAW,MAAM,cAAc,KAAK,CAAC,CAAC;AACvD;;AAGA,SAAgB,mBAAmB,MAAuB;CACxD,OAAO,CAAC,KAAK,MAAM,sBAAsB;AAC3C;;AAGA,SAAgB,kBAAkB,MAAuB;CACvD,OAAO,CAAC,CAAC,KAAK,MAAM,gBAAgB;AACtC;;;;;;;;;;;;;;;AAgBA,SAAgB,wBAAwB,QAAgB;CACtD,IAAI,QAAQ;CACZ,OAAO,QAAQ,OAAO,UAAU,OAAO,WAAW,KAAK,EAAE;CACzD,IAAI,QAAQ,OAAO,QACjB;OAAK,IAAI,UAAU,GAAG,MAAM,QAAQ,GAAG,MAAM,OAA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;EACtB,IAAI,SAAS,KAAK;GAChB;GACA;EACF;EACA,IAAI,SAAS,KAAK;GAChB;GACA,UAAU,KAAK,CAAC;GAChB,SAAS,KAAK,SAAS;EACzB;EACA,YAAY;EACZ,IAAI,SAAS,KAAK;GAChB,IACE,IAAI,SAAS,SAAS,KACtB,SAAS,IAAI,OAAO,OACpB,YAAY,KACZ,UAAU,YAAY,KAAK,SAAS,YAAY,KAAK,MAAM,UAAU,YAAY,IACjF;IACA,eAAe,KAAK,CAAC;IACrB,eAAe,KAAK,UAAU,YAAY,EAAE;GAC9C;GACA,IAAI,MAAM,SAAS,SAAS,KAAK,cAAc,KAAK,UAAU,OAAO,GAAG;IACtE,eAAe,KAAK,CAAC;IACrB,eAAe,KAAK,UAAU,EAAE;GAClC;GACA;GACA,UAAU,IAAI;GACd,SAAS,IAAI;EACf;CACF;CAEA,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KACnC,IAAI,CAAC,eAAe,SAAS,CAAC,GAC5B,UAAU,SAAS;CAIvB,OAAO;AACT;;AAIA,SAAS,aAAa,MAAc,SAAuB,SAAyB;CAClF,IAAI,SAAS,MAAM,YAAY,MAC7B,OAAO;CAET,IAAI,WAAW;CACf,IAAI,SAAS;CACb,MAAM,iBAAiB,KAAK,SAAS,OAAO;CAC5C,KAAK,MAAM,WAAW,gBAAgB;EACpC,MAAM,SAAS,QAAQ;EACvB,MAAM,QAAQ,QAAQ,SAAS;EAC/B,IAAI,UAAU,SAAS;GACrB,UAAU,KAAK,UAAU,UAAU,KAAK;GACxC,UAAU,QAAQ;GAClB,WAAW,QAAQ,QAAQ,EAAE,CAAC;EAChC;CACF;CACA,UAAU,KAAK,UAAU,QAAQ;CACjC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"api.js","names":["rslangParser"],"sources":["../../src/rslang/api.ts"],"sourcesContent":["/**\n * Module: API for RSLanguage.\n */\nimport { type AstNode, buildTree } from '../parsing';\n\nimport { normalizeAST } from './parser/normalize';\nimport { parser as rslangParser } from './parser/parser';\nimport { ArgumentsExtractor, type ArgumentsType } from './semantic/arguments-extractor';\nexport { generateExpressionFromAst } from './parser/expression-generator';\n\n/** Placeholder alias written into expressions in place of references to deleted constituents. */\nexport const DELETED_ALIAS = 'DEL';\n\n/** Represents alias mapping. */\nexport type AliasMapping = Record<string, string>;\n\n// cspell:disable\nconst LOCALS_REGEXP = /[_a-zα-ω][a-zα-ω]*\\d*/g;\nconst GLOBAL_ALIAS_SOURCE = '[XCSADFPTN]\\\\d+';\nconst GLOBALS_REGEXP = new RegExp(GLOBAL_ALIAS_SOURCE, 'g');\nconst GLOBAL_ALIAS_ANCHORED_REGEXP = new RegExp(`^${GLOBAL_ALIAS_SOURCE}$`);\nconst COMPLEX_SYMBOLS_REGEXP = /[∀∃×ℬ;|:]/g;\nconst TYPIFICATION_SET = /^ℬ+\\([ℬ\\(((X|C)\\d+|Z)\\)×]*\\)$/g;\n// cspell:enable\n\n/** Whether {@link value} is a single schema global alias (e.g. `X1`, `F42`). */\nexport function isGlobalAlias(value: string): boolean {\n return GLOBAL_ALIAS_ANCHORED_REGEXP.test(value);\n}\n\n/**\n * Parse a RSLang expression into a normalized AST.\n *\n * Returns `null` for blank input. Parses the original `expression` string so node\n * offsets match the source text (required for slice-based AST walks).\n */\nexport function parseRSLangExpression(expression: string): AstNode | null {\n if (!expression.trim()) {\n return null;\n }\n const tree = rslangParser.parse(expression);\n const ast = buildTree(tree.cursor());\n normalizeAST(ast, expression);\n return ast;\n}\n\n/** Extract arguments from AST. */\nexport function extractArguments(ast: AstNode): ArgumentsType[] {\n return new ArgumentsExtractor().run(ast);\n}\n\n/** Extracts global variable names from a given expression. */\nexport function extractGlobals(expression: string): Set<string> {\n return new Set(expression.match(GLOBALS_REGEXP) ?? []);\n}\n\n/** Check if expression is simple derivation. */\nexport function isSimpleExpression(text: string): boolean {\n return !text.match(COMPLEX_SYMBOLS_REGEXP);\n}\n\n/** Check if expression is set typification. */\nexport function isSetTypification(text: string): boolean {\n return !!text.match(TYPIFICATION_SET);\n}\n\n/**\n * Splits a string containing a template definition into its head and body parts.\n *\n * A template definition is expected to have the following format: `[head] body`.\n * If the input string does not contain the opening square bracket '[', the entire\n * string is treated as the body, and an empty string is assigned to the head.\n * If the opening bracket is present, the function attempts to find the matching\n * closing bracket ']' to determine the head and body parts.\n *\n * @example\n * const template = '[header] body content';\n * const result = splitTemplateDefinition(template);\n * // result: `{ head: 'header', body: 'body content' }`\n */\nexport function splitTemplateDefinition(target: string) {\n let start = 0;\n for (; start < target.length && target[start] !== '['; ++start);\n if (start < target.length) {\n for (let counter = 0, end = start + 1; end < target.length; ++end) {\n if (target[end] === '[') {\n ++counter;\n } else if (target[end] === ']') {\n if (counter !== 0) {\n --counter;\n } else {\n return {\n head: target.substring(start + 1, end).trim(),\n body: target.substring(end + 1).trim()\n };\n }\n }\n }\n }\n return {\n head: '',\n body: target\n };\n}\n\n/**\n * Substitutes values for template arguments in a given expression.\n *\n * This function takes an input mathematical expression and a list of argument values.\n * It replaces template argument placeholders in the expression with their corresponding values\n * from the provided arguments.\n */\nexport function substituteTemplateArgs(expression: string, mapping: AliasMapping): string {\n if (Object.keys(mapping).length === 0) {\n return expression;\n }\n let { head, body } = splitTemplateDefinition(expression);\n body = applyPattern(body, mapping, LOCALS_REGEXP);\n const argTexts = head.split(',').map(text => text.trim());\n head = argTexts\n .filter(arg => [...arg.matchAll(LOCALS_REGEXP)].every(local => local.every(match => !(match in mapping))))\n .join(', ');\n\n if (!head) {\n return body;\n } else {\n return `[${head}] ${body}`;\n }\n}\n\n/** Substitute local parameter aliases in an expression fragment. */\nexport function substituteLocalAliases(expression: string, mapping: AliasMapping): string {\n return applyPattern(expression, mapping, LOCALS_REGEXP);\n}\n\n/** Apply alias mapping. */\nexport function applyAliasMapping(target: string, mapping: AliasMapping): string {\n return applyPattern(target, mapping, GLOBALS_REGEXP);\n}\n\n/** Apply alias typification mapping. */\nexport function applyTypificationMapping(target: string, mapping: AliasMapping): string {\n const modified = applyAliasMapping(target, mapping);\n if (modified === target) {\n return target;\n }\n\n const deleteBrackets: number[] = [];\n const positions: number[] = [];\n const booleans: number[] = [];\n let boolCount: number = 0;\n let stackSize: number = 0;\n\n for (let i = 0; i < modified.length; i++) {\n const char = modified[i];\n if (char === 'ℬ') {\n boolCount++;\n continue;\n }\n if (char === '(') {\n stackSize++;\n positions.push(i);\n booleans.push(boolCount);\n }\n boolCount = 0;\n if (char === ')') {\n if (\n i < modified.length - 1 &&\n modified[i + 1] === ')' &&\n stackSize > 1 &&\n positions[stackSize - 2] + booleans[stackSize - 1] + 1 === positions[stackSize - 1]\n ) {\n deleteBrackets.push(i);\n deleteBrackets.push(positions[stackSize - 2]);\n }\n if (i === modified.length - 1 && stackSize === 1 && positions[0] === 0) {\n deleteBrackets.push(i);\n deleteBrackets.push(positions[0]);\n }\n stackSize--;\n positions.pop();\n booleans.pop();\n }\n }\n\n let result = '';\n for (let i = 0; i < modified.length; i++) {\n if (!deleteBrackets.includes(i)) {\n result += modified[i];\n }\n }\n\n return result;\n}\n\n// ====== Internals =========\n/** Text substitution guided by mapping and regular expression. */\nfunction applyPattern(text: string, mapping: AliasMapping, pattern: RegExp): string {\n if (text === '' || pattern === null) {\n return text;\n }\n let posInput = 0;\n let output = '';\n const patternMatches = text.matchAll(pattern);\n for (const segment of patternMatches) {\n const entity = segment[0];\n const start = segment.index ?? 0;\n if (entity in mapping) {\n output += text.substring(posInput, start);\n output += mapping[entity];\n posInput = start + segment[0].length;\n }\n }\n output += text.substring(posInput);\n return output;\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,gBAAgB;AAM7B,MAAM,gBAAgB;AACtB,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB,IAAI,OAAO,qBAAqB,GAAG;AAC1D,MAAM,+BAA+B,IAAI,OAAO,IAAI,oBAAoB,EAAE;AAC1E,MAAM,yBAAyB;AAC/B,MAAM,mBAAmB;;AAIzB,SAAgB,cAAc,O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e,KAAK,CAAC;IACrB,eAAe,KAAK,UAAU,EAAE;GAClC;GACA;GACA,UAAU,IAAI;GACd,SAAS,IAAI;EACf;CACF;CAEA,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,SAAS,QAAQ,KACnC,IAAI,CAAC,eAAe,SAAS,CAAC,GAC5B,UAAU,SAAS;CAIvB,OAAO;AACT;;AAIA,SAAS,aAAa,MAAc,SAAuB,SAAyB;CAClF,IAAI,SAAS,MAAM,YAAY,MAC7B,OAAO;CAET,IAAI,WAAW;CACf,IAAI,SAAS;CACb,MAAM,iBAAiB,KAAK,SAAS,OAAO;CAC5C,KAAK,MAAM,WAAW,gBAAgB;EACpC,MAAM,SAAS,QAAQ;EACvB,MAAM,QAAQ,QAAQ,SAAS;EAC/B,IAAI,UAAU,SAAS;GACrB,UAAU,KAAK,UAAU,UAAU,KAAK;GACxC,UAAU,QAAQ;GAClB,WAAW,QAAQ,QAAQ,EAAE,CAAC;EAChC;CACF;CACA,UAAU,KAAK,UAAU,QAAQ;CACjC,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as readTypeAnnotation, n as annotateType, r as readErrorAnnotation, t as annotateError } from "../ast-annotations-
|
|
1
|
+
import { i as readTypeAnnotation, n as annotateType, r as readErrorAnnotation, t as annotateError } from "../ast-annotations-B0XO6380.js";
|
|
2
2
|
export { annotateError, annotateType, readErrorAnnotation, readTypeAnnotation };
|
package/dist/rslang/error.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RSErrorDescription, c as getRSErrorPrefix, i as RSErrorCode, l as isCritical, n as EvalStackFrame, o as RSErrorInfo, r as RSErrorClass, s as formatEvalCallStack, t as ErrorReporter } from "../error-
|
|
1
|
+
import { a as RSErrorDescription, c as getRSErrorPrefix, i as RSErrorCode, l as isCritical, n as EvalStackFrame, o as RSErrorInfo, r as RSErrorClass, s as formatEvalCallStack, t as ErrorReporter } from "../error-DBbO_NIg.js";
|
|
2
2
|
export { ErrorReporter, EvalStackFrame, RSErrorClass, RSErrorCode, RSErrorDescription, RSErrorInfo, formatEvalCallStack, getRSErrorPrefix, isCritical };
|
package/dist/rslang/error.js
CHANGED
package/dist/rslang/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../src/rslang/error.ts"],"sourcesContent":["/** Module: Error types and functions. */\n\n/** Represents error class. */\nexport const RSErrorClass = {\n LEXER: 0,\n PARSER: 1,\n SEMANTIC: 2,\n EVALUATION: 3,\n UNKNOWN: 4\n} as const;\nexport type RSErrorClass = (typeof RSErrorClass)[keyof typeof RSErrorClass];\n\n/** Represents RSLang expression error information. */\nexport interface RSErrorInfo {\n code: RSErrorCode;\n params?: readonly string[];\n}\n\n/**\n * One frame of an evaluation call chain.\n *\n * Spans are relative to the formal definition of {@link alias}.\n * Frames are ordered innermost-first: fault locus, then each caller outward.\n * The root expression under evaluation is not a frame — its highlight is\n * {@link RSErrorDescription.from}/{@link RSErrorDescription.to}; {@link RSErrorDescription.stack}\n * is absent when the fault is in that root expression.\n */\nexport interface EvalStackFrame {\n /** Constituent whose formal definition contains this span. */\n alias: string;\n /** Half-open span `[from, to)` in that definition. */\n from: number;\n to: number;\n}\n\n/** Represents RSLang expression error description. */\nexport interface RSErrorDescription extends RSErrorInfo {\n from: number;\n to: number;\n /**\n * Evaluation call chain when the fault is inside a called `F#`/`P#` body.\n * Absent for parse/semantic errors and for evaluation errors in the root expression.\n */\n stack?: readonly EvalStackFrame[];\n}\n\n/** Error reporter function type. */\nexport type ErrorReporter = (error: RSErrorDescription) => void;\n\n/**\n * Formats an evaluation call chain for display (`F5 → F12`).\n *\n * Uses callee aliases from outermost call to innermost fault container.\n * Returns an empty string when there is no nested call to show.\n */\nexport function formatEvalCallStack(stack: readonly EvalStackFrame[] | undefined): string {\n if (!stack || stack.length === 0) {\n return '';\n }\n const aliases: string[] = [];\n for (let index = stack.length - 1; index >= 0; index--) {\n const frame = stack[index];\n if (frame) {\n aliases.push(frame.alias);\n }\n }\n return aliases.join(' → ');\n}\n\n/** Represents RSLang expression error types. */\nexport const RSErrorCode = {\n unknownSyntax: 0x8400, // 33792\n forbiddenCharacter: 0x8401, // 33793\n bracketMismatch: 0x8409, // 33801\n doubleParenthesis: 0x840a, // 33802\n missingOpenBracket: 0x840b, // 33803\n missingCloseBracket: 0x840c, // 33804\n invalidFilterSyntax: 0x8417, // 33815\n expectedFunctionBody: 0x8418, // 33816\n expectedExpressionBody: 0x8419, // 33817\n expectedLogicBody: 0x841a, // 33818\n expectedQuantifierBody: 0x841b, // 33819\n expectedDeclarativeBody: 0x841c, // 33820\n expectedImperativeBody: 0x841d, // 33821\n expectedRecursiveBody: 0x841e, // 33822\n expectedQuantifierDomain: 0x841f, // 33823\n expectedRightOperand: 0x8420, // 33824\n expectedUnaryOperand: 0x8421, // 33825\n globalFuncParenCall: 0x8422, // 33826\n expectedArgument: 0x8423, // 33827\n expectedLocal: 0x8415, // 33813\n expectedType: 0x8416, // 33814\n\n localNotUsed: 0x2802, // 10242\n\n localUndeclared: 0x8801, // 34817\n localShadowing: 0x8802, // 34818\n localDoubleDeclare: 0x8803, // 34819\n\n typesNotEqual: 0x880a, // 34826\n globalNotTyped: 0x8804, // 34820\n invalidDecart: 0x8805, // 34821\n invalidBoolean: 0x8806, // 34822\n invalidTypeOperation: 0x8807, // 34823\n invalidCard: 0x8808, // 34824\n invalidDebool: 0x8809, // 34825\n globalFuncWithoutArgs: 0x880b, // 34827\n invalidReduce: 0x8810, // 34832\n invalidEnumeration: 0x8813, // 34835\n projectionSetArgumentNotSet: 0x8830, // 34864\n projectionSetArgumentNotTupleSet: 0x8831, // 34865\n projectionSetIndexOutOfRange: 0x8832, // 34866\n projectionTupleArgumentNotTuple: 0x8833, // 34867\n projectionTupleIndexOutOfRange: 0x8834, // 34868\n invalidCortegeDeclare: 0x8814, // 34836\n localOutOfScope: 0x8815, // 34837\n invalidElementPredicate: 0x8816, // 34838\n invalidEmptySetUsage: 0x8817, // 34839\n invalidArgsArity: 0x8818, // 34840\n invalidArgumentType: 0x8819, // 34841\n globalStructure: 0x881c, // 34844\n radicalUsage: 0x8821, // 34849\n invalidFilterArgumentType: 0x8822, // 34850\n invalidFilterArity: 0x8823, // 34851\n arithmeticNotSupported: 0x8824, // 34852\n typesNotCompatible: 0x8825, // 34853\n orderingNotSupported: 0x8826, // 34854\n expectedLogic: 0x8827, // 34855\n expectedSetexpr: 0x8828, // 34856\n invalidArgumentCortegeDeclare: 0x8829, // 34857\n invalidQuantifierDomain: 0x882a, // 34858\n invalidFilterParameterType: 0x882b, // 34859\n invalidFilterIndex: 0x882c, // 34860\n invalidFilterBooleanEchelon: 0x882d, // 34861\n localOutOfScopeParentheses: 0x882e, // 34862\n localUndeclaredInSubexpr: 0x882f, // 34863\n\n globalNoValue: 0x8840, // 34880\n invalidPropertyUsage: 0x8841, // 34881\n\n // Value evaluation (runtime)\n calcUnknownError: 0x8100, // 35328\n setOverflow: 0x8101, // 35329\n booleanBaseLimit: 0x8102, // 35330\n calcGlobalMissing: 0x8103, // 35331\n iterationsLimit: 0x8104, // 35332\n calcInvalidDebool: 0x8105, // 35333\n iterateInfinity: 0x8106, // 35334\n calculationNotSupported: 0x8107, // 35335\n calcInvalidData: 0x8108, // 35336\n\n cstEmptyDerived: 0x8861, // 34913\n definitionNotAllowed: 0x8862, // 34914\n\n // Schema diagnostics surfaced in expression analysis (same value as RSDiagnosticCode.schemaDependencyCycle).\n schemaDependencyCycle: 0x8906 // 35078\n} as const;\nexport type RSErrorCode = (typeof RSErrorCode)[keyof typeof RSErrorCode];\n\nconst ERROR_EVALUATION_MASK = 0x0100;\nconst ERROR_LEXER_MASK = 0x0200;\nconst ERROR_PARSER_MASK = 0x0400;\nconst ERROR_SEMANTIC_MASK = 0x0800;\n\n/** Infers error class from error type (code). */\nfunction inferErrorClass(error: RSErrorCode): RSErrorClass {\n if ((error & ERROR_EVALUATION_MASK) !== 0) {\n return RSErrorClass.EVALUATION;\n } else if ((error & ERROR_LEXER_MASK) !== 0) {\n return RSErrorClass.LEXER;\n } else if ((error & ERROR_PARSER_MASK) !== 0) {\n return RSErrorClass.PARSER;\n } else if ((error & ERROR_SEMANTIC_MASK) !== 0) {\n return RSErrorClass.SEMANTIC;\n } else {\n return RSErrorClass.UNKNOWN;\n }\n}\n\n/** Generate ErrorID label. */\nexport function getRSErrorPrefix(code: RSErrorCode): string {\n const id = code.toString(16).toUpperCase();\n // prettier-ignore\n switch (inferErrorClass(code)) {\n case RSErrorClass.LEXER: return 'L' + id;\n case RSErrorClass.PARSER: return 'P' + id;\n case RSErrorClass.SEMANTIC: return 'S' + id;\n case RSErrorClass.EVALUATION: return 'E' + id;\n case RSErrorClass.UNKNOWN: return 'U' + id;\n }\n}\n\n/** Checks if error is critical. */\nexport function isCritical(code: RSErrorCode): boolean {\n if ((code & 0xf000) === 0x2000) {\n return false;\n }\n return true;\n}\n"],"mappings":";;;AAGA,MAAa,eAAe;CAC1B,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;AACX;;;;;;;AA8CA,SAAgB,oBAAoB,OAAsD;CACxF,IAAI,CAAC,SAAS,MAAM,WAAW,GAC7B,OAAO;CAET,MAAM,UAAoB,CAAC;CAC3B,KAAK,IAAI,QAAQ,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS;EACtD,MAAM,QAAQ,MAAM;EACpB,IAAI,OACF,QAAQ,KAAK,MAAM,KAAK;CAE5B;CACA,OAAO,QAAQ,KAAK,KAAK;AAC3B;;AAGA,MAAa,cAAc;CACzB,eAAe;CACf,oBAAoB;CACpB,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,sBAAsB;CACtB,wBAAwB;CACxB,mBAAmB;CACnB,wBAAwB;CACxB,yBAAyB;CACzB,wBAAwB;CACxB,uBAAuB;CACvB,0BAA0B;CAC1B,sBAAsB;CACtB,sB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AAC,YAAY;CAEzC,QAAQ,gBAAgB,IAAI,GAA5B;EACE,KAAK,aAAa,OAAO,OAAO,MAAM;EACtC,KAAK,aAAa,QAAQ,OAAO,MAAM;EACvC,KAAK,aAAa,UAAU,OAAO,MAAM;EACzC,KAAK,aAAa,YAAY,OAAO,MAAM;EAC3C,KAAK,aAAa,SAAS,OAAO,MAAM;CAC1C;AACF;;AAGA,SAAgB,WAAW,MAA4B;CACrD,KAAK,OAAO,WAAY,MACtB,OAAO;CAET,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../src/rslang/error.ts"],"sourcesContent":["/** Module: Error types and functions. */\n\n/** Represents error class. */\nexport const RSErrorClass = {\n LEXER: 0,\n PARSER: 1,\n SEMANTIC: 2,\n EVALUATION: 3,\n UNKNOWN: 4\n} as const;\nexport type RSErrorClass = (typeof RSErrorClass)[keyof typeof RSErrorClass];\n\n/** Represents RSLang expression error information. */\nexport interface RSErrorInfo {\n code: RSErrorCode;\n params?: readonly string[];\n}\n\n/**\n * One frame of an evaluation call chain.\n *\n * Spans are relative to the formal definition of {@link alias}.\n * Frames are ordered innermost-first: fault locus, then each caller outward.\n * The root expression under evaluation is not a frame — its highlight is\n * {@link RSErrorDescription.from}/{@link RSErrorDescription.to}; {@link RSErrorDescription.stack}\n * is absent when the fault is in that root expression.\n */\nexport interface EvalStackFrame {\n /** Constituent whose formal definition contains this span. */\n alias: string;\n /** Half-open span `[from, to)` in that definition. */\n from: number;\n to: number;\n}\n\n/** Represents RSLang expression error description. */\nexport interface RSErrorDescription extends RSErrorInfo {\n from: number;\n to: number;\n /**\n * Evaluation call chain when the fault is inside a called `F#`/`P#` body.\n * Absent for parse/semantic errors and for evaluation errors in the root expression.\n */\n stack?: readonly EvalStackFrame[];\n}\n\n/** Error reporter function type. */\nexport type ErrorReporter = (error: RSErrorDescription) => void;\n\n/**\n * Formats an evaluation call chain for display (`F5 → F12`).\n *\n * Uses callee aliases from outermost call to innermost fault container.\n * Returns an empty string when there is no nested call to show.\n */\nexport function formatEvalCallStack(stack: readonly EvalStackFrame[] | undefined): string {\n if (!stack || stack.length === 0) {\n return '';\n }\n const aliases: string[] = [];\n for (let index = stack.length - 1; index >= 0; index--) {\n const frame = stack[index];\n if (frame) {\n aliases.push(frame.alias);\n }\n }\n return aliases.join(' → ');\n}\n\n/** Represents RSLang expression error types. */\nexport const RSErrorCode = {\n unknownSyntax: 0x8400, // 33792\n forbiddenCharacter: 0x8401, // 33793\n bracketMismatch: 0x8409, // 33801\n doubleParenthesis: 0x840a, // 33802\n missingOpenBracket: 0x840b, // 33803\n missingCloseBracket: 0x840c, // 33804\n invalidFilterSyntax: 0x8417, // 33815\n expectedFunctionBody: 0x8418, // 33816\n expectedExpressionBody: 0x8419, // 33817\n expectedLogicBody: 0x841a, // 33818\n expectedQuantifierBody: 0x841b, // 33819\n expectedDeclarativeBody: 0x841c, // 33820\n expectedImperativeBody: 0x841d, // 33821\n expectedRecursiveBody: 0x841e, // 33822\n expectedQuantifierDomain: 0x841f, // 33823\n expectedRightOperand: 0x8420, // 33824\n expectedUnaryOperand: 0x8421, // 33825\n globalFuncParenCall: 0x8422, // 33826\n expectedArgument: 0x8423, // 33827\n expectedLocal: 0x8415, // 33813\n expectedType: 0x8416, // 33814\n\n localNotUsed: 0x2802, // 10242\n\n localUndeclared: 0x8801, // 34817\n localShadowing: 0x8802, // 34818\n localDoubleDeclare: 0x8803, // 34819\n\n typesNotEqual: 0x880a, // 34826\n globalNotTyped: 0x8804, // 34820\n invalidDecart: 0x8805, // 34821\n invalidBoolean: 0x8806, // 34822\n invalidTypeOperation: 0x8807, // 34823\n invalidCard: 0x8808, // 34824\n invalidDebool: 0x8809, // 34825\n globalFuncWithoutArgs: 0x880b, // 34827\n globalDeleted: 0x880c, // 34828\n invalidReduce: 0x8810, // 34832\n invalidEnumeration: 0x8813, // 34835\n projectionSetArgumentNotSet: 0x8830, // 34864\n projectionSetArgumentNotTupleSet: 0x8831, // 34865\n projectionSetIndexOutOfRange: 0x8832, // 34866\n projectionTupleArgumentNotTuple: 0x8833, // 34867\n projectionTupleIndexOutOfRange: 0x8834, // 34868\n invalidCortegeDeclare: 0x8814, // 34836\n localOutOfScope: 0x8815, // 34837\n invalidElementPredicate: 0x8816, // 34838\n invalidEmptySetUsage: 0x8817, // 34839\n invalidArgsArity: 0x8818, // 34840\n invalidArgumentType: 0x8819, // 34841\n globalStructure: 0x881c, // 34844\n radicalUsage: 0x8821, // 34849\n invalidFilterArgumentType: 0x8822, // 34850\n invalidFilterArity: 0x8823, // 34851\n arithmeticNotSupported: 0x8824, // 34852\n typesNotCompatible: 0x8825, // 34853\n orderingNotSupported: 0x8826, // 34854\n expectedLogic: 0x8827, // 34855\n expectedSetexpr: 0x8828, // 34856\n invalidArgumentCortegeDeclare: 0x8829, // 34857\n invalidQuantifierDomain: 0x882a, // 34858\n invalidFilterParameterType: 0x882b, // 34859\n invalidFilterIndex: 0x882c, // 34860\n invalidFilterBooleanEchelon: 0x882d, // 34861\n localOutOfScopeParentheses: 0x882e, // 34862\n localUndeclaredInSubexpr: 0x882f, // 34863\n\n globalNoValue: 0x8840, // 34880\n invalidPropertyUsage: 0x8841, // 34881\n\n // Value evaluation (runtime)\n calcUnknownError: 0x8100, // 35328\n setOverflow: 0x8101, // 35329\n booleanBaseLimit: 0x8102, // 35330\n calcGlobalMissing: 0x8103, // 35331\n iterationsLimit: 0x8104, // 35332\n calcInvalidDebool: 0x8105, // 35333\n iterateInfinity: 0x8106, // 35334\n calculationNotSupported: 0x8107, // 35335\n calcInvalidData: 0x8108, // 35336\n\n cstEmptyDerived: 0x8861, // 34913\n definitionNotAllowed: 0x8862, // 34914\n\n // Schema diagnostics surfaced in expression analysis (same value as RSDiagnosticCode.schemaDependencyCycle).\n schemaDependencyCycle: 0x8906 // 35078\n} as const;\nexport type RSErrorCode = (typeof RSErrorCode)[keyof typeof RSErrorCode];\n\nconst ERROR_EVALUATION_MASK = 0x0100;\nconst ERROR_LEXER_MASK = 0x0200;\nconst ERROR_PARSER_MASK = 0x0400;\nconst ERROR_SEMANTIC_MASK = 0x0800;\n\n/** Infers error class from error type (code). */\nfunction inferErrorClass(error: RSErrorCode): RSErrorClass {\n if ((error & ERROR_EVALUATION_MASK) !== 0) {\n return RSErrorClass.EVALUATION;\n } else if ((error & ERROR_LEXER_MASK) !== 0) {\n return RSErrorClass.LEXER;\n } else if ((error & ERROR_PARSER_MASK) !== 0) {\n return RSErrorClass.PARSER;\n } else if ((error & ERROR_SEMANTIC_MASK) !== 0) {\n return RSErrorClass.SEMANTIC;\n } else {\n return RSErrorClass.UNKNOWN;\n }\n}\n\n/** Generate ErrorID label. */\nexport function getRSErrorPrefix(code: RSErrorCode): string {\n const id = code.toString(16).toUpperCase();\n // prettier-ignore\n switch (inferErrorClass(code)) {\n case RSErrorClass.LEXER: return 'L' + id;\n case RSErrorClass.PARSER: return 'P' + id;\n case RSErrorClass.SEMANTIC: return 'S' + id;\n case RSErrorClass.EVALUATION: return 'E' + id;\n case RSErrorClass.UNKNOWN: return 'U' + id;\n }\n}\n\n/** Checks if error is critical. */\nexport function isCritical(code: RSErrorCode): boolean {\n if ((code & 0xf000) === 0x2000) {\n return false;\n }\n return true;\n}\n"],"mappings":";;;AAGA,MAAa,eAAe;CAC1B,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;AACX;;;;;;;AA8CA,SAAgB,oBAAoB,OAAsD;CACxF,IAAI,CAAC,SAAS,MAAM,WAAW,GAC7B,OAAO;CAET,MAAM,UAAoB,CAAC;CAC3B,KAAK,IAAI,QAAQ,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS;EACtD,MAAM,QAAQ,MAAM;EACpB,IAAI,OACF,QAAQ,KAAK,MAAM,KAAK;CAE5B;CACA,OAAO,QAAQ,KAAK,KAAK;AAC3B;;AAGA,MAAa,cAAc;CACzB,eAAe;CACf,oBAAoB;CACpB,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,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,uBAAuB,GACzC,OAAO,aAAa;MACf,KAAK,QAAQ,yBAAyB,GAC3C,OAAO,aAAa;MAEpB,OAAO,aAAa;AAExB;;AAGA,SAAgB,iBAAiB,MAA2B;CAC1D,MAAM,KAAK,KAAK,SAAS,EAAE,CAAC,CAAC,YAAY;CAEzC,QAAQ,gBAAgB,IAAI,GAA5B;EACE,KAAK,aAAa,OAAO,OAAO,MAAM;EACtC,KAAK,aAAa,QAAQ,OAAO,MAAM;EACvC,KAAK,aAAa,UAAU,OAAO,MAAM;EACzC,KAAK,aAAa,YAAY,OAAO,MAAM;EAC3C,KAAK,aAAa,SAAS,OAAO,MAAM;CAC1C;AACF;;AAGA,SAAgB,WAAW,MAA4B;CACrD,KAAK,OAAO,WAAY,MACtB,OAAO;CAET,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../../calculator-
|
|
1
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../../calculator-SVf1trzN.js";
|
|
2
2
|
export { CalculatorEvaluateOptions, CalculatorResult, RSCalculator };
|