@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":"typification-parser.js","names":[],"sources":["../../../src/rslang/semantic/typification-parser.ts"],"sourcesContent":["import {\n bool,\n type ExpressionType,\n IntegerT,\n isTypification,\n LogicT,\n tuple,\n TypeID,\n type Typification\n} from './typification';\n\nexport interface TypificationParseResult {\n type: ExpressionType | null;\n error: string | null;\n}\n\nexport function parseTypeText(input: string): TypificationParseResult {\n const normalized = input.trim().replaceAll('->', '→');\n if (normalized.length === 0) {\n return { type: null, error: null };\n }\n const parser = new TypificationParser(normalized);\n return parser.parse();\n}\n\n/** ASCII substitutions while editing typification text */\nexport function applyAsciiTypeSubstitutions(raw: string): string {\n return raw.replaceAll('->', '→').replaceAll('*', '×').replaceAll('B', 'ℬ');\n}\n\nclass TypificationParser {\n private index = 0;\n private input: string;\n\n constructor(input: string) {\n this.index = 0;\n this.input = input;\n }\n\n parse(): TypificationParseResult {\n try {\n const result = this.parseExpressionType();\n this.skipSpaces();\n if (!this.eof()) {\n throw new Error('Unexpected trailing symbols');\n }\n return { type: result, error: null };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return { type: null, error: message };\n }\n }\n\n private parseExpressionType(): ExpressionType {\n this.skipSpaces();\n if (this.peek() === '[') {\n return this.parseCallableType();\n } else {\n return this.parseTypification();\n }\n }\n\n private parseCallableType(): ExpressionType {\n this.expect('[');\n const args: Typification[] = [];\n this.skipSpaces();\n if (this.peek() !== ']') {\n while (true) {\n args.push(this.parseTypification());\n this.skipSpaces();\n if (this.peek() === ',') {\n this.next();\n this.skipSpaces();\n if (this.peek() === ']') {\n throw new Error('Empty argument in callable typification');\n }\n continue;\n }\n break;\n }\n }\n this.expect(']');\n this.skipSpaces();\n this.expect('→');\n const result = this.parseCallableResult();\n if (result.typeID === TypeID.logic) {\n return {\n typeID: TypeID.predicate,\n result: LogicT,\n args: args.map((arg, index) => ({ alias: `a${index + 1}`, type: arg }))\n };\n }\n if (!isTypification(result)) {\n throw new Error('Invalid callable result type');\n }\n return {\n typeID: TypeID.function,\n result: result as Typification,\n args: args.map((arg, index) => ({ alias: `a${index + 1}`, type: arg }))\n };\n }\n\n private parseCallableResult(): ExpressionType {\n this.skipSpaces();\n const lookahead = this.readToken();\n this.index -= lookahead.length;\n if (lookahead === 'Logic') {\n this.index += lookahead.length;\n return LogicT;\n }\n return this.parseTypification();\n }\n\n private parseTypification(): Typification {\n this.skipSpaces();\n if (this.match('ℬ')) {\n this.skipSpaces();\n if (this.peek() === '(') {\n this.next();\n const base = this.parseTypification();\n this.expect(')');\n return bool(base);\n }\n this.skipSpaces();\n if (this.input.startsWith('ℬ', this.index)) {\n const base = this.parseTypification();\n return bool(base);\n }\n throw new Error('Expected \"(\" after \"ℬ\"');\n }\n const first = this.parseTypificationAtom();\n const factors: Typification[] = [first];\n while (true) {\n this.skipSpaces();\n if (!this.match('×')) {\n break;\n }\n factors.push(this.parseTypificationAtom());\n }\n if (factors.length === 1) {\n return first;\n }\n return tuple(factors);\n }\n\n private parseTypificationAtom(): Typification {\n this.skipSpaces();\n if (this.input.startsWith('ℬ', this.index)) {\n return this.parseTypification();\n }\n if (this.peek() === '(') {\n this.next();\n const wrapped = this.parseTypification();\n this.expect(')');\n return wrapped;\n }\n const token = this.readToken();\n if (token === 'Z') {\n return IntegerT;\n }\n if (token === 'R0') {\n return { typeID: TypeID.anyTypification };\n }\n if (!/^[A-Z]\\d+$/.test(token)) {\n throw new Error(`Unknown typification token \"${token}\"`);\n }\n return { typeID: TypeID.basic, baseID: token };\n }\n\n private readToken(): string {\n this.skipSpaces();\n const start = this.index;\n while (!this.eof()) {\n const char = this.peek();\n if (!char || /[\\s,()[\\]→×]/.test(char)) {\n break;\n }\n this.next();\n }\n if (start === this.index) {\n throw new Error('Expected typification token');\n }\n return this.input.slice(start, this.index);\n }\n\n private skipSpaces(): void {\n while (!this.eof() && /\\s/.test(this.peek()!)) {\n this.index += 1;\n }\n }\n\n private expect(symbol: string): void {\n this.skipSpaces();\n if (!this.match(symbol)) {\n throw new Error(`Expected \"${symbol}\"`);\n }\n }\n\n private match(symbol: string): boolean {\n if (this.input.startsWith(symbol, this.index)) {\n this.index += symbol.length;\n return true;\n }\n return false;\n }\n\n private peek(): string | undefined {\n return this.input[this.index];\n }\n\n private next(): string | undefined {\n const value = this.input[this.index];\n this.index += 1;\n return value;\n }\n\n private eof(): boolean {\n return this.index >= this.input.length;\n }\n}\n"],"mappings":";;AAgBA,SAAgB,cAAc,OAAwC;CACpE,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,WAAW,MAAM,GAAG;CACpD,IAAI,WAAW,WAAW,GACxB,OAAO;EAAE,MAAM;EAAM,OAAO;CAAK;CAGnC,OAAO,IADY,mBAAmB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AW;IAAE,OAAO,IAAI,QAAQ;IAAK,MAAM;GAAI,EAAE;EACxE;EAEF,IAAI,CAAC,eAAe,MAAM,GACxB,MAAM,IAAI,MAAM,8BAA8B;EAEhD,OAAO;GACL,QAAQ,OAAO;GACP;GACR,MAAM,KAAK,KAAK,KAAK,WAAW;IAAE,OAAO,IAAI,QAAQ;IAAK,MAAM;GAAI,EAAE;EACxE;CACF;CAEA,sBAA8C;EAC5C,KAAK,WAAW;EAChB,MAAM,YAAY,KAAK,UAAU;EACjC,KAAK,SAAS,UAAU;EACxB,IAAI,cAAc,SAAS;GACzB,KAAK,SAAS,UAAU;GACxB,OAAO;EACT;EACA,OAAO,KAAK,kBAAkB;CAChC;CAEA,oBAA0C;EACxC,KAAK,WAAW;EAChB,IAAI,KAAK,MAAM,GAAG,GAAG;GACnB,KAAK,WAAW;GAChB,IAAI,KAAK,KAAK,MAAM,KAAK;IACvB,KAAK,KAAK;IACV,MAAM,OAAO,KAAK,kBAAkB;IACpC,KAAK,OAAO,GAAG;IACf,OAAO,KAAK,IAAI;GAClB;GACA,KAAK,WAAW;GAChB,IAAI,KAAK,MAAM,WAAW,KAAK,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"typification-parser.js","names":[],"sources":["../../../src/rslang/semantic/typification-parser.ts"],"sourcesContent":["import {\n bool,\n type ExpressionType,\n IntegerT,\n isTypification,\n LogicT,\n tuple,\n TypeID,\n type Typification\n} from './typification';\n\nexport interface TypificationParseResult {\n type: ExpressionType | null;\n error: string | null;\n}\n\nexport function parseTypeText(input: string): TypificationParseResult {\n const normalized = input.trim().replaceAll('->', '→');\n if (normalized.length === 0) {\n return { type: null, error: null };\n }\n const parser = new TypificationParser(normalized);\n return parser.parse();\n}\n\n/** ASCII substitutions while editing typification text */\nexport function applyAsciiTypeSubstitutions(raw: string): string {\n return raw.replaceAll('->', '→').replaceAll('*', '×').replaceAll('B', 'ℬ');\n}\n\nclass TypificationParser {\n private index = 0;\n private input: string;\n\n constructor(input: string) {\n this.index = 0;\n this.input = input;\n }\n\n parse(): TypificationParseResult {\n try {\n const result = this.parseExpressionType();\n this.skipSpaces();\n if (!this.eof()) {\n throw new Error('Unexpected trailing symbols');\n }\n return { type: result, error: null };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return { type: null, error: message };\n }\n }\n\n private parseExpressionType(): ExpressionType {\n this.skipSpaces();\n if (this.peek() === '[') {\n return this.parseCallableType();\n } else {\n return this.parseTypification();\n }\n }\n\n private parseCallableType(): ExpressionType {\n this.expect('[');\n const args: Typification[] = [];\n this.skipSpaces();\n if (this.peek() !== ']') {\n while (true) {\n args.push(this.parseTypification());\n this.skipSpaces();\n if (this.peek() === ',') {\n this.next();\n this.skipSpaces();\n if (this.peek() === ']') {\n throw new Error('Empty argument in callable typification');\n }\n continue;\n }\n break;\n }\n }\n this.expect(']');\n this.skipSpaces();\n this.expect('→');\n const result = this.parseCallableResult();\n if (result.typeID === TypeID.logic) {\n return {\n typeID: TypeID.predicate,\n result: LogicT,\n args: args.map((arg, index) => ({ alias: `a${index + 1}`, type: arg }))\n };\n }\n if (!isTypification(result)) {\n throw new Error('Invalid callable result type');\n }\n return {\n typeID: TypeID.function,\n result: result as Typification,\n args: args.map((arg, index) => ({ alias: `a${index + 1}`, type: arg }))\n };\n }\n\n private parseCallableResult(): ExpressionType {\n this.skipSpaces();\n const lookahead = this.readToken();\n this.index -= lookahead.length;\n if (lookahead === 'Logic') {\n this.index += lookahead.length;\n return LogicT;\n }\n return this.parseTypification();\n }\n\n private parseTypification(): Typification {\n this.skipSpaces();\n if (this.match('ℬ')) {\n this.skipSpaces();\n if (this.peek() === '(') {\n this.next();\n const base = this.parseTypification();\n this.expect(')');\n return bool(base);\n }\n this.skipSpaces();\n if (this.input.startsWith('ℬ', this.index)) {\n const base = this.parseTypification();\n return bool(base);\n }\n throw new Error('Expected \"(\" after \"ℬ\"');\n }\n const first = this.parseTypificationAtom();\n const factors: Typification[] = [first];\n while (true) {\n this.skipSpaces();\n if (!this.match('×')) {\n break;\n }\n factors.push(this.parseTypificationAtom());\n }\n if (factors.length === 1) {\n return first;\n }\n return tuple(factors);\n }\n\n private parseTypificationAtom(): Typification {\n this.skipSpaces();\n if (this.input.startsWith('ℬ', this.index)) {\n return this.parseTypification();\n }\n if (this.peek() === '(') {\n this.next();\n const wrapped = this.parseTypification();\n this.expect(')');\n return wrapped;\n }\n const token = this.readToken();\n if (token === 'Z') {\n return IntegerT;\n }\n if (token === 'R0') {\n return { typeID: TypeID.anyTypification };\n }\n if (!/^[A-Z]\\d+$/.test(token)) {\n throw new Error(`Unknown typification token \"${token}\"`);\n }\n return { typeID: TypeID.basic, baseID: token };\n }\n\n private readToken(): string {\n this.skipSpaces();\n const start = this.index;\n while (!this.eof()) {\n const char = this.peek();\n if (!char || /[\\s,()[\\]→×]/.test(char)) {\n break;\n }\n this.next();\n }\n if (start === this.index) {\n throw new Error('Expected typification token');\n }\n return this.input.slice(start, this.index);\n }\n\n private skipSpaces(): void {\n while (!this.eof() && /\\s/.test(this.peek()!)) {\n this.index += 1;\n }\n }\n\n private expect(symbol: string): void {\n this.skipSpaces();\n if (!this.match(symbol)) {\n throw new Error(`Expected \"${symbol}\"`);\n }\n }\n\n private match(symbol: string): boolean {\n if (this.input.startsWith(symbol, this.index)) {\n this.index += symbol.length;\n return true;\n }\n return false;\n }\n\n private peek(): string | undefined {\n return this.input[this.index];\n }\n\n private next(): string | undefined {\n const value = this.input[this.index];\n this.index += 1;\n return value;\n }\n\n private eof(): boolean {\n return this.index >= this.input.length;\n }\n}\n"],"mappings":";;AAgBA,SAAgB,cAAc,OAAwC;CACpE,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,WAAW,MAAM,GAAG;CACpD,IAAI,WAAW,WAAW,GACxB,OAAO;EAAE,MAAM;EAAM,OAAO;CAAK;CAGnC,OAAO,IADY,mBAAmB,UAC/B,CAAA,CAAO,MAAM;AACtB;;AAGA,SAAgB,4BAA4B,KAAqB;CAC/D,OAAO,IA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5RahF1K.js";
|
|
3
|
-
import { t as ErrorReporter } from "../../error-
|
|
3
|
+
import { t as ErrorReporter } from "../../error-DBbO_NIg.js";
|
|
4
4
|
import { n as ValueClassContext, t as ValueClass } from "../../value-class-CNI-lqXJ.js";
|
|
5
5
|
//#region src/rslang/semantic/value-auditor.d.ts
|
|
6
6
|
/** Value auditor for AST value class checking. */
|
|
7
|
-
declare class ValueAuditor {
|
|
7
|
+
export declare class ValueAuditor {
|
|
8
8
|
private context;
|
|
9
9
|
private annotateErrors;
|
|
10
10
|
private reporter?;
|
|
@@ -33,5 +33,4 @@ declare class ValueAuditor {
|
|
|
33
33
|
private visitSetexprBinary;
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
|
-
export { ValueAuditor };
|
|
37
36
|
//# sourceMappingURL=value-auditor.d.ts.map
|
package/dist/shared/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { applyHash_fnv1a, generateStub };
|
|
1
|
+
export { applyHash_fnv1a, generateStub } from "./hash.js";
|
|
@@ -4,6 +4,7 @@ import { TokenID } from "./rslang/parser/token.js";
|
|
|
4
4
|
import { TypeClass } from "./rslang/semantic/typification.js";
|
|
5
5
|
import "./rslang/parser/parser.terms.js";
|
|
6
6
|
import { annotateError } from "./rslang/ast-annotations.js";
|
|
7
|
+
import "./rslang/api.js";
|
|
7
8
|
import { RSErrorCode } from "./rslang/error.js";
|
|
8
9
|
//#region src/rslang/parser/syntax-errors/context.ts
|
|
9
10
|
/** Skips classifiers that conflict with bracket-level diagnostics. */
|
|
@@ -528,6 +529,19 @@ function extractForbiddenCharacterErrors(expression) {
|
|
|
528
529
|
}
|
|
529
530
|
return errors;
|
|
530
531
|
}
|
|
532
|
+
/** Matches {@link DELETED_ALIAS} as a standalone identifier (not a part of a longer name). */
|
|
533
|
+
const DELETED_ALIAS_REGEXP = new RegExp(`(?<![\\p{L}\\p{N}_])DEL(?![\\p{L}\\p{N}_])`, "gu");
|
|
534
|
+
/** Reports every reference to a deleted constituent ({@link DELETED_ALIAS}) in the expression. */
|
|
535
|
+
function extractDeletedReferenceErrors(expression) {
|
|
536
|
+
const errors = [];
|
|
537
|
+
for (const match of expression.matchAll(DELETED_ALIAS_REGEXP)) errors.push({
|
|
538
|
+
code: RSErrorCode.globalDeleted,
|
|
539
|
+
from: match.index,
|
|
540
|
+
to: match.index + match[0].length,
|
|
541
|
+
params: [match[0]]
|
|
542
|
+
});
|
|
543
|
+
return errors;
|
|
544
|
+
}
|
|
531
545
|
function extractBracketErrors(expression) {
|
|
532
546
|
const stack = [];
|
|
533
547
|
for (let pos = 0; pos < expression.length; pos++) {
|
|
@@ -679,9 +693,10 @@ function findMatchingCloseParen(expression, openPos) {
|
|
|
679
693
|
* @param options - Optional typification hint for incomplete formal expressions
|
|
680
694
|
*/
|
|
681
695
|
function extractSyntaxErrors(ast, expression, reporter, annotateErrors = false, options) {
|
|
682
|
-
const
|
|
683
|
-
if (
|
|
684
|
-
|
|
696
|
+
const textErrors = [...extractDeletedReferenceErrors(expression), ...extractForbiddenCharacterErrors(expression)];
|
|
697
|
+
if (textErrors.length > 0) {
|
|
698
|
+
textErrors.sort((left, right) => left.from - right.from);
|
|
699
|
+
for (const error of textErrors) {
|
|
685
700
|
reporter(error);
|
|
686
701
|
if (annotateErrors) annotateError(ast, error.code, error.params);
|
|
687
702
|
}
|
|
@@ -722,4 +737,4 @@ function extractInternal(node, expression, collect, hasBracketErrors, options) {
|
|
|
722
737
|
//#endregion
|
|
723
738
|
export { extractSyntaxErrors as t };
|
|
724
739
|
|
|
725
|
-
//# sourceMappingURL=syntax-errors-
|
|
740
|
+
//# sourceMappingURL=syntax-errors-WGLQNaNe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax-errors-BN_bqTaX.js","names":["TypeClassEnum"],"sources":["../src/rslang/parser/syntax-errors/context.ts","../src/rslang/parser/syntax-errors/ast-utils.ts","../src/rslang/parser/syntax-errors/function-calls.ts","../src/rslang/parser/syntax-errors/error-builders.ts","../src/rslang/parser/syntax-errors/generators.ts","../src/rslang/parser/syntax-errors/trailing-slot.ts","../src/rslang/parser/syntax-errors/incomplete-formal.ts","../src/rslang/parser/syntax-errors/incomplete-operands.ts","../src/rslang/parser/syntax-errors/classify.ts","../src/rslang/parser/syntax-errors/expression-errors.ts","../src/rslang/parser/syntax-errors/index.ts"],"sourcesContent":["/**\n * Types for the parse-error classifier pipeline.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport type { RSErrorDescription } from '../../error';\nimport type { TypeClass } from '../../semantic/typification';\n\n/** Shared state passed through parse-error classifiers. */\nexport interface ClassifyContext {\n hasBracketErrors: boolean;\n expected?: TypeClass;\n}\n\n/** Classifies a single ERROR node into a specific syntax error, if possible. */\nexport type ErrorClassifier = (\n node: AstNode,\n expression: string,\n context: ClassifyContext\n) => RSErrorDescription | null;\n\n/** Skips classifiers that conflict with bracket-level diagnostics. */\nexport function whenNoBracketErrors(classifier: ErrorClassifier): ErrorClassifier {\n return (node, expression, context) => (context.hasBracketErrors ? null : classifier(node, expression, context));\n}\n","/**\n * AST navigation helpers and node-type predicates for classifiers.\n *\n * Predicates accept grammar terms **or** {@link TokenID} because `normalizeAST` runs before\n * error extraction and leaves `hasError` subtrees unnormalized — see `parser/README.md`.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { Filter, Function, Function_decl, Logic_quantor, Predicate } from '../parser.terms';\nimport { TokenID } from '../token';\n\nexport function findAncestor(node: AstNode, predicate: (node: AstNode) => boolean): AstNode | null {\n let current: AstNode | null = node;\n while (current !== null) {\n if (predicate(current)) {\n return current;\n }\n current = current.parent;\n }\n return null;\n}\n\nexport function findRelatedNode(node: AstNode, predicate: (target: AstNode) => boolean): AstNode | null {\n let current: AstNode | null = node.parent;\n while (current !== null) {\n for (const child of current.children) {\n if (predicate(child)) {\n return child;\n }\n }\n current = current.parent;\n }\n return null;\n}\n\nexport function isDescendantOf(ancestor: AstNode, node: AstNode): boolean {\n let current: AstNode | null = node.parent;\n while (current !== null) {\n if (current === ancestor) {\n return true;\n }\n current = current.parent;\n }\n return false;\n}\n\nexport function subtreeHasError(node: AstNode): boolean {\n if (node.typeID === TokenID.ERROR) {\n return true;\n }\n return node.children.some(subtreeHasError);\n}\n\nexport function isFunctionDeclNode(node: AstNode): boolean {\n return node.typeID === Function_decl || node.typeID === TokenID.NT_FUNC_DEFINITION;\n}\n\nexport function isQuantifierNode(node: AstNode): boolean {\n return node.typeID === Logic_quantor;\n}\n\nexport function isFunctionNode(node: AstNode): boolean {\n return node.typeID === Function || node.typeID === TokenID.ID_FUNCTION;\n}\n\nexport function isPredicateNode(node: AstNode): boolean {\n return node.typeID === Predicate || node.typeID === TokenID.ID_PREDICATE;\n}\n\nexport function isFilterNode(node: AstNode): boolean {\n return node.typeID === Filter || node.typeID === TokenID.FILTER;\n}\n\nexport function findMatchingCloseBracket(expression: string, openPos: number): number {\n if (expression[openPos] !== '[') {\n return -1;\n }\n\n let depth = 0;\n for (let index = openPos; index < expression.length; index++) {\n const symbol = expression[index];\n if (symbol === '[') {\n depth++;\n } else if (symbol === ']') {\n depth--;\n if (depth === 0) {\n return index;\n }\n }\n }\n return -1;\n}\n\nexport function getErrorOperandNode(node: AstNode): AstNode | null {\n if (node.typeID === TokenID.ERROR) {\n return node;\n }\n if (node.children.length === 1) {\n return getErrorOperandNode(node.children[0]);\n }\n return null;\n}\n\nexport function isErrorPlaceholder(node: AstNode): boolean {\n if (node.typeID === TokenID.ERROR) {\n return true;\n }\n if (node.children.length === 0) {\n return false;\n }\n return node.children.every(child => isErrorPlaceholder(child));\n}\n\n/** True when a body slot is missing or is only an ERROR placeholder (not a real expression + trailing junk). */\nexport function isEmptyOrErrorOnlyBody(nodes: AstNode[]): boolean {\n if (nodes.length === 0) {\n return true;\n }\n if (nodes.length === 1) {\n return isErrorPlaceholder(nodes[0]);\n }\n return false;\n}\n","/**\n * Malformed calls: `Fi…(…)`, `F1` / `P1` without or with wrong argument brackets.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\n\nimport {\n findAncestor,\n findMatchingCloseBracket,\n findRelatedNode,\n isFilterNode,\n isFunctionNode,\n isPredicateNode\n} from './ast-utils';\nimport type { ErrorClassifier } from './context';\n\nexport const classifyFilterParenMismatch: ErrorClassifier = (node, expression) => {\n const filterNode = findAncestor(node, isFilterNode) ?? findRelatedNode(node, isFilterNode);\n if (filterNode === null || expression[filterNode.to] !== '(') {\n return null;\n }\n\n return {\n code: RSErrorCode.invalidFilterSyntax,\n from: filterNode.from,\n to: filterNode.to + 1\n };\n};\n\nexport const classifyGlobalFuncCall: ErrorClassifier = (node, expression) => {\n const funcNode =\n findAncestor(node, n => isFunctionNode(n) || isPredicateNode(n)) ??\n findRelatedNode(node, n => isFunctionNode(n) || isPredicateNode(n));\n if (funcNode === null) {\n return null;\n }\n return classifyFuncWithoutArgs(funcNode, expression);\n};\n\nfunction classifyFuncWithoutArgs(funcNode: AstNode, expression: string): RSErrorDescription | null {\n const name = expression.slice(funcNode.from, funcNode.to);\n const rest = expression.slice(funcNode.to);\n\n const withoutArgs: RSErrorDescription = {\n code: RSErrorCode.globalFuncWithoutArgs,\n from: funcNode.from,\n to: funcNode.to,\n params: [name]\n };\n\n if (/^\\s*$/.test(rest)) {\n return withoutArgs;\n }\n\n if (/^\\s*\\(/.test(rest)) {\n return {\n code: RSErrorCode.globalFuncParenCall,\n from: funcNode.from,\n to: funcNode.to,\n params: [name]\n };\n }\n\n const openBracket = /^\\s*\\[/.exec(rest);\n if (openBracket === null) {\n return null;\n }\n\n const closeIdx = findMatchingCloseBracket(rest, openBracket[0].length - 1);\n if (closeIdx >= 0 && rest.slice(openBracket[0].length, closeIdx).trim().length === 0) {\n return withoutArgs;\n }\n\n return null;\n}\n","/**\n * Small helpers for building `RSErrorDescription` values from AST nodes.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { type RSErrorCode, type RSErrorDescription } from '../../error';\n\nexport function errorAt(node: AstNode, code: RSErrorCode, params?: readonly string[]): RSErrorDescription {\n return {\n code,\n from: node.from,\n to: node.to,\n params\n };\n}\n\nexport function hasOnlyClosingSuffix(expression: string, from: number): boolean {\n const suffix = expression.slice(from).trim();\n return suffix.length === 0 || /^[\\]\\)\\}]*$/.test(suffix);\n}\n\nexport function sliceText(node: AstNode, expression: string): string {\n return expression.slice(node.from, node.to);\n}\n\nexport function isTextToken(node: AstNode, expression: string, text: string): boolean {\n return sliceText(node, expression) === text;\n}\n","/**\n * Incomplete generator bodies: declarative `D{…}`, imperative `I{…}`, recursive `R{…}`.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { Declarative, Imp_blocks, Imperative, Recursion, Setexpr } from '../parser.terms';\nimport { TokenID } from '../token';\n\nimport { findAncestor, isDescendantOf, isEmptyOrErrorOnlyBody, isErrorPlaceholder, subtreeHasError } from './ast-utils';\nimport type { ErrorClassifier } from './context';\nimport { errorAt, isTextToken } from './error-builders';\n\nexport const classifyIncompleteGenerator: ErrorClassifier = (node, expression) =>\n detectIncompleteDeclarative(node, expression) ??\n detectIncompleteImperative(node, expression) ??\n detectIncompleteRecursion(node, expression);\n\nexport function isIncompleteGeneratorBodyCode(code: RSErrorCode): boolean {\n return (\n code === RSErrorCode.expectedDeclarativeBody ||\n code === RSErrorCode.expectedImperativeBody ||\n code === RSErrorCode.expectedRecursiveBody\n );\n}\n\ninterface GeneratorBodySlot {\n nodes: AstNode[];\n headerEndIndex: number;\n}\n\nfunction detectIncompleteDeclarative(node: AstNode, expression: string): RSErrorDescription | null {\n const generatorNode = findAncestor(\n node,\n target => target.typeID === Declarative || target.typeID === TokenID.NT_DECLARATIVE_EXPR\n );\n return detectIncompleteGeneratorBody(node, expression, generatorNode, RSErrorCode.expectedDeclarativeBody, slot =>\n isIncompleteDeclarativeBody(slot.nodes)\n );\n}\n\nfunction detectIncompleteImperative(node: AstNode, expression: string): RSErrorDescription | null {\n const generatorNode = findAncestor(\n node,\n target => target.typeID === Imperative || target.typeID === TokenID.NT_IMPERATIVE_EXPR\n );\n return detectIncompleteGeneratorBody(node, expression, generatorNode, RSErrorCode.expectedImperativeBody, slot =>\n isIncompleteImperativeBody(slot, expression)\n );\n}\n\nfunction detectIncompleteRecursion(node: AstNode, expression: string): RSErrorDescription | null {\n const generatorNode = findAncestor(node, target => target.typeID === Recursion);\n return detectIncompleteGeneratorBody(node, expression, generatorNode, RSErrorCode.expectedRecursiveBody, slot =>\n isIncompleteRecursionBody(slot.nodes)\n );\n}\n\nfunction detectIncompleteGeneratorBody(\n node: AstNode,\n expression: string,\n generatorNode: AstNode | null,\n code: RSErrorCode,\n isIncomplete: (slot: GeneratorBodySlot) => boolean\n): RSErrorDescription | null {\n if (generatorNode === null || expression.slice(generatorNode.to).trim().length > 0) {\n return null;\n }\n\n const slot = getGeneratorBodySlot(generatorNode, expression);\n if (slot === null || !isIncomplete(slot) || !generatorHeaderIsValid(generatorNode, expression, slot.headerEndIndex)) {\n return null;\n }\n\n if (!isErrorInBodySlot(node, slot, generatorNode)) {\n return null;\n }\n\n return errorAt(node, code);\n}\n\nfunction getGeneratorBodySlot(generatorNode: AstNode, expression: string): GeneratorBodySlot | null {\n if (generatorNode.typeID === Declarative || generatorNode.typeID === TokenID.NT_DECLARATIVE_EXPR) {\n return getDeclarativeBodySlot(generatorNode, expression);\n }\n if (generatorNode.typeID === Imperative || generatorNode.typeID === TokenID.NT_IMPERATIVE_EXPR) {\n return getImperativeBodySlot(generatorNode, expression);\n }\n if (generatorNode.typeID === Recursion) {\n return getRecursionBodySlot(generatorNode, expression);\n }\n return null;\n}\n\nfunction getDeclarativeBodySlot(declNode: AstNode, expression: string): GeneratorBodySlot | null {\n const pipeIndex = declNode.children.findIndex(child => isTextToken(child, expression, '|'));\n if (pipeIndex >= 0) {\n return {\n nodes: contentChildren(declNode, expression, pipeIndex + 1),\n headerEndIndex: pipeIndex + 1\n };\n }\n\n const domainNode = findDeclarativeDomain(declNode, expression);\n if (domainNode === null) {\n return null;\n }\n\n const domainIndex = declNode.children.indexOf(domainNode);\n return {\n nodes: contentChildren(declNode, expression, domainIndex + 1),\n headerEndIndex: domainIndex + 1\n };\n}\n\nfunction getImperativeBodySlot(impNode: AstNode, expression: string): GeneratorBodySlot | null {\n const pipeIndex = impNode.children.findIndex(child => isTextToken(child, expression, '|'));\n if (pipeIndex >= 0) {\n return {\n nodes: contentChildren(impNode, expression, pipeIndex + 1),\n headerEndIndex: pipeIndex + 1\n };\n }\n\n const tupleNode = findImperativeTuple(impNode);\n if (tupleNode === null) {\n return null;\n }\n\n const tupleIndex = impNode.children.indexOf(tupleNode);\n return {\n nodes: contentChildren(impNode, expression, tupleIndex + 1),\n headerEndIndex: tupleIndex + 1\n };\n}\n\nfunction getRecursionBodySlot(recNode: AstNode, expression: string): GeneratorBodySlot | null {\n const initNode = findRecursionInit(recNode, expression);\n if (initNode === null) {\n return null;\n }\n\n const initIndex = recNode.children.indexOf(initNode);\n const afterInit = contentChildren(recNode, expression, initIndex + 1);\n const lastPipeIndex = findLastPipeIndex(afterInit, expression);\n if (lastPipeIndex < 0) {\n return {\n nodes: afterInit,\n headerEndIndex: initIndex + 1\n };\n }\n\n return {\n nodes: afterInit.slice(lastPipeIndex + 1),\n headerEndIndex: recNode.children.indexOf(afterInit[lastPipeIndex]) + 1\n };\n}\n\nfunction contentChildren(generatorNode: AstNode, expression: string, fromIndex: number): AstNode[] {\n return generatorNode.children.slice(fromIndex).filter(child => !isClosingBrace(child, expression));\n}\n\nfunction findDeclarativeDomain(declNode: AstNode, expression: string): AstNode | null {\n const inIndex = declNode.children.findIndex(child => isTextToken(child, expression, '∈'));\n if (inIndex < 0) {\n return null;\n }\n\n for (let index = inIndex + 1; index < declNode.children.length; index++) {\n const child = declNode.children[index];\n if (isTextToken(child, expression, '|') || isClosingBrace(child, expression)) {\n break;\n }\n if (child.typeID === Setexpr) {\n return child;\n }\n }\n\n return null;\n}\n\nfunction findImperativeTuple(impNode: AstNode): AstNode | null {\n for (const child of impNode.children) {\n if (child.typeID === Setexpr) {\n return child;\n }\n }\n return null;\n}\n\nfunction findLastPipeIndex(nodes: AstNode[], expression: string): number {\n for (let index = nodes.length - 1; index >= 0; index--) {\n if (isTextToken(nodes[index], expression, '|')) {\n return index;\n }\n }\n return -1;\n}\n\nfunction generatorHeaderIsValid(generatorNode: AstNode, expression: string, headerEndIndex: number): boolean {\n for (let index = 0; index < headerEndIndex; index++) {\n const child = generatorNode.children[index];\n if (child.typeID === TokenID.ERROR) {\n return false;\n }\n if (isStructuralGeneratorToken(child, expression)) {\n continue;\n }\n if (subtreeHasError(child)) {\n return false;\n }\n }\n return true;\n}\n\nfunction isIncompleteDeclarativeBody(nodes: AstNode[]): boolean {\n return isEmptyOrErrorOnlyBody(nodes);\n}\n\nfunction isIncompleteImperativeBody(slot: GeneratorBodySlot, expression: string): boolean {\n if (slot.nodes.length === 0) {\n return true;\n }\n if (slot.nodes.length === 1 && slot.nodes[0].typeID === Imp_blocks) {\n return isImpBlocksIncomplete(slot.nodes[0], expression);\n }\n return isEmptyOrErrorOnlyBody(slot.nodes);\n}\n\nfunction isIncompleteRecursionBody(nodes: AstNode[]): boolean {\n return isEmptyOrErrorOnlyBody(nodes);\n}\n\nfunction isImpBlocksIncomplete(blocksNode: AstNode, expression: string): boolean {\n if (blocksNode.children.length === 0) {\n return true;\n }\n\n const lastChild = blocksNode.children[blocksNode.children.length - 1];\n if (lastChild.typeID === TokenID.ERROR) {\n return true;\n }\n if (isTextToken(lastChild, expression, ';')) {\n return true;\n }\n if (lastChild.typeID === Setexpr && isErrorPlaceholder(lastChild)) {\n return true;\n }\n\n return false;\n}\n\nfunction isErrorInBodySlot(errorNode: AstNode, slot: GeneratorBodySlot, generatorNode: AstNode): boolean {\n if (slot.nodes.length === 0) {\n const bodyStart = generatorNode.children[slot.headerEndIndex]?.from ?? generatorNode.from;\n return errorNode.from >= bodyStart;\n }\n\n for (const bodyNode of slot.nodes) {\n if (errorNode === bodyNode || isDescendantOf(bodyNode, errorNode)) {\n if (isErrorPlaceholder(bodyNode)) {\n return true;\n }\n if (bodyNode.typeID === Imp_blocks && isImpBlocksTailError(bodyNode, errorNode)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction isImpBlocksTailError(blocksNode: AstNode, errorNode: AstNode): boolean {\n const lastChild = blocksNode.children[blocksNode.children.length - 1];\n return lastChild.typeID === TokenID.ERROR && (errorNode === lastChild || isDescendantOf(lastChild, errorNode));\n}\n\nfunction findRecursionInit(recursionNode: AstNode, expression: string): AstNode | null {\n const assignIndex = recursionNode.children.findIndex(child => isTextToken(child, expression, ':='));\n if (assignIndex < 0) {\n return null;\n }\n\n for (let index = assignIndex + 1; index < recursionNode.children.length; index++) {\n const child = recursionNode.children[index];\n if (child.typeID === TokenID.ERROR) {\n break;\n }\n if (isTextToken(child, expression, '|') || isClosingBrace(child, expression)) {\n continue;\n }\n return child;\n }\n\n return null;\n}\n\nfunction isClosingBrace(node: AstNode, expression: string): boolean {\n return node.typeID !== TokenID.ERROR && isTextToken(node, expression, '}');\n}\n\nfunction isStructuralGeneratorToken(node: AstNode, expression: string): boolean {\n const text = expression.slice(node.from, node.to);\n return text === '{' || text === '}' || text === '|' || text === '∈' || text === ':=' || text === ';';\n}\n","/**\n * Reusable pattern: container header is valid, body slot is empty/ERROR-only, input ends here.\n *\n * Distinguishes a missing body (`[α∈X1]⚠`) from a real body with trailing junk\n * (`[α∈X1]1=1⚠)`), which must not report `expected*Body`.\n *\n * @see incomplete-formal.ts — function declarations, quantifiers\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { type RSErrorCode, type RSErrorDescription } from '../../error';\nimport { TokenID } from '../token';\n\nimport { isEmptyOrErrorOnlyBody } from './ast-utils';\nimport { errorAt } from './error-builders';\n\nexport function detectTrailingErrorSlot(\n node: AstNode,\n expression: string,\n container: AstNode | null,\n options: {\n headerValid?: (container: AstNode) => boolean;\n /** Nodes that form the body after the header. Defaults to the trailing ERROR only. */\n bodyNodes?: (container: AstNode, errorChild: AstNode) => AstNode[];\n code: RSErrorCode | ((container: AstNode, bodyChild: AstNode) => RSErrorCode | null);\n }\n): RSErrorDescription | null {\n if (container === null) {\n return null;\n }\n\n const bodyChild = container.children[container.children.length - 1];\n if (bodyChild?.typeID !== TokenID.ERROR || node !== bodyChild) {\n return null;\n }\n\n if (expression.slice(container.to).trim().length > 0) {\n return null;\n }\n\n if (options.headerValid !== undefined && !options.headerValid(container)) {\n return null;\n }\n\n const bodyNodes = options.bodyNodes?.(container, bodyChild) ?? [bodyChild];\n if (!isEmptyOrErrorOnlyBody(bodyNodes)) {\n return null;\n }\n\n const code = typeof options.code === 'function' ? options.code(container, bodyChild) : options.code;\n if (code === null) {\n return null;\n }\n\n return errorAt(bodyChild, code);\n}\n","/**\n * Incomplete formal headers: `[α∈…]` declarations and quantifiers (`∀α∈…`).\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { TypeClass as TypeClassEnum } from '../../semantic/typification';\nimport { Arguments, Variable_pack } from '../parser.terms';\nimport { TokenID } from '../token';\n\nimport { findAncestor, isFunctionDeclNode, isQuantifierNode, subtreeHasError } from './ast-utils';\nimport type { ClassifyContext, ErrorClassifier } from './context';\nimport { isTextToken } from './error-builders';\nimport { detectTrailingErrorSlot } from './trailing-slot';\n\nexport const classifyIncompleteFormal: ErrorClassifier = (node, expression, context) =>\n detectIncompleteFunctionDecl(node, expression, context.expected) ?? detectIncompleteQuantifier(node, expression);\n\nfunction detectIncompleteFunctionDecl(\n node: AstNode,\n expression: string,\n expected?: ClassifyContext['expected']\n): RSErrorDescription | null {\n return detectTrailingErrorSlot(node, expression, findAncestor(node, isFunctionDeclNode), {\n headerValid: container => {\n const argsNode = container.children.find(\n child => child.typeID === Arguments || child.typeID === TokenID.NT_ARGUMENTS\n );\n return argsNode !== undefined && !subtreeHasError(argsNode);\n },\n bodyNodes: (container, errorChild) => functionDeclBodyNodes(container, expression, errorChild),\n code: () => incompleteFormalExpressionCode(expected)\n });\n}\n\nfunction functionDeclBodyNodes(container: AstNode, expression: string, errorChild: AstNode): AstNode[] {\n const closeIndex = container.children.findIndex(child => isTextToken(child, expression, ']'));\n if (closeIndex < 0) {\n return [errorChild];\n }\n return container.children.slice(closeIndex + 1);\n}\n\nfunction incompleteFormalExpressionCode(expected?: ClassifyContext['expected']): RSErrorCode {\n switch (expected) {\n case TypeClassEnum.function:\n return RSErrorCode.expectedExpressionBody;\n case TypeClassEnum.predicate:\n case TypeClassEnum.logic:\n return RSErrorCode.expectedLogicBody;\n default:\n return RSErrorCode.expectedFunctionBody;\n }\n}\n\nfunction detectIncompleteQuantifier(node: AstNode, expression: string): RSErrorDescription | null {\n return detectTrailingErrorSlot(node, expression, findAncestor(node, isQuantifierNode), {\n headerValid: container => {\n const varPack = container.children.find(\n child => child.typeID === Variable_pack || child.typeID === TokenID.NT_ENUM_DECL\n );\n return varPack !== undefined && !subtreeHasError(varPack);\n },\n bodyNodes: (container, errorChild) => quantifierBodyNodes(container, expression, errorChild),\n code: (container, bodyChild) => {\n const inIndex = container.children.findIndex(child => expression.slice(child.from, child.to) === '∈');\n if (inIndex < 0) {\n return RSErrorCode.expectedQuantifierDomain;\n }\n\n const domainChild = container.children[inIndex + 1];\n if (domainChild === undefined || domainChild === bodyChild || subtreeHasError(domainChild)) {\n return RSErrorCode.expectedQuantifierDomain;\n }\n\n return RSErrorCode.expectedQuantifierBody;\n }\n });\n}\n\nfunction quantifierBodyNodes(container: AstNode, expression: string, errorChild: AstNode): AstNode[] {\n const inIndex = container.children.findIndex(child => isTextToken(child, expression, '∈'));\n if (inIndex < 0) {\n return [errorChild];\n }\n // Domain is the child after ∈; body starts after the domain.\n return container.children.slice(inIndex + 2);\n}\n","/**\n * Incomplete operators and bracket argument lists (`P1[S1, ]`).\n *\n * Tuple enums `(α,β,)` intentionally stay `unknownSyntax` — not `expectedArgument`.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { Boolean, Expr_enum_min2, Logic_binary, Logic_predicates, Logic_unary, Setexpr_binary } from '../parser.terms';\nimport { TokenID } from '../token';\n\nimport {\n findAncestor,\n findMatchingCloseBracket,\n getErrorOperandNode,\n isFilterNode,\n isFunctionNode,\n isPredicateNode,\n subtreeHasError\n} from './ast-utils';\nimport type { ErrorClassifier } from './context';\nimport { errorAt, hasOnlyClosingSuffix, isTextToken, sliceText } from './error-builders';\n\nexport const classifyIncompleteOperands: ErrorClassifier = (node, expression) =>\n detectIncompleteUnaryOperand(node, expression) ??\n detectIncompleteBinaryOperand(node, expression) ??\n detectIncompleteBooleanOperand(node, expression);\n\nexport const classifyIncompleteArgument: ErrorClassifier = (node, expression) =>\n detectIncompleteArgument(node, expression);\n\nfunction detectIncompleteUnaryOperand(node: AstNode, expression: string): RSErrorDescription | null {\n const unaryNode = findAncestor(node, target => target.typeID === Logic_unary);\n if (unaryNode === null) {\n return null;\n }\n\n const operandChild = unaryNode.children[unaryNode.children.length - 1];\n if (operandChild?.typeID !== TokenID.ERROR || node !== operandChild) {\n return null;\n }\n\n if (expression.slice(unaryNode.to).trim().length > 0) {\n return null;\n }\n\n const operatorChild = unaryNode.children[0];\n if (operatorChild === undefined || operatorChild === operandChild) {\n return null;\n }\n\n if (!isTextToken(operatorChild, expression, '¬')) {\n return null;\n }\n\n return errorAt(operandChild, RSErrorCode.expectedUnaryOperand);\n}\n\nfunction detectIncompleteBinaryOperand(node: AstNode, expression: string): RSErrorDescription | null {\n const binaryNode = findAncestor(\n node,\n target => target.typeID === Logic_binary || target.typeID === Logic_predicates || target.typeID === Setexpr_binary\n );\n if (binaryNode === null) {\n return null;\n }\n\n const operandChild = binaryNode.children[binaryNode.children.length - 1];\n if (operandChild?.typeID !== TokenID.ERROR || node !== operandChild) {\n return null;\n }\n\n if (expression.slice(binaryNode.to).trim().length > 0) {\n return null;\n }\n\n if (binaryNode.children.length < 2) {\n return null;\n }\n\n const leftChild = binaryNode.children[0];\n if (leftChild.typeID === TokenID.ERROR || subtreeHasError(leftChild)) {\n return null;\n }\n\n return errorAt(operandChild, RSErrorCode.expectedRightOperand);\n}\n\nfunction detectIncompleteBooleanOperand(node: AstNode, expression: string): RSErrorDescription | null {\n const booleanNode = findAncestor(node, target => target.typeID === Boolean);\n if (booleanNode === null) {\n return null;\n }\n\n const operandChild = findTrailingErrorOperand(booleanNode, expression);\n if (operandChild === null || node !== operandChild) {\n return null;\n }\n\n if (!hasOnlyClosingSuffix(expression, booleanNode.to)) {\n return null;\n }\n\n return errorAt(operandChild, RSErrorCode.expectedRightOperand);\n}\n\nfunction detectIncompleteArgument(node: AstNode, expression: string): RSErrorDescription | null {\n const enumNode = findAncestor(node, target => target.typeID === Expr_enum_min2);\n if (enumNode === null || !isLegitimateArgumentEnum(enumNode, expression)) {\n return null;\n }\n\n const errorChild = findEnumArgumentError(enumNode, expression);\n if (errorChild === null || node !== errorChild || !hasOnlyClosingSuffix(expression, enumNode.to)) {\n return null;\n }\n\n return errorAt(errorChild, RSErrorCode.expectedArgument);\n}\n\nfunction findTrailingErrorOperand(container: AstNode, expression: string): AstNode | null {\n for (let index = container.children.length - 1; index >= 0; index--) {\n const child = container.children[index];\n if (isOperandStructuralToken(child, expression)) {\n continue;\n }\n return getErrorOperandNode(child);\n }\n return null;\n}\n\nfunction findEnumArgumentError(enumNode: AstNode, expression: string): AstNode | null {\n for (const child of enumNode.children) {\n if (isTextToken(child, expression, ',')) {\n continue;\n }\n const errorNode = getErrorOperandNode(child);\n if (errorNode !== null) {\n return errorNode;\n }\n }\n return null;\n}\n\nfunction isOperandStructuralToken(node: AstNode, expression: string): boolean {\n const text = sliceText(node, expression);\n return text === '(' || text === ')' || text === 'ℬ';\n}\n\nfunction isLegitimateArgumentEnum(enumNode: AstNode, expression: string): boolean {\n return findCallHostForBracketEnum(enumNode, expression) !== null;\n}\n\nfunction findCallHostForBracketEnum(enumNode: AstNode, expression: string): AstNode | null {\n let current: AstNode | null = enumNode.parent;\n while (current !== null) {\n for (const child of current.children) {\n if (!isFunctionNode(child) && !isPredicateNode(child) && !isFilterNode(child)) {\n continue;\n }\n if (isEnumInCallBrackets(enumNode, child, expression)) {\n return child;\n }\n }\n current = current.parent;\n }\n return null;\n}\n\nfunction isEnumInCallBrackets(enumNode: AstNode, nameNode: AstNode, expression: string): boolean {\n const rest = expression.slice(nameNode.to);\n const match = /^\\s*\\[/.exec(rest);\n if (match === null) {\n return false;\n }\n\n const openPos = nameNode.to + match.index + match[0].indexOf('[');\n const closePos = findMatchingCloseBracket(expression, openPos);\n if (closePos < 0) {\n return false;\n }\n\n return enumNode.from > openPos && enumNode.from < closePos;\n}\n","/**\n * Parse-error classification: ordered classifier chain and P8400 fallback.\n *\n * Register new detectors in `PARSE_ERROR_CLASSIFIERS` (first match wins).\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { Variable } from '../parser.terms';\n\nimport type { ClassifyContext, ErrorClassifier } from './context';\nimport { whenNoBracketErrors } from './context';\nimport { classifyFilterParenMismatch, classifyGlobalFuncCall } from './function-calls';\nimport { classifyIncompleteGenerator } from './generators';\nimport { classifyIncompleteFormal } from './incomplete-formal';\nimport { classifyIncompleteArgument, classifyIncompleteOperands } from './incomplete-operands';\n\nconst PARSE_ERROR_CLASSIFIERS: ErrorClassifier[] = [\n classifyIncompleteFormal,\n classifyIncompleteGenerator,\n whenNoBracketErrors(classifyIncompleteOperands),\n whenNoBracketErrors(classifyIncompleteArgument),\n classifyFilterParenMismatch,\n classifyGlobalFuncCall\n];\n\n/** Runs classifiers in priority order for one `ERROR` AST node. */\nexport function classifyParseError(\n node: AstNode,\n expression: string,\n context: ClassifyContext\n): RSErrorDescription | null {\n for (const classifier of PARSE_ERROR_CLASSIFIERS) {\n const error = classifier(node, expression, context);\n if (error !== null) {\n return error;\n }\n }\n return null;\n}\n\n/** Default rules when no classifier matched: `expectedLocal` or `unknownSyntax`. */\nexport function classifyFallbackError(\n node: AstNode,\n ignoreUnknownErrors: boolean\n): { error: RSErrorDescription; target: AstNode } | null {\n const parent = node.parent;\n if (parent === null) {\n return ignoreUnknownErrors\n ? null\n : { error: { code: RSErrorCode.unknownSyntax, from: node.from, to: node.to }, target: node };\n }\n\n if (parent.typeID === Variable) {\n return {\n error: { code: RSErrorCode.expectedLocal, from: parent.from, to: parent.to },\n target: parent\n };\n }\n\n if (ignoreUnknownErrors) {\n return null;\n }\n\n const target = node.from === node.to ? parent : node;\n return {\n error: { code: RSErrorCode.unknownSyntax, from: target.from, to: target.to },\n target\n };\n}\n","/**\n * Expression-level diagnostics (no AST required) and error deduplication.\n */\n\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\n\ntype OpenBracket = '(' | '[' | '{';\ntype CloseBracket = ')' | ']' | '}';\n\ninterface BracketFrame {\n bracket: OpenBracket;\n index: number;\n}\n\nconst ALLOWED_EXPRESSION_CHARS = buildAllowedExpressionChars();\n\nfunction buildAllowedExpressionChars(): Set<string> {\n const chars = new Set<string>();\n for (const chunk of [\n '0123456789',\n 'abcdefghijklmnopqrstuvwxyz',\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',\n '_',\n '∅¬∀∃⇔⇒∨&ℬ+-*∪\\\\∆∩×∈∉⊆⊄⊂<>≥≤≠=,:;|[]{}()'\n ]) {\n for (const symbol of chunk) {\n chars.add(symbol);\n }\n }\n for (let codePoint = 0x03b1; codePoint <= 0x03c9; codePoint++) {\n chars.add(String.fromCodePoint(codePoint));\n }\n return chars;\n}\n\nfunction isAllowedExpressionChar(symbol: string): boolean {\n return /\\s/u.test(symbol) || ALLOWED_EXPRESSION_CHARS.has(symbol);\n}\n\nexport function extractForbiddenCharacterErrors(expression: string): RSErrorDescription[] {\n const errors: RSErrorDescription[] = [];\n let pos = 0;\n\n while (pos < expression.length) {\n const symbol = expression[pos];\n if (isAllowedExpressionChar(symbol)) {\n pos++;\n continue;\n }\n\n const start = pos;\n while (pos < expression.length && !isAllowedExpressionChar(expression[pos])) {\n pos++;\n }\n\n errors.push({\n code: RSErrorCode.forbiddenCharacter,\n from: start,\n to: pos,\n params: [expression.slice(start, pos)]\n });\n }\n\n return errors;\n}\n\nexport function extractBracketErrors(expression: string): RSErrorDescription | null {\n const stack: BracketFrame[] = [];\n\n for (let pos = 0; pos < expression.length; pos++) {\n const symbol = expression[pos];\n if (isOpenBracket(symbol)) {\n if (isDoubleParenthesis(expression, pos)) {\n return {\n code: RSErrorCode.doubleParenthesis,\n from: pos,\n to: pos + 2\n };\n }\n stack.push({ bracket: symbol, index: pos });\n continue;\n }\n if (!isCloseBracket(symbol)) {\n continue;\n }\n\n const expectedOpen = closeToOpen(symbol);\n const top = stack[stack.length - 1];\n if (top === undefined) {\n return {\n code: RSErrorCode.missingOpenBracket,\n from: pos,\n to: pos + 1,\n params: [symbol]\n };\n }\n\n if (top.bracket !== expectedOpen) {\n return {\n code: RSErrorCode.bracketMismatch,\n from: pos,\n to: pos + 1,\n params: [openToClose(top.bracket), symbol]\n };\n }\n\n stack.pop();\n }\n\n if (stack.length > 0) {\n const unclosed = stack[0];\n return {\n code: RSErrorCode.missingCloseBracket,\n from: unclosed.index,\n to: unclosed.index + 1,\n params: [unclosed.bracket]\n };\n }\n\n return null;\n}\n\nexport function deduplicateErrors(errors: RSErrorDescription[]): RSErrorDescription[] {\n const result: RSErrorDescription[] = [];\n\n for (const error of errors) {\n const duplicate = result.some(\n existing => existing.code === error.code && existing.from === error.from && existing.to === error.to\n );\n if (duplicate) {\n continue;\n }\n\n if (error.code !== RSErrorCode.unknownSyntax) {\n for (let index = result.length - 1; index >= 0; index--) {\n if (result[index].code === RSErrorCode.unknownSyntax && rangesOverlap(error, result[index])) {\n result.splice(index, 1);\n }\n }\n }\n\n result.push(error);\n }\n\n const specific = result.filter(error => error.code !== RSErrorCode.unknownSyntax);\n const filtered = result.filter(\n error => error.code !== RSErrorCode.unknownSyntax || !specific.some(item => rangesOverlap(error, item))\n );\n return collapseContiguousUnknownSyntax(filtered);\n}\n\nfunction collapseContiguousUnknownSyntax(errors: RSErrorDescription[]): RSErrorDescription[] {\n const unknowns = errors.filter(error => error.code === RSErrorCode.unknownSyntax);\n if (unknowns.length <= 1) {\n return errors;\n }\n\n const others = errors.filter(error => error.code !== RSErrorCode.unknownSyntax);\n const sorted = [...unknowns].sort((left, right) => left.from - right.from || left.to - right.to);\n const merged: RSErrorDescription[] = [];\n\n let clusterFrom = sorted[0].from;\n let clusterTo = sorted[0].to;\n\n for (let index = 1; index < sorted.length; index++) {\n const error = sorted[index];\n if (error.from <= clusterTo) {\n clusterTo = Math.max(clusterTo, error.to);\n continue;\n }\n\n merged.push({ code: RSErrorCode.unknownSyntax, from: clusterFrom, to: clusterTo });\n clusterFrom = error.from;\n clusterTo = error.to;\n }\n\n merged.push({ code: RSErrorCode.unknownSyntax, from: clusterFrom, to: clusterTo });\n return [...others, ...merged];\n}\n\nfunction rangesOverlap(a: RSErrorDescription, b: RSErrorDescription): boolean {\n return a.from < b.to && b.from < a.to;\n}\n\nfunction isOpenBracket(symbol: string): symbol is OpenBracket {\n return symbol === '(' || symbol === '[' || symbol === '{';\n}\n\nfunction isCloseBracket(symbol: string): symbol is CloseBracket {\n return symbol === ')' || symbol === ']' || symbol === '}';\n}\n\nfunction openToClose(symbol: OpenBracket): CloseBracket {\n switch (symbol) {\n case '(':\n return ')';\n case '[':\n return ']';\n case '{':\n return '}';\n }\n}\n\nfunction closeToOpen(symbol: CloseBracket): OpenBracket {\n switch (symbol) {\n case ')':\n return '(';\n case ']':\n return '[';\n case '}':\n return '{';\n }\n}\n\nfunction isDoubleParenthesis(expression: string, pos: number): boolean {\n const isOpenDoubleParenthesis = expression[pos] === '(' && expression[pos + 1] === '(';\n if (!isOpenDoubleParenthesis) {\n return false;\n }\n\n const outerClose = findMatchingCloseParen(expression, pos);\n const innerClose = findMatchingCloseParen(expression, pos + 1);\n if (outerClose < 0 || innerClose < 0) {\n return false;\n }\n\n return outerClose === innerClose + 1;\n}\n\nfunction findMatchingCloseParen(expression: string, openPos: number): number {\n if (expression[openPos] !== '(') {\n return -1;\n }\n\n const stack: OpenBracket[] = [];\n for (let index = openPos; index < expression.length; index++) {\n const symbol = expression[index];\n if (isOpenBracket(symbol)) {\n stack.push(symbol);\n continue;\n }\n if (!isCloseBracket(symbol)) {\n continue;\n }\n const top = stack.pop();\n if (top === undefined || top !== closeToOpen(symbol)) {\n return -1;\n }\n if (stack.length === 0) {\n return index;\n }\n }\n\n return -1;\n}\n","/**\n * Syntax error extraction — public entry point.\n *\n * Expects the **hybrid** AST produced by `normalizeAST` (see `parser/README.md`).\n * See {@link ./README.md} for pipeline, classifier order, and how to add codes.\n *\n * @module rslang/parser/syntax-errors\n */\n\nimport { type AstNode, visitAstDFS } from '../../../parsing';\nimport { annotateError } from '../../ast-annotations';\nimport { type ErrorReporter, type RSErrorDescription } from '../../error';\nimport { type TypeClass } from '../../semantic/typification';\nimport { TokenID } from '../token';\n\nimport { classifyFallbackError, classifyParseError } from './classify';\nimport { deduplicateErrors, extractBracketErrors, extractForbiddenCharacterErrors } from './expression-errors';\nimport { isIncompleteGeneratorBodyCode } from './generators';\n\n/** When set, refines incomplete formal headers (`[α∈…]`, quantifiers). */\nexport interface SyntaxErrorOptions {\n expected?: TypeClass;\n}\n\n/**\n * Walks a parsed expression AST and reports syntax errors.\n *\n * @param ast - Root AST from `buildTree(parser.parse(expression))`\n * @param expression - Original source text (positions must match the AST)\n * @param reporter - Called once per deduplicated error\n * @param annotateErrors - When true, also calls `annotateError` on the triggering node\n * @param options - Optional typification hint for incomplete formal expressions\n */\nexport function extractSyntaxErrors(\n ast: AstNode,\n expression: string,\n reporter: ErrorReporter,\n annotateErrors: boolean = false,\n options?: SyntaxErrorOptions\n) {\n const forbiddenErrors = extractForbiddenCharacterErrors(expression);\n if (forbiddenErrors.length > 0) {\n for (const error of forbiddenErrors) {\n reporter(error);\n if (annotateErrors) {\n annotateError(ast, error.code, error.params);\n }\n }\n return;\n }\n\n const collected: RSErrorDescription[] = [];\n const annotationTargets = new Map<RSErrorDescription, AstNode>();\n const collect = (error: RSErrorDescription, target?: AstNode) => {\n collected.push(error);\n if (target !== undefined) {\n annotationTargets.set(error, target);\n }\n };\n\n const bracketError = extractBracketErrors(expression);\n const hasBracketErrors = bracketError !== null;\n visitAstDFS(ast, node => extractInternal(node, expression, collect, hasBracketErrors, options));\n\n const hasIncompleteGenerator = collected.some(error => isIncompleteGeneratorBodyCode(error.code));\n if (bracketError !== null && !hasIncompleteGenerator) {\n collect(bracketError, ast);\n }\n\n for (const error of deduplicateErrors(collected)) {\n reporter(error);\n if (annotateErrors) {\n const target = annotationTargets.get(error);\n if (target !== undefined) {\n annotateError(target, error.code, error.params);\n }\n }\n }\n}\n\nfunction extractInternal(\n node: AstNode,\n expression: string,\n collect: (error: RSErrorDescription, target: AstNode) => void,\n hasBracketErrors: boolean,\n options?: SyntaxErrorOptions\n) {\n if (node.typeID !== TokenID.ERROR) {\n return;\n }\n\n const classified = classifyParseError(node, expression, { hasBracketErrors, expected: options?.expected });\n if (classified !== null) {\n collect(classified, node);\n return;\n }\n\n const fallback = classifyFallbackError(node, hasBracketErrors);\n if (fallback !== null) {\n collect(fallback.error, fallback.target);\n }\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,oBAAoB,YAA8C;CAChF,QAAQ,MAAM,YAAY,YAAa,QAAQ,mBAAmB,OAAO,WAAW,MAAM,YAAY,OAAO;AAC/G;;;ACbA,SAAgB,aAAa,MAAe,WAAuD;CACjG,IAAI,UAA0B;CAC9B,OAAO,YAAY,MAAM;EACvB,IAAI,UAAU,OAAO,GACnB,OAAO;EAET,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;AAEA,SAAgB,gBAAgB,MAAe,WAAyD;CACtG,IAAI,UAA0B,KAAK;CACnC,OAAO,YAAY,MAAM;EACvB,KAAK,MAAM,SAAS,QAAQ,UAC1B,IAAI,UAAU,KAAK,GACjB,OAAO;EAGX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K;GAC1C,IAAI,WAAW,QACb,cAAc,QAAQ,MAAM,MAAM,MAAM,MAAM;EAElD;CACF;AACF;AAEA,SAAS,gBACP,MACA,YACA,SACA,kBACA,SACA;CACA,IAAI,KAAK,WAAW,QAAQ,OAC1B;CAGF,MAAM,aAAa,mBAAmB,MAAM,YAAY;EAAE;EAAkB,UAAU,SAAS;CAAS,CAAC;CACzG,IAAI,eAAe,MAAM;EACvB,QAAQ,YAAY,IAAI;EACxB;CACF;CAEA,MAAM,WAAW,sBAAsB,MAAM,gBAAgB;CAC7D,IAAI,aAAa,MACf,QAAQ,SAAS,OAAO,SAAS,MAAM;AAE3C"}
|
|
1
|
+
{"version":3,"file":"syntax-errors-WGLQNaNe.js","names":["TypeClassEnum"],"sources":["../src/rslang/parser/syntax-errors/context.ts","../src/rslang/parser/syntax-errors/ast-utils.ts","../src/rslang/parser/syntax-errors/function-calls.ts","../src/rslang/parser/syntax-errors/error-builders.ts","../src/rslang/parser/syntax-errors/generators.ts","../src/rslang/parser/syntax-errors/trailing-slot.ts","../src/rslang/parser/syntax-errors/incomplete-formal.ts","../src/rslang/parser/syntax-errors/incomplete-operands.ts","../src/rslang/parser/syntax-errors/classify.ts","../src/rslang/parser/syntax-errors/expression-errors.ts","../src/rslang/parser/syntax-errors/index.ts"],"sourcesContent":["/**\n * Types for the parse-error classifier pipeline.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport type { RSErrorDescription } from '../../error';\nimport type { TypeClass } from '../../semantic/typification';\n\n/** Shared state passed through parse-error classifiers. */\nexport interface ClassifyContext {\n hasBracketErrors: boolean;\n expected?: TypeClass;\n}\n\n/** Classifies a single ERROR node into a specific syntax error, if possible. */\nexport type ErrorClassifier = (\n node: AstNode,\n expression: string,\n context: ClassifyContext\n) => RSErrorDescription | null;\n\n/** Skips classifiers that conflict with bracket-level diagnostics. */\nexport function whenNoBracketErrors(classifier: ErrorClassifier): ErrorClassifier {\n return (node, expression, context) => (context.hasBracketErrors ? null : classifier(node, expression, context));\n}\n","/**\n * AST navigation helpers and node-type predicates for classifiers.\n *\n * Predicates accept grammar terms **or** {@link TokenID} because `normalizeAST` runs before\n * error extraction and leaves `hasError` subtrees unnormalized — see `parser/README.md`.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { Filter, Function, Function_decl, Logic_quantor, Predicate } from '../parser.terms';\nimport { TokenID } from '../token';\n\nexport function findAncestor(node: AstNode, predicate: (node: AstNode) => boolean): AstNode | null {\n let current: AstNode | null = node;\n while (current !== null) {\n if (predicate(current)) {\n return current;\n }\n current = current.parent;\n }\n return null;\n}\n\nexport function findRelatedNode(node: AstNode, predicate: (target: AstNode) => boolean): AstNode | null {\n let current: AstNode | null = node.parent;\n while (current !== null) {\n for (const child of current.children) {\n if (predicate(child)) {\n return child;\n }\n }\n current = current.parent;\n }\n return null;\n}\n\nexport function isDescendantOf(ancestor: AstNode, node: AstNode): boolean {\n let current: AstNode | null = node.parent;\n while (current !== null) {\n if (current === ancestor) {\n return true;\n }\n current = current.parent;\n }\n return false;\n}\n\nexport function subtreeHasError(node: AstNode): boolean {\n if (node.typeID === TokenID.ERROR) {\n return true;\n }\n return node.children.some(subtreeHasError);\n}\n\nexport function isFunctionDeclNode(node: AstNode): boolean {\n return node.typeID === Function_decl || node.typeID === TokenID.NT_FUNC_DEFINITION;\n}\n\nexport function isQuantifierNode(node: AstNode): boolean {\n return node.typeID === Logic_quantor;\n}\n\nexport function isFunctionNode(node: AstNode): boolean {\n return node.typeID === Function || node.typeID === TokenID.ID_FUNCTION;\n}\n\nexport function isPredicateNode(node: AstNode): boolean {\n return node.typeID === Predicate || node.typeID === TokenID.ID_PREDICATE;\n}\n\nexport function isFilterNode(node: AstNode): boolean {\n return node.typeID === Filter || node.typeID === TokenID.FILTER;\n}\n\nexport function findMatchingCloseBracket(expression: string, openPos: number): number {\n if (expression[openPos] !== '[') {\n return -1;\n }\n\n let depth = 0;\n for (let index = openPos; index < expression.length; index++) {\n const symbol = expression[index];\n if (symbol === '[') {\n depth++;\n } else if (symbol === ']') {\n depth--;\n if (depth === 0) {\n return index;\n }\n }\n }\n return -1;\n}\n\nexport function getErrorOperandNode(node: AstNode): AstNode | null {\n if (node.typeID === TokenID.ERROR) {\n return node;\n }\n if (node.children.length === 1) {\n return getErrorOperandNode(node.children[0]);\n }\n return null;\n}\n\nexport function isErrorPlaceholder(node: AstNode): boolean {\n if (node.typeID === TokenID.ERROR) {\n return true;\n }\n if (node.children.length === 0) {\n return false;\n }\n return node.children.every(child => isErrorPlaceholder(child));\n}\n\n/** True when a body slot is missing or is only an ERROR placeholder (not a real expression + trailing junk). */\nexport function isEmptyOrErrorOnlyBody(nodes: AstNode[]): boolean {\n if (nodes.length === 0) {\n return true;\n }\n if (nodes.length === 1) {\n return isErrorPlaceholder(nodes[0]);\n }\n return false;\n}\n","/**\n * Malformed calls: `Fi…(…)`, `F1` / `P1` without or with wrong argument brackets.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\n\nimport {\n findAncestor,\n findMatchingCloseBracket,\n findRelatedNode,\n isFilterNode,\n isFunctionNode,\n isPredicateNode\n} from './ast-utils';\nimport type { ErrorClassifier } from './context';\n\nexport const classifyFilterParenMismatch: ErrorClassifier = (node, expression) => {\n const filterNode = findAncestor(node, isFilterNode) ?? findRelatedNode(node, isFilterNode);\n if (filterNode === null || expression[filterNode.to] !== '(') {\n return null;\n }\n\n return {\n code: RSErrorCode.invalidFilterSyntax,\n from: filterNode.from,\n to: filterNode.to + 1\n };\n};\n\nexport const classifyGlobalFuncCall: ErrorClassifier = (node, expression) => {\n const funcNode =\n findAncestor(node, n => isFunctionNode(n) || isPredicateNode(n)) ??\n findRelatedNode(node, n => isFunctionNode(n) || isPredicateNode(n));\n if (funcNode === null) {\n return null;\n }\n return classifyFuncWithoutArgs(funcNode, expression);\n};\n\nfunction classifyFuncWithoutArgs(funcNode: AstNode, expression: string): RSErrorDescription | null {\n const name = expression.slice(funcNode.from, funcNode.to);\n const rest = expression.slice(funcNode.to);\n\n const withoutArgs: RSErrorDescription = {\n code: RSErrorCode.globalFuncWithoutArgs,\n from: funcNode.from,\n to: funcNode.to,\n params: [name]\n };\n\n if (/^\\s*$/.test(rest)) {\n return withoutArgs;\n }\n\n if (/^\\s*\\(/.test(rest)) {\n return {\n code: RSErrorCode.globalFuncParenCall,\n from: funcNode.from,\n to: funcNode.to,\n params: [name]\n };\n }\n\n const openBracket = /^\\s*\\[/.exec(rest);\n if (openBracket === null) {\n return null;\n }\n\n const closeIdx = findMatchingCloseBracket(rest, openBracket[0].length - 1);\n if (closeIdx >= 0 && rest.slice(openBracket[0].length, closeIdx).trim().length === 0) {\n return withoutArgs;\n }\n\n return null;\n}\n","/**\n * Small helpers for building `RSErrorDescription` values from AST nodes.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { type RSErrorCode, type RSErrorDescription } from '../../error';\n\nexport function errorAt(node: AstNode, code: RSErrorCode, params?: readonly string[]): RSErrorDescription {\n return {\n code,\n from: node.from,\n to: node.to,\n params\n };\n}\n\nexport function hasOnlyClosingSuffix(expression: string, from: number): boolean {\n const suffix = expression.slice(from).trim();\n return suffix.length === 0 || /^[\\]\\)\\}]*$/.test(suffix);\n}\n\nexport function sliceText(node: AstNode, expression: string): string {\n return expression.slice(node.from, node.to);\n}\n\nexport function isTextToken(node: AstNode, expression: string, text: string): boolean {\n return sliceText(node, expression) === text;\n}\n","/**\n * Incomplete generator bodies: declarative `D{…}`, imperative `I{…}`, recursive `R{…}`.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { Declarative, Imp_blocks, Imperative, Recursion, Setexpr } from '../parser.terms';\nimport { TokenID } from '../token';\n\nimport { findAncestor, isDescendantOf, isEmptyOrErrorOnlyBody, isErrorPlaceholder, subtreeHasError } from './ast-utils';\nimport type { ErrorClassifier } from './context';\nimport { errorAt, isTextToken } from './error-builders';\n\nexport const classifyIncompleteGenerator: ErrorClassifier = (node, expression) =>\n detectIncompleteDeclarative(node, expression) ??\n detectIncompleteImperative(node, expression) ??\n detectIncompleteRecursion(node, expression);\n\nexport function isIncompleteGeneratorBodyCode(code: RSErrorCode): boolean {\n return (\n code === RSErrorCode.expectedDeclarativeBody ||\n code === RSErrorCode.expectedImperativeBody ||\n code === RSErrorCode.expectedRecursiveBody\n );\n}\n\ninterface GeneratorBodySlot {\n nodes: AstNode[];\n headerEndIndex: number;\n}\n\nfunction detectIncompleteDeclarative(node: AstNode, expression: string): RSErrorDescription | null {\n const generatorNode = findAncestor(\n node,\n target => target.typeID === Declarative || target.typeID === TokenID.NT_DECLARATIVE_EXPR\n );\n return detectIncompleteGeneratorBody(node, expression, generatorNode, RSErrorCode.expectedDeclarativeBody, slot =>\n isIncompleteDeclarativeBody(slot.nodes)\n );\n}\n\nfunction detectIncompleteImperative(node: AstNode, expression: string): RSErrorDescription | null {\n const generatorNode = findAncestor(\n node,\n target => target.typeID === Imperative || target.typeID === TokenID.NT_IMPERATIVE_EXPR\n );\n return detectIncompleteGeneratorBody(node, expression, generatorNode, RSErrorCode.expectedImperativeBody, slot =>\n isIncompleteImperativeBody(slot, expression)\n );\n}\n\nfunction detectIncompleteRecursion(node: AstNode, expression: string): RSErrorDescription | null {\n const generatorNode = findAncestor(node, target => target.typeID === Recursion);\n return detectIncompleteGeneratorBody(node, expression, generatorNode, RSErrorCode.expectedRecursiveBody, slot =>\n isIncompleteRecursionBody(slot.nodes)\n );\n}\n\nfunction detectIncompleteGeneratorBody(\n node: AstNode,\n expression: string,\n generatorNode: AstNode | null,\n code: RSErrorCode,\n isIncomplete: (slot: GeneratorBodySlot) => boolean\n): RSErrorDescription | null {\n if (generatorNode === null || expression.slice(generatorNode.to).trim().length > 0) {\n return null;\n }\n\n const slot = getGeneratorBodySlot(generatorNode, expression);\n if (slot === null || !isIncomplete(slot) || !generatorHeaderIsValid(generatorNode, expression, slot.headerEndIndex)) {\n return null;\n }\n\n if (!isErrorInBodySlot(node, slot, generatorNode)) {\n return null;\n }\n\n return errorAt(node, code);\n}\n\nfunction getGeneratorBodySlot(generatorNode: AstNode, expression: string): GeneratorBodySlot | null {\n if (generatorNode.typeID === Declarative || generatorNode.typeID === TokenID.NT_DECLARATIVE_EXPR) {\n return getDeclarativeBodySlot(generatorNode, expression);\n }\n if (generatorNode.typeID === Imperative || generatorNode.typeID === TokenID.NT_IMPERATIVE_EXPR) {\n return getImperativeBodySlot(generatorNode, expression);\n }\n if (generatorNode.typeID === Recursion) {\n return getRecursionBodySlot(generatorNode, expression);\n }\n return null;\n}\n\nfunction getDeclarativeBodySlot(declNode: AstNode, expression: string): GeneratorBodySlot | null {\n const pipeIndex = declNode.children.findIndex(child => isTextToken(child, expression, '|'));\n if (pipeIndex >= 0) {\n return {\n nodes: contentChildren(declNode, expression, pipeIndex + 1),\n headerEndIndex: pipeIndex + 1\n };\n }\n\n const domainNode = findDeclarativeDomain(declNode, expression);\n if (domainNode === null) {\n return null;\n }\n\n const domainIndex = declNode.children.indexOf(domainNode);\n return {\n nodes: contentChildren(declNode, expression, domainIndex + 1),\n headerEndIndex: domainIndex + 1\n };\n}\n\nfunction getImperativeBodySlot(impNode: AstNode, expression: string): GeneratorBodySlot | null {\n const pipeIndex = impNode.children.findIndex(child => isTextToken(child, expression, '|'));\n if (pipeIndex >= 0) {\n return {\n nodes: contentChildren(impNode, expression, pipeIndex + 1),\n headerEndIndex: pipeIndex + 1\n };\n }\n\n const tupleNode = findImperativeTuple(impNode);\n if (tupleNode === null) {\n return null;\n }\n\n const tupleIndex = impNode.children.indexOf(tupleNode);\n return {\n nodes: contentChildren(impNode, expression, tupleIndex + 1),\n headerEndIndex: tupleIndex + 1\n };\n}\n\nfunction getRecursionBodySlot(recNode: AstNode, expression: string): GeneratorBodySlot | null {\n const initNode = findRecursionInit(recNode, expression);\n if (initNode === null) {\n return null;\n }\n\n const initIndex = recNode.children.indexOf(initNode);\n const afterInit = contentChildren(recNode, expression, initIndex + 1);\n const lastPipeIndex = findLastPipeIndex(afterInit, expression);\n if (lastPipeIndex < 0) {\n return {\n nodes: afterInit,\n headerEndIndex: initIndex + 1\n };\n }\n\n return {\n nodes: afterInit.slice(lastPipeIndex + 1),\n headerEndIndex: recNode.children.indexOf(afterInit[lastPipeIndex]) + 1\n };\n}\n\nfunction contentChildren(generatorNode: AstNode, expression: string, fromIndex: number): AstNode[] {\n return generatorNode.children.slice(fromIndex).filter(child => !isClosingBrace(child, expression));\n}\n\nfunction findDeclarativeDomain(declNode: AstNode, expression: string): AstNode | null {\n const inIndex = declNode.children.findIndex(child => isTextToken(child, expression, '∈'));\n if (inIndex < 0) {\n return null;\n }\n\n for (let index = inIndex + 1; index < declNode.children.length; index++) {\n const child = declNode.children[index];\n if (isTextToken(child, expression, '|') || isClosingBrace(child, expression)) {\n break;\n }\n if (child.typeID === Setexpr) {\n return child;\n }\n }\n\n return null;\n}\n\nfunction findImperativeTuple(impNode: AstNode): AstNode | null {\n for (const child of impNode.children) {\n if (child.typeID === Setexpr) {\n return child;\n }\n }\n return null;\n}\n\nfunction findLastPipeIndex(nodes: AstNode[], expression: string): number {\n for (let index = nodes.length - 1; index >= 0; index--) {\n if (isTextToken(nodes[index], expression, '|')) {\n return index;\n }\n }\n return -1;\n}\n\nfunction generatorHeaderIsValid(generatorNode: AstNode, expression: string, headerEndIndex: number): boolean {\n for (let index = 0; index < headerEndIndex; index++) {\n const child = generatorNode.children[index];\n if (child.typeID === TokenID.ERROR) {\n return false;\n }\n if (isStructuralGeneratorToken(child, expression)) {\n continue;\n }\n if (subtreeHasError(child)) {\n return false;\n }\n }\n return true;\n}\n\nfunction isIncompleteDeclarativeBody(nodes: AstNode[]): boolean {\n return isEmptyOrErrorOnlyBody(nodes);\n}\n\nfunction isIncompleteImperativeBody(slot: GeneratorBodySlot, expression: string): boolean {\n if (slot.nodes.length === 0) {\n return true;\n }\n if (slot.nodes.length === 1 && slot.nodes[0].typeID === Imp_blocks) {\n return isImpBlocksIncomplete(slot.nodes[0], expression);\n }\n return isEmptyOrErrorOnlyBody(slot.nodes);\n}\n\nfunction isIncompleteRecursionBody(nodes: AstNode[]): boolean {\n return isEmptyOrErrorOnlyBody(nodes);\n}\n\nfunction isImpBlocksIncomplete(blocksNode: AstNode, expression: string): boolean {\n if (blocksNode.children.length === 0) {\n return true;\n }\n\n const lastChild = blocksNode.children[blocksNode.children.length - 1];\n if (lastChild.typeID === TokenID.ERROR) {\n return true;\n }\n if (isTextToken(lastChild, expression, ';')) {\n return true;\n }\n if (lastChild.typeID === Setexpr && isErrorPlaceholder(lastChild)) {\n return true;\n }\n\n return false;\n}\n\nfunction isErrorInBodySlot(errorNode: AstNode, slot: GeneratorBodySlot, generatorNode: AstNode): boolean {\n if (slot.nodes.length === 0) {\n const bodyStart = generatorNode.children[slot.headerEndIndex]?.from ?? generatorNode.from;\n return errorNode.from >= bodyStart;\n }\n\n for (const bodyNode of slot.nodes) {\n if (errorNode === bodyNode || isDescendantOf(bodyNode, errorNode)) {\n if (isErrorPlaceholder(bodyNode)) {\n return true;\n }\n if (bodyNode.typeID === Imp_blocks && isImpBlocksTailError(bodyNode, errorNode)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nfunction isImpBlocksTailError(blocksNode: AstNode, errorNode: AstNode): boolean {\n const lastChild = blocksNode.children[blocksNode.children.length - 1];\n return lastChild.typeID === TokenID.ERROR && (errorNode === lastChild || isDescendantOf(lastChild, errorNode));\n}\n\nfunction findRecursionInit(recursionNode: AstNode, expression: string): AstNode | null {\n const assignIndex = recursionNode.children.findIndex(child => isTextToken(child, expression, ':='));\n if (assignIndex < 0) {\n return null;\n }\n\n for (let index = assignIndex + 1; index < recursionNode.children.length; index++) {\n const child = recursionNode.children[index];\n if (child.typeID === TokenID.ERROR) {\n break;\n }\n if (isTextToken(child, expression, '|') || isClosingBrace(child, expression)) {\n continue;\n }\n return child;\n }\n\n return null;\n}\n\nfunction isClosingBrace(node: AstNode, expression: string): boolean {\n return node.typeID !== TokenID.ERROR && isTextToken(node, expression, '}');\n}\n\nfunction isStructuralGeneratorToken(node: AstNode, expression: string): boolean {\n const text = expression.slice(node.from, node.to);\n return text === '{' || text === '}' || text === '|' || text === '∈' || text === ':=' || text === ';';\n}\n","/**\n * Reusable pattern: container header is valid, body slot is empty/ERROR-only, input ends here.\n *\n * Distinguishes a missing body (`[α∈X1]⚠`) from a real body with trailing junk\n * (`[α∈X1]1=1⚠)`), which must not report `expected*Body`.\n *\n * @see incomplete-formal.ts — function declarations, quantifiers\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { type RSErrorCode, type RSErrorDescription } from '../../error';\nimport { TokenID } from '../token';\n\nimport { isEmptyOrErrorOnlyBody } from './ast-utils';\nimport { errorAt } from './error-builders';\n\nexport function detectTrailingErrorSlot(\n node: AstNode,\n expression: string,\n container: AstNode | null,\n options: {\n headerValid?: (container: AstNode) => boolean;\n /** Nodes that form the body after the header. Defaults to the trailing ERROR only. */\n bodyNodes?: (container: AstNode, errorChild: AstNode) => AstNode[];\n code: RSErrorCode | ((container: AstNode, bodyChild: AstNode) => RSErrorCode | null);\n }\n): RSErrorDescription | null {\n if (container === null) {\n return null;\n }\n\n const bodyChild = container.children[container.children.length - 1];\n if (bodyChild?.typeID !== TokenID.ERROR || node !== bodyChild) {\n return null;\n }\n\n if (expression.slice(container.to).trim().length > 0) {\n return null;\n }\n\n if (options.headerValid !== undefined && !options.headerValid(container)) {\n return null;\n }\n\n const bodyNodes = options.bodyNodes?.(container, bodyChild) ?? [bodyChild];\n if (!isEmptyOrErrorOnlyBody(bodyNodes)) {\n return null;\n }\n\n const code = typeof options.code === 'function' ? options.code(container, bodyChild) : options.code;\n if (code === null) {\n return null;\n }\n\n return errorAt(bodyChild, code);\n}\n","/**\n * Incomplete formal headers: `[α∈…]` declarations and quantifiers (`∀α∈…`).\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { TypeClass as TypeClassEnum } from '../../semantic/typification';\nimport { Arguments, Variable_pack } from '../parser.terms';\nimport { TokenID } from '../token';\n\nimport { findAncestor, isFunctionDeclNode, isQuantifierNode, subtreeHasError } from './ast-utils';\nimport type { ClassifyContext, ErrorClassifier } from './context';\nimport { isTextToken } from './error-builders';\nimport { detectTrailingErrorSlot } from './trailing-slot';\n\nexport const classifyIncompleteFormal: ErrorClassifier = (node, expression, context) =>\n detectIncompleteFunctionDecl(node, expression, context.expected) ?? detectIncompleteQuantifier(node, expression);\n\nfunction detectIncompleteFunctionDecl(\n node: AstNode,\n expression: string,\n expected?: ClassifyContext['expected']\n): RSErrorDescription | null {\n return detectTrailingErrorSlot(node, expression, findAncestor(node, isFunctionDeclNode), {\n headerValid: container => {\n const argsNode = container.children.find(\n child => child.typeID === Arguments || child.typeID === TokenID.NT_ARGUMENTS\n );\n return argsNode !== undefined && !subtreeHasError(argsNode);\n },\n bodyNodes: (container, errorChild) => functionDeclBodyNodes(container, expression, errorChild),\n code: () => incompleteFormalExpressionCode(expected)\n });\n}\n\nfunction functionDeclBodyNodes(container: AstNode, expression: string, errorChild: AstNode): AstNode[] {\n const closeIndex = container.children.findIndex(child => isTextToken(child, expression, ']'));\n if (closeIndex < 0) {\n return [errorChild];\n }\n return container.children.slice(closeIndex + 1);\n}\n\nfunction incompleteFormalExpressionCode(expected?: ClassifyContext['expected']): RSErrorCode {\n switch (expected) {\n case TypeClassEnum.function:\n return RSErrorCode.expectedExpressionBody;\n case TypeClassEnum.predicate:\n case TypeClassEnum.logic:\n return RSErrorCode.expectedLogicBody;\n default:\n return RSErrorCode.expectedFunctionBody;\n }\n}\n\nfunction detectIncompleteQuantifier(node: AstNode, expression: string): RSErrorDescription | null {\n return detectTrailingErrorSlot(node, expression, findAncestor(node, isQuantifierNode), {\n headerValid: container => {\n const varPack = container.children.find(\n child => child.typeID === Variable_pack || child.typeID === TokenID.NT_ENUM_DECL\n );\n return varPack !== undefined && !subtreeHasError(varPack);\n },\n bodyNodes: (container, errorChild) => quantifierBodyNodes(container, expression, errorChild),\n code: (container, bodyChild) => {\n const inIndex = container.children.findIndex(child => expression.slice(child.from, child.to) === '∈');\n if (inIndex < 0) {\n return RSErrorCode.expectedQuantifierDomain;\n }\n\n const domainChild = container.children[inIndex + 1];\n if (domainChild === undefined || domainChild === bodyChild || subtreeHasError(domainChild)) {\n return RSErrorCode.expectedQuantifierDomain;\n }\n\n return RSErrorCode.expectedQuantifierBody;\n }\n });\n}\n\nfunction quantifierBodyNodes(container: AstNode, expression: string, errorChild: AstNode): AstNode[] {\n const inIndex = container.children.findIndex(child => isTextToken(child, expression, '∈'));\n if (inIndex < 0) {\n return [errorChild];\n }\n // Domain is the child after ∈; body starts after the domain.\n return container.children.slice(inIndex + 2);\n}\n","/**\n * Incomplete operators and bracket argument lists (`P1[S1, ]`).\n *\n * Tuple enums `(α,β,)` intentionally stay `unknownSyntax` — not `expectedArgument`.\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { Boolean, Expr_enum_min2, Logic_binary, Logic_predicates, Logic_unary, Setexpr_binary } from '../parser.terms';\nimport { TokenID } from '../token';\n\nimport {\n findAncestor,\n findMatchingCloseBracket,\n getErrorOperandNode,\n isFilterNode,\n isFunctionNode,\n isPredicateNode,\n subtreeHasError\n} from './ast-utils';\nimport type { ErrorClassifier } from './context';\nimport { errorAt, hasOnlyClosingSuffix, isTextToken, sliceText } from './error-builders';\n\nexport const classifyIncompleteOperands: ErrorClassifier = (node, expression) =>\n detectIncompleteUnaryOperand(node, expression) ??\n detectIncompleteBinaryOperand(node, expression) ??\n detectIncompleteBooleanOperand(node, expression);\n\nexport const classifyIncompleteArgument: ErrorClassifier = (node, expression) =>\n detectIncompleteArgument(node, expression);\n\nfunction detectIncompleteUnaryOperand(node: AstNode, expression: string): RSErrorDescription | null {\n const unaryNode = findAncestor(node, target => target.typeID === Logic_unary);\n if (unaryNode === null) {\n return null;\n }\n\n const operandChild = unaryNode.children[unaryNode.children.length - 1];\n if (operandChild?.typeID !== TokenID.ERROR || node !== operandChild) {\n return null;\n }\n\n if (expression.slice(unaryNode.to).trim().length > 0) {\n return null;\n }\n\n const operatorChild = unaryNode.children[0];\n if (operatorChild === undefined || operatorChild === operandChild) {\n return null;\n }\n\n if (!isTextToken(operatorChild, expression, '¬')) {\n return null;\n }\n\n return errorAt(operandChild, RSErrorCode.expectedUnaryOperand);\n}\n\nfunction detectIncompleteBinaryOperand(node: AstNode, expression: string): RSErrorDescription | null {\n const binaryNode = findAncestor(\n node,\n target => target.typeID === Logic_binary || target.typeID === Logic_predicates || target.typeID === Setexpr_binary\n );\n if (binaryNode === null) {\n return null;\n }\n\n const operandChild = binaryNode.children[binaryNode.children.length - 1];\n if (operandChild?.typeID !== TokenID.ERROR || node !== operandChild) {\n return null;\n }\n\n if (expression.slice(binaryNode.to).trim().length > 0) {\n return null;\n }\n\n if (binaryNode.children.length < 2) {\n return null;\n }\n\n const leftChild = binaryNode.children[0];\n if (leftChild.typeID === TokenID.ERROR || subtreeHasError(leftChild)) {\n return null;\n }\n\n return errorAt(operandChild, RSErrorCode.expectedRightOperand);\n}\n\nfunction detectIncompleteBooleanOperand(node: AstNode, expression: string): RSErrorDescription | null {\n const booleanNode = findAncestor(node, target => target.typeID === Boolean);\n if (booleanNode === null) {\n return null;\n }\n\n const operandChild = findTrailingErrorOperand(booleanNode, expression);\n if (operandChild === null || node !== operandChild) {\n return null;\n }\n\n if (!hasOnlyClosingSuffix(expression, booleanNode.to)) {\n return null;\n }\n\n return errorAt(operandChild, RSErrorCode.expectedRightOperand);\n}\n\nfunction detectIncompleteArgument(node: AstNode, expression: string): RSErrorDescription | null {\n const enumNode = findAncestor(node, target => target.typeID === Expr_enum_min2);\n if (enumNode === null || !isLegitimateArgumentEnum(enumNode, expression)) {\n return null;\n }\n\n const errorChild = findEnumArgumentError(enumNode, expression);\n if (errorChild === null || node !== errorChild || !hasOnlyClosingSuffix(expression, enumNode.to)) {\n return null;\n }\n\n return errorAt(errorChild, RSErrorCode.expectedArgument);\n}\n\nfunction findTrailingErrorOperand(container: AstNode, expression: string): AstNode | null {\n for (let index = container.children.length - 1; index >= 0; index--) {\n const child = container.children[index];\n if (isOperandStructuralToken(child, expression)) {\n continue;\n }\n return getErrorOperandNode(child);\n }\n return null;\n}\n\nfunction findEnumArgumentError(enumNode: AstNode, expression: string): AstNode | null {\n for (const child of enumNode.children) {\n if (isTextToken(child, expression, ',')) {\n continue;\n }\n const errorNode = getErrorOperandNode(child);\n if (errorNode !== null) {\n return errorNode;\n }\n }\n return null;\n}\n\nfunction isOperandStructuralToken(node: AstNode, expression: string): boolean {\n const text = sliceText(node, expression);\n return text === '(' || text === ')' || text === 'ℬ';\n}\n\nfunction isLegitimateArgumentEnum(enumNode: AstNode, expression: string): boolean {\n return findCallHostForBracketEnum(enumNode, expression) !== null;\n}\n\nfunction findCallHostForBracketEnum(enumNode: AstNode, expression: string): AstNode | null {\n let current: AstNode | null = enumNode.parent;\n while (current !== null) {\n for (const child of current.children) {\n if (!isFunctionNode(child) && !isPredicateNode(child) && !isFilterNode(child)) {\n continue;\n }\n if (isEnumInCallBrackets(enumNode, child, expression)) {\n return child;\n }\n }\n current = current.parent;\n }\n return null;\n}\n\nfunction isEnumInCallBrackets(enumNode: AstNode, nameNode: AstNode, expression: string): boolean {\n const rest = expression.slice(nameNode.to);\n const match = /^\\s*\\[/.exec(rest);\n if (match === null) {\n return false;\n }\n\n const openPos = nameNode.to + match.index + match[0].indexOf('[');\n const closePos = findMatchingCloseBracket(expression, openPos);\n if (closePos < 0) {\n return false;\n }\n\n return enumNode.from > openPos && enumNode.from < closePos;\n}\n","/**\n * Parse-error classification: ordered classifier chain and P8400 fallback.\n *\n * Register new detectors in `PARSE_ERROR_CLASSIFIERS` (first match wins).\n */\n\nimport type { AstNode } from '../../../parsing';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\nimport { Variable } from '../parser.terms';\n\nimport type { ClassifyContext, ErrorClassifier } from './context';\nimport { whenNoBracketErrors } from './context';\nimport { classifyFilterParenMismatch, classifyGlobalFuncCall } from './function-calls';\nimport { classifyIncompleteGenerator } from './generators';\nimport { classifyIncompleteFormal } from './incomplete-formal';\nimport { classifyIncompleteArgument, classifyIncompleteOperands } from './incomplete-operands';\n\nconst PARSE_ERROR_CLASSIFIERS: ErrorClassifier[] = [\n classifyIncompleteFormal,\n classifyIncompleteGenerator,\n whenNoBracketErrors(classifyIncompleteOperands),\n whenNoBracketErrors(classifyIncompleteArgument),\n classifyFilterParenMismatch,\n classifyGlobalFuncCall\n];\n\n/** Runs classifiers in priority order for one `ERROR` AST node. */\nexport function classifyParseError(\n node: AstNode,\n expression: string,\n context: ClassifyContext\n): RSErrorDescription | null {\n for (const classifier of PARSE_ERROR_CLASSIFIERS) {\n const error = classifier(node, expression, context);\n if (error !== null) {\n return error;\n }\n }\n return null;\n}\n\n/** Default rules when no classifier matched: `expectedLocal` or `unknownSyntax`. */\nexport function classifyFallbackError(\n node: AstNode,\n ignoreUnknownErrors: boolean\n): { error: RSErrorDescription; target: AstNode } | null {\n const parent = node.parent;\n if (parent === null) {\n return ignoreUnknownErrors\n ? null\n : { error: { code: RSErrorCode.unknownSyntax, from: node.from, to: node.to }, target: node };\n }\n\n if (parent.typeID === Variable) {\n return {\n error: { code: RSErrorCode.expectedLocal, from: parent.from, to: parent.to },\n target: parent\n };\n }\n\n if (ignoreUnknownErrors) {\n return null;\n }\n\n const target = node.from === node.to ? parent : node;\n return {\n error: { code: RSErrorCode.unknownSyntax, from: target.from, to: target.to },\n target\n };\n}\n","/**\n * Expression-level diagnostics (no AST required) and error deduplication.\n */\n\nimport { DELETED_ALIAS } from '../../api';\nimport { RSErrorCode, type RSErrorDescription } from '../../error';\n\ntype OpenBracket = '(' | '[' | '{';\ntype CloseBracket = ')' | ']' | '}';\n\ninterface BracketFrame {\n bracket: OpenBracket;\n index: number;\n}\n\nconst ALLOWED_EXPRESSION_CHARS = buildAllowedExpressionChars();\n\nfunction buildAllowedExpressionChars(): Set<string> {\n const chars = new Set<string>();\n for (const chunk of [\n '0123456789',\n 'abcdefghijklmnopqrstuvwxyz',\n 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',\n '_',\n '∅¬∀∃⇔⇒∨&ℬ+-*∪\\\\∆∩×∈∉⊆⊄⊂<>≥≤≠=,:;|[]{}()'\n ]) {\n for (const symbol of chunk) {\n chars.add(symbol);\n }\n }\n for (let codePoint = 0x03b1; codePoint <= 0x03c9; codePoint++) {\n chars.add(String.fromCodePoint(codePoint));\n }\n return chars;\n}\n\nfunction isAllowedExpressionChar(symbol: string): boolean {\n return /\\s/u.test(symbol) || ALLOWED_EXPRESSION_CHARS.has(symbol);\n}\n\nexport function extractForbiddenCharacterErrors(expression: string): RSErrorDescription[] {\n const errors: RSErrorDescription[] = [];\n let pos = 0;\n\n while (pos < expression.length) {\n const symbol = expression[pos];\n if (isAllowedExpressionChar(symbol)) {\n pos++;\n continue;\n }\n\n const start = pos;\n while (pos < expression.length && !isAllowedExpressionChar(expression[pos])) {\n pos++;\n }\n\n errors.push({\n code: RSErrorCode.forbiddenCharacter,\n from: start,\n to: pos,\n params: [expression.slice(start, pos)]\n });\n }\n\n return errors;\n}\n\n/** Matches {@link DELETED_ALIAS} as a standalone identifier (not a part of a longer name). */\nconst DELETED_ALIAS_REGEXP = new RegExp(`(?<![\\\\p{L}\\\\p{N}_])${DELETED_ALIAS}(?![\\\\p{L}\\\\p{N}_])`, 'gu');\n\n/** Reports every reference to a deleted constituent ({@link DELETED_ALIAS}) in the expression. */\nexport function extractDeletedReferenceErrors(expression: string): RSErrorDescription[] {\n const errors: RSErrorDescription[] = [];\n for (const match of expression.matchAll(DELETED_ALIAS_REGEXP)) {\n errors.push({\n code: RSErrorCode.globalDeleted,\n from: match.index,\n to: match.index + match[0].length,\n params: [match[0]]\n });\n }\n return errors;\n}\n\nexport function extractBracketErrors(expression: string): RSErrorDescription | null {\n const stack: BracketFrame[] = [];\n\n for (let pos = 0; pos < expression.length; pos++) {\n const symbol = expression[pos];\n if (isOpenBracket(symbol)) {\n if (isDoubleParenthesis(expression, pos)) {\n return {\n code: RSErrorCode.doubleParenthesis,\n from: pos,\n to: pos + 2\n };\n }\n stack.push({ bracket: symbol, index: pos });\n continue;\n }\n if (!isCloseBracket(symbol)) {\n continue;\n }\n\n const expectedOpen = closeToOpen(symbol);\n const top = stack[stack.length - 1];\n if (top === undefined) {\n return {\n code: RSErrorCode.missingOpenBracket,\n from: pos,\n to: pos + 1,\n params: [symbol]\n };\n }\n\n if (top.bracket !== expectedOpen) {\n return {\n code: RSErrorCode.bracketMismatch,\n from: pos,\n to: pos + 1,\n params: [openToClose(top.bracket), symbol]\n };\n }\n\n stack.pop();\n }\n\n if (stack.length > 0) {\n const unclosed = stack[0];\n return {\n code: RSErrorCode.missingCloseBracket,\n from: unclosed.index,\n to: unclosed.index + 1,\n params: [unclosed.bracket]\n };\n }\n\n return null;\n}\n\nexport function deduplicateErrors(errors: RSErrorDescription[]): RSErrorDescription[] {\n const result: RSErrorDescription[] = [];\n\n for (const error of errors) {\n const duplicate = result.some(\n existing => existing.code === error.code && existing.from === error.from && existing.to === error.to\n );\n if (duplicate) {\n continue;\n }\n\n if (error.code !== RSErrorCode.unknownSyntax) {\n for (let index = result.length - 1; index >= 0; index--) {\n if (result[index].code === RSErrorCode.unknownSyntax && rangesOverlap(error, result[index])) {\n result.splice(index, 1);\n }\n }\n }\n\n result.push(error);\n }\n\n const specific = result.filter(error => error.code !== RSErrorCode.unknownSyntax);\n const filtered = result.filter(\n error => error.code !== RSErrorCode.unknownSyntax || !specific.some(item => rangesOverlap(error, item))\n );\n return collapseContiguousUnknownSyntax(filtered);\n}\n\nfunction collapseContiguousUnknownSyntax(errors: RSErrorDescription[]): RSErrorDescription[] {\n const unknowns = errors.filter(error => error.code === RSErrorCode.unknownSyntax);\n if (unknowns.length <= 1) {\n return errors;\n }\n\n const others = errors.filter(error => error.code !== RSErrorCode.unknownSyntax);\n const sorted = [...unknowns].sort((left, right) => left.from - right.from || left.to - right.to);\n const merged: RSErrorDescription[] = [];\n\n let clusterFrom = sorted[0].from;\n let clusterTo = sorted[0].to;\n\n for (let index = 1; index < sorted.length; index++) {\n const error = sorted[index];\n if (error.from <= clusterTo) {\n clusterTo = Math.max(clusterTo, error.to);\n continue;\n }\n\n merged.push({ code: RSErrorCode.unknownSyntax, from: clusterFrom, to: clusterTo });\n clusterFrom = error.from;\n clusterTo = error.to;\n }\n\n merged.push({ code: RSErrorCode.unknownSyntax, from: clusterFrom, to: clusterTo });\n return [...others, ...merged];\n}\n\nfunction rangesOverlap(a: RSErrorDescription, b: RSErrorDescription): boolean {\n return a.from < b.to && b.from < a.to;\n}\n\nfunction isOpenBracket(symbol: string): symbol is OpenBracket {\n return symbol === '(' || symbol === '[' || symbol === '{';\n}\n\nfunction isCloseBracket(symbol: string): symbol is CloseBracket {\n return symbol === ')' || symbol === ']' || symbol === '}';\n}\n\nfunction openToClose(symbol: OpenBracket): CloseBracket {\n switch (symbol) {\n case '(':\n return ')';\n case '[':\n return ']';\n case '{':\n return '}';\n }\n}\n\nfunction closeToOpen(symbol: CloseBracket): OpenBracket {\n switch (symbol) {\n case ')':\n return '(';\n case ']':\n return '[';\n case '}':\n return '{';\n }\n}\n\nfunction isDoubleParenthesis(expression: string, pos: number): boolean {\n const isOpenDoubleParenthesis = expression[pos] === '(' && expression[pos + 1] === '(';\n if (!isOpenDoubleParenthesis) {\n return false;\n }\n\n const outerClose = findMatchingCloseParen(expression, pos);\n const innerClose = findMatchingCloseParen(expression, pos + 1);\n if (outerClose < 0 || innerClose < 0) {\n return false;\n }\n\n return outerClose === innerClose + 1;\n}\n\nfunction findMatchingCloseParen(expression: string, openPos: number): number {\n if (expression[openPos] !== '(') {\n return -1;\n }\n\n const stack: OpenBracket[] = [];\n for (let index = openPos; index < expression.length; index++) {\n const symbol = expression[index];\n if (isOpenBracket(symbol)) {\n stack.push(symbol);\n continue;\n }\n if (!isCloseBracket(symbol)) {\n continue;\n }\n const top = stack.pop();\n if (top === undefined || top !== closeToOpen(symbol)) {\n return -1;\n }\n if (stack.length === 0) {\n return index;\n }\n }\n\n return -1;\n}\n","/**\n * Syntax error extraction — public entry point.\n *\n * Expects the **hybrid** AST produced by `normalizeAST` (see `parser/README.md`).\n * See {@link ./README.md} for pipeline, classifier order, and how to add codes.\n *\n * @module rslang/parser/syntax-errors\n */\n\nimport { type AstNode, visitAstDFS } from '../../../parsing';\nimport { annotateError } from '../../ast-annotations';\nimport { type ErrorReporter, type RSErrorDescription } from '../../error';\nimport { type TypeClass } from '../../semantic/typification';\nimport { TokenID } from '../token';\n\nimport { classifyFallbackError, classifyParseError } from './classify';\nimport {\n deduplicateErrors,\n extractBracketErrors,\n extractDeletedReferenceErrors,\n extractForbiddenCharacterErrors\n} from './expression-errors';\nimport { isIncompleteGeneratorBodyCode } from './generators';\n\n/** When set, refines incomplete formal headers (`[α∈…]`, quantifiers). */\nexport interface SyntaxErrorOptions {\n expected?: TypeClass;\n}\n\n/**\n * Walks a parsed expression AST and reports syntax errors.\n *\n * @param ast - Root AST from `buildTree(parser.parse(expression))`\n * @param expression - Original source text (positions must match the AST)\n * @param reporter - Called once per deduplicated error\n * @param annotateErrors - When true, also calls `annotateError` on the triggering node\n * @param options - Optional typification hint for incomplete formal expressions\n */\nexport function extractSyntaxErrors(\n ast: AstNode,\n expression: string,\n reporter: ErrorReporter,\n annotateErrors: boolean = false,\n options?: SyntaxErrorOptions\n) {\n // Deleted references and forbidden characters make the AST meaningless: report only them.\n const textErrors = [...extractDeletedReferenceErrors(expression), ...extractForbiddenCharacterErrors(expression)];\n if (textErrors.length > 0) {\n textErrors.sort((left, right) => left.from - right.from);\n for (const error of textErrors) {\n reporter(error);\n if (annotateErrors) {\n annotateError(ast, error.code, error.params);\n }\n }\n return;\n }\n\n const collected: RSErrorDescription[] = [];\n const annotationTargets = new Map<RSErrorDescription, AstNode>();\n const collect = (error: RSErrorDescription, target?: AstNode) => {\n collected.push(error);\n if (target !== undefined) {\n annotationTargets.set(error, target);\n }\n };\n\n const bracketError = extractBracketErrors(expression);\n const hasBracketErrors = bracketError !== null;\n visitAstDFS(ast, node => extractInternal(node, expression, collect, hasBracketErrors, options));\n\n const hasIncompleteGenerator = collected.some(error => isIncompleteGeneratorBodyCode(error.code));\n if (bracketError !== null && !hasIncompleteGenerator) {\n collect(bracketError, ast);\n }\n\n for (const error of deduplicateErrors(collected)) {\n reporter(error);\n if (annotateErrors) {\n const target = annotationTargets.get(error);\n if (target !== undefined) {\n annotateError(target, error.code, error.params);\n }\n }\n }\n}\n\nfunction extractInternal(\n node: AstNode,\n expression: string,\n collect: (error: RSErrorDescription, target: AstNode) => void,\n hasBracketErrors: boolean,\n options?: SyntaxErrorOptions\n) {\n if (node.typeID !== TokenID.ERROR) {\n return;\n }\n\n const classified = classifyParseError(node, expression, { hasBracketErrors, expected: options?.expected });\n if (classified !== null) {\n collect(classified, node);\n return;\n }\n\n const fallback = classifyFallbackError(node, hasBracketErrors);\n if (fallback !== null) {\n collect(fallback.error, fallback.target);\n }\n}\n"],"mappings":";;;;;;;;;;AAsBA,SAAgB,oBAAoB,YAA8C;CAChF,QAAQ,MAAM,YAAY,YAAa,QAAQ,mBAAmB,OAAO,WAAW,MAAM,YAAY,OAAO;AAC/G;;;ACbA,SAAgB,aAAa,MAAe,WAAuD;CACjG,IAAI,UAA0B;CAC9B,OAAO,YAAY,MAAM;EACvB,IAAI,UAAU,OAAO,GACnB,OAAO;EAET,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;AAEA,SAAgB,gBAAgB,MAAe,WAAyD;CACtG,IAAI,UAA0B,KAAK;CACnC,OAAO,YAAY,MAAM;EACvB,KAAK,MAAM,SAAS,QAAQ,UAC1B,IAAI,UAAU,KAAK,GACjB,OAAO;EAGX,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;AAEA,SAAgB,eAAe,UAAmB,MAAwB;CACxE,IAAI,UAA0B,KAAK;CACnC,OAAO,YAAY,MAAM;EACvB,IAAI,YAAY,UACd,O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AAO,CAAC;CAE9F,MAAM,yBAAyB,UAAU,MAAK,UAAS,8BAA8B,MAAM,IAAI,CAAC;CAChG,IAAI,iBAAiB,QAAQ,CAAC,wBAC5B,QAAQ,cAAc,GAAG;CAG3B,KAAK,MAAM,SAAS,kBAAkB,SAAS,GAAG;EAChD,SAAS,KAAK;EACd,IAAI,gBAAgB;GAClB,MAAM,SAAS,kBAAkB,IAAI,KAAK;GAC1C,IAAI,WAAW,QACb,cAAc,QAAQ,MAAM,MAAM,MAAM,MAAM;EAElD;CACF;AACF;AAEA,SAAS,gBACP,MACA,YACA,SACA,kBACA,SACA;CACA,IAAI,KAAK,WAAW,QAAQ,OAC1B;CAGF,MAAM,aAAa,mBAAmB,MAAM,YAAY;EAAE;EAAkB,UAAU,SAAS;CAAS,CAAC;CACzG,IAAI,eAAe,MAAM;EACvB,QAAQ,YAAY,IAAI;EACxB;CACF;CAEA,MAAM,WAAW,sBAAsB,MAAM,gBAAgB;CAC7D,IAAI,aAAa,MACf,QAAQ,SAAS,OAAO,SAAS,MAAM;AAE3C"}
|
|
@@ -190,7 +190,8 @@ function printValue(data) {
|
|
|
190
190
|
/** Generates stub ID for value. */
|
|
191
191
|
function valueStub(value) {
|
|
192
192
|
if (value == null) return "";
|
|
193
|
-
|
|
193
|
+
const str = printValue(value);
|
|
194
|
+
return generateStub(str);
|
|
194
195
|
}
|
|
195
196
|
/** Checks if value is a set representation, not a tuple representation. */
|
|
196
197
|
function isSetValue(data) {
|
|
@@ -374,4 +375,4 @@ function set(elements) {
|
|
|
374
375
|
//#endregion
|
|
375
376
|
export { setUnion as A, printValue as C, setIntersection as D, setDiff as E, validateValue as M, valueStub as N, setNestedValue as O, normalizeValue as S, reduce as T, extractValue as _, SET_INFINITY as a, isTupleValue as b, VALUE_TRUE as c, set as d, tuple as f, convertPathToType as g, contains as h, INVALID_ELEMENT as i, testInvalid as j, setSymDiff as k, compare as l, cartesianProduct as m, CalcInvalidDataError as n, TUPLE_ID as o, boolean as p, EmptySetV as r, VALUE_FALSE as s, BOOL_INFINITY as t, makeValuePath as u, isSetValue as v, projection as w, makeDefaultValue as x, isSubsetOrEq as y };
|
|
376
377
|
|
|
377
|
-
//# sourceMappingURL=value-
|
|
378
|
+
//# sourceMappingURL=value-BDISzQqI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value-COprb2Je.js","names":[],"sources":["../src/rslang/eval/value-api.ts","../src/rslang/eval/value.ts"],"sourcesContent":["import { generateStub } from '../../shared';\nimport { type ExpressionType, TypeID, type TypePath, type Typification } from '../semantic/typification';\n\nimport {\n BOOL_INFINITY,\n compare,\n EmptySetV,\n INVALID_ELEMENT,\n makeValuePath,\n set,\n SET_INFINITY,\n tuple,\n TUPLE_ID,\n type Value,\n VALUE_FALSE,\n VALUE_TRUE,\n type ValueContext,\n type ValuePath\n} from './value';\n\n/** Cartesian product of factor sets. */\nexport function cartesianProduct(factors: Value[][]): Value[] | null {\n const cardinality = factors.reduce((acc, f) => acc * f.length, 1);\n if (cardinality > SET_INFINITY) {\n return null;\n }\n if (cardinality === 0 || factors.length === 0) {\n return EmptySetV;\n }\n\n let accumulator: Value[][] = [[]];\n for (const factor of factors) {\n const next: Value[][] = [];\n for (const prefix of accumulator) {\n for (const value of factor) {\n next.push([...prefix, value]);\n }\n }\n accumulator = next;\n }\n return accumulator.map(tuple);\n}\n\n/** Boolean power set ℬ(X). No cache - materialized. */\nexport function boolean(base: Value[]): Value[] | null {\n if (base.length > BOOL_INFINITY) {\n return null;\n }\n return powerset(base);\n}\n\n/** Powerset of array. */\nfunction powerset(arr: readonly Value[]): Value[][] {\n const result: Value[][] = [[]];\n if (arr.length === 0) {\n return result;\n }\n\n let current: Value[][] = [[]];\n let maxIndex: number[] = [-1];\n while (current.length > 0) {\n const next: Value[][] = [];\n const nextMaxIndex: number[] = [];\n for (let i = 0; i < current.length; i++) {\n for (let j = maxIndex[i] + 1; j < arr.length; j++) {\n const subset = [...current[i], arr[j]];\n result.push(subset);\n if (j < arr.length - 1) {\n next.push(subset);\n nextMaxIndex.push(j);\n }\n }\n }\n current = next;\n maxIndex = nextMaxIndex;\n }\n return result;\n}\n\n/** Check if set contains element. */\nexport function contains(setData: Value[], element: Value): boolean {\n let left = 0;\n let right = setData.length - 1;\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n const cmp = compare(setData[mid], element);\n if (cmp === 0) {\n return true;\n } else if (cmp < 0) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n return false;\n}\n\n/** Is A ⊆ B. */\nexport function isSubsetOrEq(a: Value[], b: Value[]): boolean {\n let i = 0,\n j = 0;\n while (i < a.length && j < b.length) {\n const cmp = compare(a[i], b[j]);\n if (cmp === 0) {\n i++;\n j++;\n } else if (cmp > 0) {\n j++;\n } else {\n return false;\n }\n }\n return i === a.length;\n}\n\n/** Reduce: flatten double boolean to single boolean. */\nexport function reduce(target: Value[][]): Value[] {\n const result: Value[] = [];\n for (const element of target) {\n result.push(...element);\n }\n return set(result);\n}\n\n/** Union A ∪ B. */\nexport function setUnion(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n let i = 0,\n j = 0;\n while (i < set1.length && j < set2.length) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n result.push(set1[i]);\n i++;\n } else if (cmp > 0) {\n result.push(set2[j]);\n j++;\n } else {\n result.push(set1[i]);\n i++;\n j++;\n }\n }\n while (i < set1.length) {\n result.push(set1[i]);\n i++;\n }\n while (j < set2.length) {\n result.push(set2[j]);\n j++;\n }\n return result;\n}\n\n/** Intersection A ∩ B. */\nexport function setIntersection(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n for (let i = 0, j = 0; i < set1.length && j < set2.length; ) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n i++;\n } else if (cmp > 0) {\n j++;\n } else {\n result.push(set1[i]);\n i++;\n j++;\n }\n }\n return result;\n}\n\n/** Difference A \\ B. */\nexport function setDiff(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n let i = 0,\n j = 0;\n while (i < set1.length && j < set2.length) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n result.push(set1[i]);\n i++;\n } else if (cmp > 0) {\n j++;\n } else {\n i++;\n j++;\n }\n }\n while (i < set1.length) {\n result.push(set1[i]);\n i++;\n }\n return result;\n}\n\n/** Symmetric difference A ∆ B. */\nexport function setSymDiff(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n let i = 0,\n j = 0;\n while (i < set1.length && j < set2.length) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n result.push(set1[i]);\n i++;\n } else if (cmp > 0) {\n result.push(set2[j]);\n j++;\n } else {\n i++;\n j++;\n }\n }\n while (i < set1.length) {\n result.push(set1[i]);\n i++;\n }\n while (j < set2.length) {\n result.push(set2[j]);\n j++;\n }\n return result;\n}\n\n/** Projection of set by indices (BigPr). */\nexport function projection(target: Value[][], indices: number[]): Value[] {\n const projectedElements: Value[] = target.map(element => {\n const newComponents = indices.map(idx => element[idx]);\n return indices.length === 1 ? newComponents[0] : tuple(newComponents);\n });\n return set(projectedElements);\n}\n\n/** Condensed string representation. */\nexport function printValue(data: Value | null): string {\n if (!Array.isArray(data)) {\n return String(data);\n }\n const len = data.length;\n if (data.length === 0) {\n return '{}';\n }\n\n const isTuple = data[0] === TUPLE_ID;\n const start = isTuple ? 1 : 0;\n\n let result = isTuple ? '(' : '{';\n for (let i = start; i < len; i++) {\n if (i > start) result += ', ';\n result += printValue(data[i]);\n }\n result += isTuple ? ')' : '}';\n return result;\n}\n\n/** Generates stub ID for value. */\nexport function valueStub(value: Value | null): string {\n if (value == null) {\n return '';\n }\n const str = printValue(value);\n return generateStub(str);\n}\n\n/** Checks if value is a set representation, not a tuple representation. */\nexport function isSetValue(data: Value | null): data is Value[] {\n return Array.isArray(data) && (data.length === 0 || data[0] !== TUPLE_ID);\n}\n\n/** Checks if value is a tuple representation. */\nexport function isTupleValue(data: Value | null): data is Value[] {\n return Array.isArray(data) && data.length > 1 && data[0] === TUPLE_ID;\n}\n\n/** Normalize unsorted array of values. */\nexport function normalizeValue(data: Value): void {\n if (!Array.isArray(data) || data.length === 0) {\n return;\n }\n\n if (data[0] === TUPLE_ID) {\n for (let i = 1; i < data.length; i++) {\n normalizeValue(data[i]);\n }\n return;\n }\n\n for (const item of data) {\n normalizeValue(item);\n }\n\n data.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < data.length) {\n if (compare(data[i - 1], data[i]) === 0) {\n data.splice(i, 1);\n } else {\n i++;\n }\n }\n}\n\n/** Validates value for {@link ExpressionType} and value of basic sets. */\nexport function validateValue(value: Value, type: ExpressionType, basics: ValueContext): boolean {\n switch (type.typeID) {\n case TypeID.integer:\n return typeof value === 'number';\n case TypeID.logic: {\n if (typeof value !== 'number') {\n return false;\n }\n return value === VALUE_TRUE || value === VALUE_FALSE;\n }\n case TypeID.basic: {\n if (typeof value !== 'number') {\n return false;\n }\n const domain = basics.get(type.baseID);\n return !!domain && Array.isArray(domain) && domain.includes(value);\n }\n\n case TypeID.tuple: {\n if (!Array.isArray(value) || value.length !== type.factors.length + 1 || value[0] !== TUPLE_ID) {\n return false;\n }\n for (let i = 0; i < type.factors.length; i++) {\n if (!validateValue(value[i + 1], type.factors[i], basics)) {\n return false;\n }\n }\n return true;\n }\n\n case TypeID.collection: {\n if (!isSetValue(value)) {\n return false;\n }\n for (const item of value) {\n if (!validateValue(item, type.base, basics)) {\n return false;\n }\n }\n return true;\n }\n\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return false;\n }\n}\n\n/** Converts value path to type path. */\nexport function convertPathToType(path: ValuePath, type: Typification): TypePath | null {\n const result: number[] = [];\n if (path.length === 0) {\n return result as TypePath;\n }\n\n let curType = type;\n let index = 0;\n while (index < path.length) {\n switch (curType.typeID) {\n case TypeID.collection: {\n result.push(0);\n curType = curType.base;\n index++;\n break;\n }\n case TypeID.tuple: {\n const tupleIdx = path[index];\n if (typeof tupleIdx !== 'number' || tupleIdx < 1 || tupleIdx > curType.factors.length) {\n return null;\n }\n result.push(tupleIdx);\n curType = curType.factors[tupleIdx - 1];\n index++;\n break;\n }\n case TypeID.basic:\n case TypeID.integer:\n case TypeID.anyTypification:\n return null;\n }\n }\n return result as TypePath;\n}\n\n/** Extracts value from a target by path. */\nexport function extractValue(target: Value, path: ValuePath): Value | null {\n let current: Value = target;\n let i = 0;\n while (i < path.length) {\n if (!Array.isArray(current) || current.length <= path[i]) {\n return null;\n }\n current = current[path[i]];\n i++;\n }\n return current;\n}\n\n/** Makes default value for a type. */\nexport function makeDefaultValue(type: Typification): Value {\n switch (type.typeID) {\n case TypeID.anyTypification:\n case TypeID.integer:\n case TypeID.basic:\n return INVALID_ELEMENT;\n case TypeID.collection:\n return [];\n case TypeID.tuple:\n return tuple(type.factors.map(item => makeDefaultValue(item)));\n }\n}\n\n/** Perform immutable deep copy update. */\nexport function setNestedValue(target: Value | null, path: ValuePath, newVal: Value): Value {\n if (path.length === 0) {\n return newVal;\n }\n const [head, ...rest] = path;\n const arr = Array.isArray(target) ? [...target] : [];\n arr[head] = setNestedValue(arr[head], makeValuePath(rest), newVal);\n return arr;\n}\n\n/** Test if value contains invalid elements. */\nexport function testInvalid(value: Value): boolean {\n const stack = [value];\n while (stack.length > 0) {\n const current = stack.pop();\n if (current === INVALID_ELEMENT) {\n return true;\n }\n if (Array.isArray(current)) {\n for (const element of current) {\n stack.push(element);\n }\n }\n }\n return false;\n}\n","/**\n * Module: Structured data for RSLang expression evaluation.\n */\n\nimport { type Branded } from '../../shared';\n\nimport { printValue } from './value-api';\n\n/** Tuple ID for array distinction. */\nexport const TUPLE_ID = -111;\n\n/** Invalid value for structured data. */\nexport const INVALID_ELEMENT = -1;\n\n/** Boolean values: true. */\nexport const VALUE_TRUE = 1;\n\n/** Boolean values: false. */\nexport const VALUE_FALSE = 0;\n\n/** Cardinality threshold for \"infinite\" sets (e.g. Z). */\nexport const SET_INFINITY = 10_000_000;\n\n/** Cardinality threshold for Boolean power set. */\nexport const BOOL_INFINITY = 18;\n\n/** Expression evaluation result: structured data. */\nexport type Value = number | Value[];\n\n/** Values context. */\nexport type ValueContext = Map<string, Value>;\n\n/** Value extraction path. */\nexport type ValuePath = Branded<number[], 'ValuePath'>;\n\n/** Creates value path. */\nexport function makeValuePath(path: number[]): ValuePath {\n return path as ValuePath;\n}\n\n/** Empty set ∅. */\nexport const EmptySetV = [];\n\n/** Thrown when a runtime value operation cannot be applied to the given operands. */\nexport class CalcInvalidDataError extends Error {\n readonly left: string;\n readonly right: string;\n\n constructor(left: string, right: string) {\n super(`Cannot compare different types ${left} and ${right}`);\n this.name = 'CalcInvalidDataError';\n this.left = left;\n this.right = right;\n }\n}\n\n/** Compare two structured data without recursive calls. */\nexport function compare(v1: Value, v2: Value): number {\n const stack1: Value[] = [v1];\n const stack2: Value[] = [v2];\n\n while (stack1.length > 0 && stack2.length > 0) {\n const el1 = stack1.pop();\n const el2 = stack2.pop();\n if (el1 === el2) {\n continue;\n }\n\n const type1 = typeof el1;\n const type2 = typeof el2;\n if (type1 === 'number' && type2 === 'number') {\n const numDiff = (el1 as number) - (el2 as number);\n if (numDiff !== 0) return numDiff;\n continue;\n }\n\n const isArray1 = Array.isArray(el1);\n const isArray2 = Array.isArray(el2);\n if (!isArray1 || !isArray2) {\n throw new CalcInvalidDataError(printValue(el1!), printValue(el2!));\n }\n\n const arr1 = el1;\n const arr2 = el2;\n const len1 = arr1.length;\n const len2 = arr2.length;\n if (len1 !== len2) {\n return len1 - len2;\n }\n\n for (let i = len1 - 1; i >= 0; i--) {\n stack1.push(arr1[i]);\n stack2.push(arr2[i]);\n }\n }\n return 0;\n}\n\n/** Tuple from components. */\nexport function tuple(components: Value[]): Value {\n return [TUPLE_ID, ...components];\n}\n\n/** Set from elements (unique). Value[] - materialized. */\nexport function set(elements: Value[]): Value[] {\n const sorted = [...elements].sort(compare);\n for (let i = 1; i < sorted.length; ) {\n if (compare(sorted[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C,GAAG,QAAQ,CAAC,CAAC,KAAK,OAAO;CACzC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,SACzB,IAAI,QAAQ,OAAO,IAAI,IAAI,OAAO,EAAE,MAAM,GACxC,OAAO,OAAO,GAAG,CAAC;MAElB;CAGJ,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"value-BDISzQqI.js","names":[],"sources":["../src/rslang/eval/value-api.ts","../src/rslang/eval/value.ts"],"sourcesContent":["import { generateStub } from '../../shared';\nimport { type ExpressionType, TypeID, type TypePath, type Typification } from '../semantic/typification';\n\nimport {\n BOOL_INFINITY,\n compare,\n EmptySetV,\n INVALID_ELEMENT,\n makeValuePath,\n set,\n SET_INFINITY,\n tuple,\n TUPLE_ID,\n type Value,\n VALUE_FALSE,\n VALUE_TRUE,\n type ValueContext,\n type ValuePath\n} from './value';\n\n/** Cartesian product of factor sets. */\nexport function cartesianProduct(factors: Value[][]): Value[] | null {\n const cardinality = factors.reduce((acc, f) => acc * f.length, 1);\n if (cardinality > SET_INFINITY) {\n return null;\n }\n if (cardinality === 0 || factors.length === 0) {\n return EmptySetV;\n }\n\n let accumulator: Value[][] = [[]];\n for (const factor of factors) {\n const next: Value[][] = [];\n for (const prefix of accumulator) {\n for (const value of factor) {\n next.push([...prefix, value]);\n }\n }\n accumulator = next;\n }\n return accumulator.map(tuple);\n}\n\n/** Boolean power set ℬ(X). No cache - materialized. */\nexport function boolean(base: Value[]): Value[] | null {\n if (base.length > BOOL_INFINITY) {\n return null;\n }\n return powerset(base);\n}\n\n/** Powerset of array. */\nfunction powerset(arr: readonly Value[]): Value[][] {\n const result: Value[][] = [[]];\n if (arr.length === 0) {\n return result;\n }\n\n let current: Value[][] = [[]];\n let maxIndex: number[] = [-1];\n while (current.length > 0) {\n const next: Value[][] = [];\n const nextMaxIndex: number[] = [];\n for (let i = 0; i < current.length; i++) {\n for (let j = maxIndex[i] + 1; j < arr.length; j++) {\n const subset = [...current[i], arr[j]];\n result.push(subset);\n if (j < arr.length - 1) {\n next.push(subset);\n nextMaxIndex.push(j);\n }\n }\n }\n current = next;\n maxIndex = nextMaxIndex;\n }\n return result;\n}\n\n/** Check if set contains element. */\nexport function contains(setData: Value[], element: Value): boolean {\n let left = 0;\n let right = setData.length - 1;\n while (left <= right) {\n const mid = Math.floor((left + right) / 2);\n const cmp = compare(setData[mid], element);\n if (cmp === 0) {\n return true;\n } else if (cmp < 0) {\n left = mid + 1;\n } else {\n right = mid - 1;\n }\n }\n return false;\n}\n\n/** Is A ⊆ B. */\nexport function isSubsetOrEq(a: Value[], b: Value[]): boolean {\n let i = 0,\n j = 0;\n while (i < a.length && j < b.length) {\n const cmp = compare(a[i], b[j]);\n if (cmp === 0) {\n i++;\n j++;\n } else if (cmp > 0) {\n j++;\n } else {\n return false;\n }\n }\n return i === a.length;\n}\n\n/** Reduce: flatten double boolean to single boolean. */\nexport function reduce(target: Value[][]): Value[] {\n const result: Value[] = [];\n for (const element of target) {\n result.push(...element);\n }\n return set(result);\n}\n\n/** Union A ∪ B. */\nexport function setUnion(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n let i = 0,\n j = 0;\n while (i < set1.length && j < set2.length) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n result.push(set1[i]);\n i++;\n } else if (cmp > 0) {\n result.push(set2[j]);\n j++;\n } else {\n result.push(set1[i]);\n i++;\n j++;\n }\n }\n while (i < set1.length) {\n result.push(set1[i]);\n i++;\n }\n while (j < set2.length) {\n result.push(set2[j]);\n j++;\n }\n return result;\n}\n\n/** Intersection A ∩ B. */\nexport function setIntersection(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n for (let i = 0, j = 0; i < set1.length && j < set2.length; ) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n i++;\n } else if (cmp > 0) {\n j++;\n } else {\n result.push(set1[i]);\n i++;\n j++;\n }\n }\n return result;\n}\n\n/** Difference A \\ B. */\nexport function setDiff(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n let i = 0,\n j = 0;\n while (i < set1.length && j < set2.length) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n result.push(set1[i]);\n i++;\n } else if (cmp > 0) {\n j++;\n } else {\n i++;\n j++;\n }\n }\n while (i < set1.length) {\n result.push(set1[i]);\n i++;\n }\n return result;\n}\n\n/** Symmetric difference A ∆ B. */\nexport function setSymDiff(set1: Value[], set2: Value[]): Value[] {\n const result: Value[] = [];\n let i = 0,\n j = 0;\n while (i < set1.length && j < set2.length) {\n const cmp = compare(set1[i], set2[j]);\n if (cmp < 0) {\n result.push(set1[i]);\n i++;\n } else if (cmp > 0) {\n result.push(set2[j]);\n j++;\n } else {\n i++;\n j++;\n }\n }\n while (i < set1.length) {\n result.push(set1[i]);\n i++;\n }\n while (j < set2.length) {\n result.push(set2[j]);\n j++;\n }\n return result;\n}\n\n/** Projection of set by indices (BigPr). */\nexport function projection(target: Value[][], indices: number[]): Value[] {\n const projectedElements: Value[] = target.map(element => {\n const newComponents = indices.map(idx => element[idx]);\n return indices.length === 1 ? newComponents[0] : tuple(newComponents);\n });\n return set(projectedElements);\n}\n\n/** Condensed string representation. */\nexport function printValue(data: Value | null): string {\n if (!Array.isArray(data)) {\n return String(data);\n }\n const len = data.length;\n if (data.length === 0) {\n return '{}';\n }\n\n const isTuple = data[0] === TUPLE_ID;\n const start = isTuple ? 1 : 0;\n\n let result = isTuple ? '(' : '{';\n for (let i = start; i < len; i++) {\n if (i > start) result += ', ';\n result += printValue(data[i]);\n }\n result += isTuple ? ')' : '}';\n return result;\n}\n\n/** Generates stub ID for value. */\nexport function valueStub(value: Value | null): string {\n if (value == null) {\n return '';\n }\n const str = printValue(value);\n return generateStub(str);\n}\n\n/** Checks if value is a set representation, not a tuple representation. */\nexport function isSetValue(data: Value | null): data is Value[] {\n return Array.isArray(data) && (data.length === 0 || data[0] !== TUPLE_ID);\n}\n\n/** Checks if value is a tuple representation. */\nexport function isTupleValue(data: Value | null): data is Value[] {\n return Array.isArray(data) && data.length > 1 && data[0] === TUPLE_ID;\n}\n\n/** Normalize unsorted array of values. */\nexport function normalizeValue(data: Value): void {\n if (!Array.isArray(data) || data.length === 0) {\n return;\n }\n\n if (data[0] === TUPLE_ID) {\n for (let i = 1; i < data.length; i++) {\n normalizeValue(data[i]);\n }\n return;\n }\n\n for (const item of data) {\n normalizeValue(item);\n }\n\n data.sort((a, b) => compare(a, b));\n let i = 1;\n while (i < data.length) {\n if (compare(data[i - 1], data[i]) === 0) {\n data.splice(i, 1);\n } else {\n i++;\n }\n }\n}\n\n/** Validates value for {@link ExpressionType} and value of basic sets. */\nexport function validateValue(value: Value, type: ExpressionType, basics: ValueContext): boolean {\n switch (type.typeID) {\n case TypeID.integer:\n return typeof value === 'number';\n case TypeID.logic: {\n if (typeof value !== 'number') {\n return false;\n }\n return value === VALUE_TRUE || value === VALUE_FALSE;\n }\n case TypeID.basic: {\n if (typeof value !== 'number') {\n return false;\n }\n const domain = basics.get(type.baseID);\n return !!domain && Array.isArray(domain) && domain.includes(value);\n }\n\n case TypeID.tuple: {\n if (!Array.isArray(value) || value.length !== type.factors.length + 1 || value[0] !== TUPLE_ID) {\n return false;\n }\n for (let i = 0; i < type.factors.length; i++) {\n if (!validateValue(value[i + 1], type.factors[i], basics)) {\n return false;\n }\n }\n return true;\n }\n\n case TypeID.collection: {\n if (!isSetValue(value)) {\n return false;\n }\n for (const item of value) {\n if (!validateValue(item, type.base, basics)) {\n return false;\n }\n }\n return true;\n }\n\n case TypeID.anyTypification:\n case TypeID.predicate:\n case TypeID.function:\n return false;\n }\n}\n\n/** Converts value path to type path. */\nexport function convertPathToType(path: ValuePath, type: Typification): TypePath | null {\n const result: number[] = [];\n if (path.length === 0) {\n return result as TypePath;\n }\n\n let curType = type;\n let index = 0;\n while (index < path.length) {\n switch (curType.typeID) {\n case TypeID.collection: {\n result.push(0);\n curType = curType.base;\n index++;\n break;\n }\n case TypeID.tuple: {\n const tupleIdx = path[index];\n if (typeof tupleIdx !== 'number' || tupleIdx < 1 || tupleIdx > curType.factors.length) {\n return null;\n }\n result.push(tupleIdx);\n curType = curType.factors[tupleIdx - 1];\n index++;\n break;\n }\n case TypeID.basic:\n case TypeID.integer:\n case TypeID.anyTypification:\n return null;\n }\n }\n return result as TypePath;\n}\n\n/** Extracts value from a target by path. */\nexport function extractValue(target: Value, path: ValuePath): Value | null {\n let current: Value = target;\n let i = 0;\n while (i < path.length) {\n if (!Array.isArray(current) || current.length <= path[i]) {\n return null;\n }\n current = current[path[i]];\n i++;\n }\n return current;\n}\n\n/** Makes default value for a type. */\nexport function makeDefaultValue(type: Typification): Value {\n switch (type.typeID) {\n case TypeID.anyTypification:\n case TypeID.integer:\n case TypeID.basic:\n return INVALID_ELEMENT;\n case TypeID.collection:\n return [];\n case TypeID.tuple:\n return tuple(type.factors.map(item => makeDefaultValue(item)));\n }\n}\n\n/** Perform immutable deep copy update. */\nexport function setNestedValue(target: Value | null, path: ValuePath, newVal: Value): Value {\n if (path.length === 0) {\n return newVal;\n }\n const [head, ...rest] = path;\n const arr = Array.isArray(target) ? [...target] : [];\n arr[head] = setNestedValue(arr[head], makeValuePath(rest), newVal);\n return arr;\n}\n\n/** Test if value contains invalid elements. */\nexport function testInvalid(value: Value): boolean {\n const stack = [value];\n while (stack.length > 0) {\n const current = stack.pop();\n if (current === INVALID_ELEMENT) {\n return true;\n }\n if (Array.isArray(current)) {\n for (const element of current) {\n stack.push(element);\n }\n }\n }\n return false;\n}\n","/**\n * Module: Structured data for RSLang expression evaluation.\n */\n\nimport { type Branded } from '../../shared';\n\nimport { printValue } from './value-api';\n\n/** Tuple ID for array distinction. */\nexport const TUPLE_ID = -111;\n\n/** Invalid value for structured data. */\nexport const INVALID_ELEMENT = -1;\n\n/** Boolean values: true. */\nexport const VALUE_TRUE = 1;\n\n/** Boolean values: false. */\nexport const VALUE_FALSE = 0;\n\n/** Cardinality threshold for \"infinite\" sets (e.g. Z). */\nexport const SET_INFINITY = 10_000_000;\n\n/** Cardinality threshold for Boolean power set. */\nexport const BOOL_INFINITY = 18;\n\n/** Expression evaluation result: structured data. */\nexport type Value = number | Value[];\n\n/** Values context. */\nexport type ValueContext = Map<string, Value>;\n\n/** Value extraction path. */\nexport type ValuePath = Branded<number[], 'ValuePath'>;\n\n/** Creates value path. */\nexport function makeValuePath(path: number[]): ValuePath {\n return path as ValuePath;\n}\n\n/** Empty set ∅. */\nexport const EmptySetV = [];\n\n/** Thrown when a runtime value operation cannot be applied to the given operands. */\nexport class CalcInvalidDataError extends Error {\n readonly left: string;\n readonly right: string;\n\n constructor(left: string, right: string) {\n super(`Cannot compare different types ${left} and ${right}`);\n this.name = 'CalcInvalidDataError';\n this.left = left;\n this.right = right;\n }\n}\n\n/** Compare two structured data without recursive calls. */\nexport function compare(v1: Value, v2: Value): number {\n const stack1: Value[] = [v1];\n const stack2: Value[] = [v2];\n\n while (stack1.length > 0 && stack2.length > 0) {\n const el1 = stack1.pop();\n const el2 = stack2.pop();\n if (el1 === el2) {\n continue;\n }\n\n const type1 = typeof el1;\n const type2 = typeof el2;\n if (type1 === 'number' && type2 === 'number') {\n const numDiff = (el1 as number) - (el2 as number);\n if (numDiff !== 0) return numDiff;\n continue;\n }\n\n const isArray1 = Array.isArray(el1);\n const isArray2 = Array.isArray(el2);\n if (!isArray1 || !isArray2) {\n throw new CalcInvalidDataError(printValue(el1!), printValue(el2!));\n }\n\n const arr1 = el1;\n const arr2 = el2;\n const len1 = arr1.length;\n const len2 = arr2.length;\n if (len1 !== len2) {\n return len1 - len2;\n }\n\n for (let i = len1 - 1; i >= 0; i--) {\n stack1.push(arr1[i]);\n stack2.push(arr2[i]);\n }\n }\n return 0;\n}\n\n/** Tuple from components. */\nexport function tuple(components: Value[]): Value {\n return [TUPLE_ID, ...components];\n}\n\n/** Set from elements (unique). Value[] - materialized. */\nexport function set(elements: Value[]): Value[] {\n const sorted = [...elements].sort(compare);\n for (let i = 1; i < sorted.length; ) {\n if (compare(sorted[i -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C,MAAM,SAAS,CAAC,GAAG,QAAQ,CAAC,CAAC,KAAK,OAAO;CACzC,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,SACzB,IAAI,QAAQ,OAAO,IAAI,IAAI,OAAO,EAAE,MAAM,GACxC,OAAO,OAAO,GAAG,CAAC;MAElB;CAGJ,OAAO;AACT"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsconcept/domain",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Shared TypeScript domain for RS language, RSForm, RSModel, RSEngine, OSS, and concept-text helpers.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "IRBorisov",
|
|
@@ -154,6 +154,27 @@
|
|
|
154
154
|
"README.md",
|
|
155
155
|
"LICENSE"
|
|
156
156
|
],
|
|
157
|
+
"dependencies": {
|
|
158
|
+
"@lezer/common": "^1.5.3",
|
|
159
|
+
"@lezer/lr": "^1.4.11"
|
|
160
|
+
},
|
|
161
|
+
"devDependencies": {
|
|
162
|
+
"@lezer/generator": "^1.8.1",
|
|
163
|
+
"@types/node": "^26.6.5",
|
|
164
|
+
"@typescript-eslint/parser": "^8.72.0",
|
|
165
|
+
"eslint": "^10.13.0",
|
|
166
|
+
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
167
|
+
"globals": "^17.13.0",
|
|
168
|
+
"prettier": "^3.9.10",
|
|
169
|
+
"tsdown": "^0.23.1",
|
|
170
|
+
"typescript": "^6.0.3",
|
|
171
|
+
"typescript-eslint": "^8.72.0",
|
|
172
|
+
"unrun": "^0.3.1",
|
|
173
|
+
"vitest": "^5.0.5"
|
|
174
|
+
},
|
|
175
|
+
"publishConfig": {
|
|
176
|
+
"access": "public"
|
|
177
|
+
},
|
|
157
178
|
"scripts": {
|
|
158
179
|
"generate": "lezer-generator src/rslang/parser/rslang.grammar -o src/rslang/parser/parser.ts",
|
|
159
180
|
"build": "tsdown",
|
|
@@ -163,28 +184,6 @@
|
|
|
163
184
|
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
164
185
|
"lintFix": "eslint . --report-unused-disable-directives --max-warnings 0 --fix",
|
|
165
186
|
"format": "prettier --write \"src/**/*.ts\" \"*.{ts,js}\"",
|
|
166
|
-
"format:check": "prettier --check \"src/**/*.ts\" \"*.{ts,js}\""
|
|
167
|
-
"prepublishOnly": "pnpm run build"
|
|
168
|
-
},
|
|
169
|
-
"dependencies": {
|
|
170
|
-
"@lezer/common": "^1.5.2",
|
|
171
|
-
"@lezer/lr": "^1.4.10"
|
|
172
|
-
},
|
|
173
|
-
"devDependencies": {
|
|
174
|
-
"@lezer/generator": "^1.8.0",
|
|
175
|
-
"@types/node": "^26.1.1",
|
|
176
|
-
"@typescript-eslint/parser": "^8.63.0",
|
|
177
|
-
"eslint": "^9.39.5",
|
|
178
|
-
"eslint-plugin-simple-import-sort": "^13.0.0",
|
|
179
|
-
"globals": "^17.7.0",
|
|
180
|
-
"prettier": "^3.9.5",
|
|
181
|
-
"tsdown": "^0.22.4",
|
|
182
|
-
"typescript": "^6.0.3",
|
|
183
|
-
"typescript-eslint": "^8.63.0",
|
|
184
|
-
"unrun": "^0.3.1",
|
|
185
|
-
"vitest": "^4.1.10"
|
|
186
|
-
},
|
|
187
|
-
"publishConfig": {
|
|
188
|
-
"access": "public"
|
|
187
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"*.{ts,js}\""
|
|
189
188
|
}
|
|
190
|
-
}
|
|
189
|
+
}
|