@rsconcept/domain 1.5.2 → 1.6.1
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-0kmNRqcr.d.ts → analyzer-camCAEkQ.d.ts} +2 -2
- package/dist/{ast-annotations-BnVekMjH.d.ts → ast-annotations-DiXmFraa.d.ts} +2 -2
- package/dist/{calculator-OV-RNXre.d.ts → calculator-BuVooqpb.d.ts} +2 -2
- package/dist/{error-DYLkv4B3.d.ts → error-CZXO5Y6a.d.ts} +7 -3
- package/dist/index.d.ts +4 -4
- package/dist/library/rsengine.d.ts +1 -1
- package/dist/library/rsform-api.d.ts +1 -1
- package/dist/library/rsform-api.js +2 -1
- package/dist/library/rsform-api.js.map +1 -1
- package/dist/library/rsform.d.ts +1 -1
- package/dist/rslang/ast-annotations.d.ts +1 -1
- package/dist/rslang/error.d.ts +1 -1
- package/dist/rslang/error.js +6 -2
- package/dist/rslang/error.js.map +1 -1
- package/dist/rslang/eval/calculator.d.ts +1 -1
- package/dist/rslang/eval/evaluator.d.ts +1 -1
- package/dist/rslang/index.d.ts +4 -4
- package/dist/rslang/parser/syntax-errors.d.ts +1 -1
- package/dist/rslang/parser/syntax-errors.js +44 -0
- package/dist/rslang/parser/syntax-errors.js.map +1 -1
- package/dist/rslang/semantic/analyzer.d.ts +1 -1
- package/dist/rslang/semantic/analyzer.js +5 -2
- package/dist/rslang/semantic/analyzer.js.map +1 -1
- package/dist/rslang/semantic/type-auditor.d.ts +1 -1
- package/dist/rslang/semantic/type-auditor.js +32 -11
- package/dist/rslang/semantic/type-auditor.js.map +1 -1
- package/dist/rslang/semantic/value-auditor.d.ts +1 -1
- package/package.json +1 -1
- package/src/library/rsform-api.test.ts +30 -2
- package/src/library/rsform-api.ts +2 -1
- package/src/rslang/error.ts +6 -2
- package/src/rslang/parser/parser.test.ts +21 -0
- package/src/rslang/parser/syntax-errors.ts +63 -0
- package/src/rslang/semantic/analyzer.test.ts +56 -6
- package/src/rslang/semantic/analyzer.ts +5 -2
- package/src/rslang/semantic/type-auditor.test.ts +17 -7
- package/src/rslang/semantic/type-auditor.ts +31 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AstNode } from "./ast-C8sIpKdL.js";
|
|
2
2
|
import { f as ExpressionType, g as TypeClass } from "./typification-Dk-fisgO.js";
|
|
3
|
-
import { i as RSErrorDescription } from "./error-
|
|
3
|
+
import { i as RSErrorDescription } from "./error-CZXO5Y6a.js";
|
|
4
4
|
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
5
5
|
|
|
6
6
|
//#region src/rslang/semantic/analyzer.d.ts
|
|
@@ -36,4 +36,4 @@ declare class RSLangAnalyzer {
|
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
export { RSLangAnalyzer as a, AnalysisOptions as i, AnalysisFast as n, AnalysisFull as r, AnalysisBase as t };
|
|
39
|
-
//# sourceMappingURL=analyzer-
|
|
39
|
+
//# sourceMappingURL=analyzer-camCAEkQ.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AstNode } from "./ast-C8sIpKdL.js";
|
|
2
2
|
import { f as ExpressionType } from "./typification-Dk-fisgO.js";
|
|
3
|
-
import { a as RSErrorInfo, r as RSErrorCode } from "./error-
|
|
3
|
+
import { a as RSErrorInfo, r as RSErrorCode } from "./error-CZXO5Y6a.js";
|
|
4
4
|
|
|
5
5
|
//#region src/rslang/ast-annotations.d.ts
|
|
6
6
|
/** Appends {@link ExpressionType} onto the node's `annotation.rsType`. */
|
|
@@ -13,4 +13,4 @@ declare function annotateError(node: AstNode, code: RSErrorCode, params?: readon
|
|
|
13
13
|
declare function readErrorAnnotation(node: AstNode): RSErrorInfo | null;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { readTypeAnnotation as i, annotateType as n, readErrorAnnotation as r, annotateError as t };
|
|
16
|
-
//# sourceMappingURL=ast-annotations-
|
|
16
|
+
//# sourceMappingURL=ast-annotations-DiXmFraa.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AstNode } from "./ast-C8sIpKdL.js";
|
|
2
2
|
import { f as ExpressionType } from "./typification-Dk-fisgO.js";
|
|
3
|
-
import { i as RSErrorDescription } from "./error-
|
|
3
|
+
import { i as RSErrorDescription } from "./error-CZXO5Y6a.js";
|
|
4
4
|
import { l as Value } from "./value-BduA_ZGp.js";
|
|
5
5
|
|
|
6
6
|
//#region src/rslang/eval/calculator.d.ts
|
|
@@ -36,4 +36,4 @@ declare class RSCalculator {
|
|
|
36
36
|
}
|
|
37
37
|
//#endregion
|
|
38
38
|
export { CalculatorResult as n, RSCalculator as r, CalculatorEvaluateOptions as t };
|
|
39
|
-
//# sourceMappingURL=calculator-
|
|
39
|
+
//# sourceMappingURL=calculator-BuVooqpb.d.ts.map
|
|
@@ -24,6 +24,7 @@ type ErrorReporter = (error: RSErrorDescription) => void;
|
|
|
24
24
|
/** Represents RSLang expression error types. */
|
|
25
25
|
declare const RSErrorCode: {
|
|
26
26
|
readonly unknownSyntax: 33792;
|
|
27
|
+
readonly forbiddenCharacter: 33793;
|
|
27
28
|
readonly bracketMismatch: 33801;
|
|
28
29
|
readonly doubleParenthesis: 33802;
|
|
29
30
|
readonly missingOpenBracket: 33803;
|
|
@@ -47,9 +48,12 @@ declare const RSErrorCode: {
|
|
|
47
48
|
readonly invalidDebool: 34825;
|
|
48
49
|
readonly globalFuncWithoutArgs: 34827;
|
|
49
50
|
readonly invalidReduce: 34832;
|
|
50
|
-
readonly invalidProjectionTuple: 34833;
|
|
51
|
-
readonly invalidProjectionSet: 34834;
|
|
52
51
|
readonly invalidEnumeration: 34835;
|
|
52
|
+
readonly projectionSetArgumentNotSet: 34864;
|
|
53
|
+
readonly projectionSetArgumentNotTupleSet: 34865;
|
|
54
|
+
readonly projectionSetIndexOutOfRange: 34866;
|
|
55
|
+
readonly projectionTupleArgumentNotTuple: 34867;
|
|
56
|
+
readonly projectionTupleIndexOutOfRange: 34868;
|
|
53
57
|
readonly invalidCortegeDeclare: 34836;
|
|
54
58
|
readonly localOutOfScope: 34837;
|
|
55
59
|
readonly invalidElementPredicate: 34838;
|
|
@@ -93,4 +97,4 @@ declare function getRSErrorPrefix(code: RSErrorCode): string;
|
|
|
93
97
|
declare function isCritical(code: RSErrorCode): boolean;
|
|
94
98
|
//#endregion
|
|
95
99
|
export { RSErrorInfo as a, RSErrorDescription as i, RSErrorClass as n, getRSErrorPrefix as o, RSErrorCode as r, isCritical as s, ErrorReporter as t };
|
|
96
|
-
//# sourceMappingURL=error-
|
|
100
|
+
//# sourceMappingURL=error-CZXO5Y6a.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -9,15 +9,15 @@ import { a as TOKEN_ERROR, c as flattenAst, d as printAst, f as visitAstDFS, i a
|
|
|
9
9
|
import { t as Branded } from "./branded-ZlzIcxzu.js";
|
|
10
10
|
import { n as generateStub, t as applyHash_fnv1a } from "./hash-Y8I4c6Al.js";
|
|
11
11
|
import { O as makeTypePath, b as Typification, d as EmptySetT, f as ExpressionType, g as TypeClass, m as LogicT, t as AnyTypificationT, v as TypeID, y as TypePath } from "./typification-Dk-fisgO.js";
|
|
12
|
-
import { i as RSErrorDescription, r as RSErrorCode } from "./error-
|
|
13
|
-
import { i as readTypeAnnotation, r as readErrorAnnotation } from "./ast-annotations-
|
|
12
|
+
import { i as RSErrorDescription, r as RSErrorCode } from "./error-CZXO5Y6a.js";
|
|
13
|
+
import { i as readTypeAnnotation, r as readErrorAnnotation } from "./ast-annotations-DiXmFraa.js";
|
|
14
14
|
import { d as ValuePath, l as Value, o as TUPLE_ID, p as makeValuePath } from "./value-BduA_ZGp.js";
|
|
15
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "./calculator-
|
|
15
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "./calculator-BuVooqpb.js";
|
|
16
16
|
import { d as printValue } from "./value-api-B6T6f4Ia.js";
|
|
17
17
|
import { t as parser } from "./parser-Bwd8LxJ1.js";
|
|
18
18
|
import { t as TokenID } from "./token-DeXAmzwr.js";
|
|
19
19
|
import { t as ValueClass } from "./value-class-CNI-lqXJ.js";
|
|
20
|
-
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "./analyzer-
|
|
20
|
+
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "./analyzer-camCAEkQ.js";
|
|
21
21
|
import { n as ArgumentsType } from "./arguments-extractor-1acwjQNc.js";
|
|
22
22
|
import { n as applyAsciiTypeSubstitutions, r as parseTypeText } from "./typification-parser-BBVx1RxP.js";
|
|
23
23
|
import { n as TypificationNodeData, t as TypificationGraph } from "./typification-graph-6HcZ-rKH.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AstNode } from "../ast-C8sIpKdL.js";
|
|
2
2
|
import { l as Value } from "../value-BduA_ZGp.js";
|
|
3
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-
|
|
3
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-BuVooqpb.js";
|
|
4
4
|
import { CstType, RSForm } from "./rsform.js";
|
|
5
5
|
import { BasicBinding, BasicsContext, EvalStatus, RSModel } from "./rsmodel.js";
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as LibraryItem } from "../library-CYun28Xz.js";
|
|
2
2
|
import { g as TypeClass, y as TypePath } from "../typification-Dk-fisgO.js";
|
|
3
3
|
import { t as ValueClass } from "../value-class-CNI-lqXJ.js";
|
|
4
|
-
import { r as AnalysisFull } from "../analyzer-
|
|
4
|
+
import { r as AnalysisFull } from "../analyzer-camCAEkQ.js";
|
|
5
5
|
import { ArgumentValue, Constituenta, CstClass, CstStatus, CstType, RSForm, RSFormStats } from "./rsform.js";
|
|
6
6
|
|
|
7
7
|
//#region src/library/rsform-api.d.ts
|
|
@@ -266,7 +266,8 @@ function getAnalysisFor(expression, cstType, schema, alias) {
|
|
|
266
266
|
errors: [{
|
|
267
267
|
code: RSErrorCode.definitionNotAllowed,
|
|
268
268
|
from: 0,
|
|
269
|
-
to: Math.max(
|
|
269
|
+
to: Math.max(expression.length, 1),
|
|
270
|
+
params: [cstType, alias ?? ""]
|
|
270
271
|
}],
|
|
271
272
|
ast: null
|
|
272
273
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rsform-api.js","names":[],"sources":["../../src/library/rsform-api.ts"],"sourcesContent":["/**\n * Module: API for formal representation for systems of concepts.\n */\n\nimport {\n type AnalysisFull,\n RSErrorCode,\n TypeClass,\n TypeID,\n type TypePath,\n type Typification,\n ValueClass\n} from '../rslang';\nimport { basic, bool, constant, type EchelonFunctional, isTypification } from '../rslang/semantic/typification';\nimport { applyPath } from '../rslang/semantic/typification-api';\n\nimport { type LibraryItem } from './library';\nimport {\n type ArgumentValue,\n type Constituenta,\n CstClass,\n CstStatus,\n CstType,\n type RSForm,\n type RSFormStats\n} from './rsform';\n\n/** Record of {@link CstType} prefixes. */\nconst CST_TYPE_PREFIX: Record<CstType, string> = {\n [CstType.NOMINAL]: 'N',\n [CstType.BASE]: 'X',\n [CstType.CONSTANT]: 'C',\n [CstType.STRUCTURED]: 'S',\n [CstType.AXIOM]: 'A',\n [CstType.TERM]: 'D',\n [CstType.FUNCTION]: 'F',\n [CstType.PREDICATE]: 'P',\n [CstType.STATEMENT]: 'T'\n};\n\n/** Record of {@link CstType} to {@link CstClass} mapping. */\nconst CST_TYPE_TO_CLASS: Record<CstType, CstClass> = {\n [CstType.NOMINAL]: CstClass.NOMINAL,\n [CstType.BASE]: CstClass.BASIC,\n [CstType.CONSTANT]: CstClass.BASIC,\n [CstType.STRUCTURED]: CstClass.BASIC,\n [CstType.TERM]: CstClass.DERIVED,\n [CstType.FUNCTION]: CstClass.DERIVED,\n [CstType.AXIOM]: CstClass.STATEMENT,\n [CstType.PREDICATE]: CstClass.DERIVED,\n [CstType.STATEMENT]: CstClass.STATEMENT\n};\n\n/** Checks if {@link Constituenta} is a schema issue. */\nexport function isSchemaIssue(cst: Constituenta): boolean {\n if (\n cst.homonyms.length > 0 ||\n cst.formalDuplicates.length > 0 ||\n cst.status === CstStatus.INCORRECT ||\n cst.status === CstStatus.INCALCULABLE ||\n cst.is_type_mismatch\n ) {\n return true;\n }\n if (isBasicConcept(cst.cst_type) && !isLogical(cst.cst_type)) {\n if (!cst.convention || !cst.term_resolved) {\n return true;\n }\n }\n return false;\n}\n\n/** Infers the status of an expression based on parsing and value information. */\nexport function inferStatus(parse: boolean, value?: ValueClass | null): CstStatus {\n if (!parse) {\n return CstStatus.INCORRECT;\n }\n if (value === null) {\n return CstStatus.INCALCULABLE;\n }\n if (value === ValueClass.PROPERTY) {\n return CstStatus.PROPERTY;\n }\n return CstStatus.VERIFIED;\n}\n\n/** Infers type of constituent for a given template and arguments. */\nexport function inferTemplatedType(templateType: CstType, args: ArgumentValue[]): CstType {\n if (args.length === 0 || args.some(arg => !arg.value)) {\n return templateType;\n } else if (templateType === CstType.PREDICATE) {\n return CstType.AXIOM;\n } else {\n return CstType.TERM;\n }\n}\n\n/** Checks if given expression is a template. */\nexport function inferTemplate(expression: string): boolean {\n const match = expression.match(/R\\d+/g);\n return (match && match?.length > 0) ?? false;\n}\n\n/** Infers the {@link CstClass} based on the provided {@link CstType} and template status. */\nexport function inferClass(type: CstType, isTemplate: boolean = false): CstClass {\n if (isTemplate) {\n return CstClass.TEMPLATE;\n }\n return CST_TYPE_TO_CLASS[type];\n}\n\n/** Check if {@link Constituenta} is a template or a category. */\nexport function isTemplateCst(cst: Constituenta): boolean {\n return cst.cst_type === CstType.FUNCTION || cst.cst_type === CstType.PREDICATE || cst.cst_type === CstType.STATEMENT;\n}\n\n/** Apply filter based on start {@link Constituenta} type. */\nexport function applyFilterCategory(start: Constituenta, items: Constituenta[]): Constituenta[] {\n const startIndex = items.indexOf(start);\n if (startIndex === -1) {\n return [];\n }\n const nextCategoryIndex = items.findIndex((cst, index) => index > startIndex && cst.cst_type === CstType.STATEMENT);\n\n return items.filter((_, index) => index >= startIndex && (nextCategoryIndex === -1 || index < nextCategoryIndex));\n}\n\n/** Prefix for alias indicating {@link CstType}. */\nexport function getCstTypePrefix(type: CstType): string {\n return CST_TYPE_PREFIX[type];\n}\n\n/** Guess {@link CstType} from user input hint. */\nexport function guessCstType(hint: string): CstType | null {\n if (hint.length !== 1) {\n return null;\n }\n for (const [type, prefix] of Object.entries(CST_TYPE_PREFIX)) {\n if (hint === prefix) {\n return type as CstType;\n }\n }\n return null;\n}\n\n/** Evaluate if {@link CstType} is basic concept. */\nexport function isBasicConcept(type: CstType): boolean {\n switch (type) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n return true;\n\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is base set or constant set. */\nexport function isBaseSet(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is a function. */\nexport function isFunctional(type: CstType): boolean {\n switch (type) {\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is logical. */\nexport function isLogical(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link Constituenta} can be used produce structure. */\nexport function canProduceStructure(cst: Constituenta): boolean {\n switch (cst.cst_type) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.PREDICATE:\n return false;\n }\n if (!cst.effectiveType) {\n return false;\n }\n if (cst.cst_type === CstType.FUNCTION) {\n const result = (cst.effectiveType as EchelonFunctional).result;\n return typeCanProduceStructure(result);\n }\n if (!isTypification(cst.effectiveType)) {\n return false;\n }\n return typeCanProduceStructure(cst.effectiveType as Typification);\n}\n\n/** Evaluate if {@link CstType} can have manual typification. */\nexport function canHaveManualTypification(type: CstType): boolean {\n switch (type) {\n case CstType.STRUCTURED:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Validate alias format for a given {@link CstType} (prefix + digits, min length 2). */\nexport function validateAliasFormat(alias: string, type: CstType): boolean {\n if (alias.length < 2) {\n return false;\n }\n const prefix = getCstTypePrefix(type);\n if (!alias.startsWith(prefix)) {\n return false;\n }\n if (!/^\\d+$/.exec(alias.substring(prefix.length))) {\n return false;\n }\n return true;\n}\n\n/** Validate new alias against {@link CstType} and {@link RSForm}. */\nexport function validateNewAlias(alias: string, type: CstType, schema: RSForm): boolean {\n if (!validateAliasFormat(alias, type)) {\n return false;\n }\n if (schema.cstByAlias.has(alias)) {\n return false;\n }\n return true;\n}\n\n/** Generate alias for new {@link Constituenta} of a given {@link CstType} for current {@link RSForm}. */\nexport function generateAlias(type: CstType, schema: RSForm, takenAliases: string[] = []): string {\n const prefix = getCstTypePrefix(type);\n if (schema.items.length <= 0) {\n return `${prefix}1`;\n }\n let index = schema.items.reduce((prev, cst, index) => {\n if (cst.cst_type !== type) {\n return prev;\n }\n index = Number(cst.alias.slice(1 - cst.alias.length)) + 1;\n return Math.max(prev, index);\n }, 1);\n let alias = `${prefix}${index}`;\n while (takenAliases.includes(alias)) {\n index = index + 1;\n alias = `${prefix}${index}`;\n }\n return alias;\n}\n\n/**\n * Id to pass as `insert_after` when creating a new {@link Constituenta} spawned by `targetId`:\n * after the last existing child of that spawner, or after the spawner itself if none.\n */\nexport function inferNewSpawnPosition(schema: RSForm, targetId: number): number {\n let last: number | null = null;\n for (const cst of schema.items) {\n if (cst.spawner === targetId) {\n last = cst.id;\n }\n }\n return last ?? targetId;\n}\n\n/** Sorts library items relevant for InlineSynthesis with specified {@link RSForm}. */\nexport function sortItemsForInlineSynthesis(receiver: RSForm, items: readonly LibraryItem[]): LibraryItem[] {\n const result = items.filter(item => item.location === receiver.location);\n for (const item of items) {\n if (item.visible && item.owner === item.owner && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (item.visible && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (!result.includes(item)) {\n result.push(item);\n }\n }\n return result;\n}\n\n/** Remove alias from expression. */\nexport function removeAliasReference(expression: string, alias: string): string {\n const result = expression.replaceAll(new RegExp(`\\\\b${alias}\\\\b`, 'g'), 'DEL');\n return result === 'DEL' ? '' : result;\n}\n\n/** Add alias to expression. */\nexport function addAliasReference(expression: string, alias: string): string {\n return expression + ' ' + alias;\n}\n\n/** Returns expected {@link TypeClass} of formal definition for {@link CstType}. */\nexport function typeClassForCstType(cstType: CstType): TypeClass {\n switch (cstType) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.TERM:\n return TypeClass.typification;\n case CstType.FUNCTION:\n return TypeClass.function;\n case CstType.PREDICATE:\n return TypeClass.predicate;\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return TypeClass.logic;\n }\n}\n\n/** Checks whether a constituenta type supports formal definitions. */\nexport function canHaveFormalDefinition(cstType: CstType): boolean {\n return cstType !== CstType.BASE && cstType !== CstType.CONSTANT;\n}\n\n/** Analyze expression for {@link RSForm}. */\nexport function getAnalysisFor(expression: string, cstType: CstType, schema: RSForm, alias?: string): AnalysisFull {\n if (!canHaveFormalDefinition(cstType)) {\n if (expression.trim().length === 0) {\n const fallbackAlias = alias && alias.length > 0 ? alias : 'X0';\n const type = cstType === CstType.BASE ? bool(basic(fallbackAlias)) : bool(constant(fallbackAlias));\n return {\n success: true,\n type,\n valueClass: ValueClass.VALUE,\n errors: [],\n ast: null\n };\n }\n return {\n success: false,\n type: null,\n valueClass: null,\n errors: [\n {\n code: RSErrorCode.definitionNotAllowed,\n from: 0,\n to: Math.max(0, expression.length - 1)\n }\n ],\n ast: null\n };\n }\n return schema.analyzer.checkFull(expression, {\n expected: typeClassForCstType(cstType),\n isDomain: cstType === CstType.STRUCTURED\n });\n}\n\n/** Calculate statistics for {@link RSForm}. */\nexport function calculateSchemaStats(target: RSForm): RSFormStats {\n const items = target.items;\n return {\n count_all: items.length,\n count_crucial: items.reduce((sum, cst) => sum + (cst.crucial ? 1 : 0), 0),\n\n step_complexity: items.reduce((sum, cst) => sum + calculateStepComplexity(cst), 0),\n\n count_problematic: items.reduce((sum, cst) => sum + (isSchemaIssue(cst) ? 1 : 0), 0),\n count_homonyms: items.reduce((sum, cst) => sum + (cst.homonyms.length > 0 ? 1 : 0), 0),\n count_formal_duplicates: items.reduce((sum, cst) => sum + (cst.formalDuplicates.length > 0 ? 1 : 0), 0),\n count_missing_convention: items.reduce((sum, cst) => sum + (isMissingConvention(cst) ? 1 : 0), 0),\n count_type_mismatch: items.reduce((sum, cst) => sum + (cst.is_type_mismatch ? 1 : 0), 0),\n\n count_incorrect: items.reduce((sum, cst) => sum + (cst.status === CstStatus.INCORRECT ? 1 : 0), 0),\n count_property: items.reduce((sum, cst) => sum + (cst.analysis?.valueClass === ValueClass.PROPERTY ? 1 : 0), 0),\n count_incalculable: items.reduce(\n (sum, cst) => sum + (cst.analysis?.success && cst.analysis.valueClass === null ? 1 : 0),\n 0\n ),\n count_inherited: items.reduce((sum, cst) => sum + (cst.is_inherited ? 1 : 0), 0),\n\n count_text_term: items.reduce((sum, cst) => sum + (cst.term_raw ? 1 : 0), 0),\n count_definition: items.reduce((sum, cst) => sum + (cst.definition_raw ? 1 : 0), 0),\n count_convention: items.reduce((sum, cst) => sum + (isBasicConcept(cst.cst_type) && cst.convention ? 1 : 0), 0),\n count_comment: items.reduce((sum, cst) => sum + (!isBasicConcept(cst.cst_type) && !cst.convention ? 1 : 0), 0),\n\n count_base: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.BASE ? 1 : 0), 0),\n count_constant: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.CONSTANT ? 1 : 0), 0),\n count_structured: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.STRUCTURED ? 1 : 0), 0),\n count_axiom: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.AXIOM ? 1 : 0), 0),\n count_term: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.TERM ? 1 : 0), 0),\n count_function: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.FUNCTION ? 1 : 0), 0),\n count_predicate: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.PREDICATE ? 1 : 0), 0),\n count_statement: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.STATEMENT ? 1 : 0), 0),\n count_nominal: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.NOMINAL ? 1 : 0), 0)\n };\n}\n\n/** Finds {@link Constituenta} by structure path. */\nexport function findCstByStructure(schema: RSForm, target: Constituenta, path: TypePath): Constituenta | null {\n for (const cst of schema.items) {\n if (cst.spawner === target.id && cst.spawner_path) {\n if (cst.spawner_path.length === path.length && cst.spawner_path.every((v, i) => v === path[i])) {\n return cst;\n }\n }\n }\n return null;\n}\n\n/** Retrieves name for piece of target {@link Constituenta} structure. */\nexport function getStructureName(schema: RSForm, target: Constituenta, path: TypePath): string {\n const representation = findCstByStructure(schema, target, path);\n if (representation) {\n return `${representation.alias}: ${representation.term_resolved}`;\n }\n if (!isTypification(target.effectiveType)) {\n return '';\n }\n const type = applyPath(target.effectiveType as Typification, path);\n if (type?.typeID === TypeID.basic) {\n const cst = schema.cstByAlias.get(type.baseID);\n if (cst?.term_resolved) {\n return `${cst.alias}: ${cst.term_resolved}`;\n }\n }\n return '';\n}\n\n// ========= Internals =====\nfunction calculateStepComplexity(cst: Constituenta): number {\n if (cst.cst_type === CstType.AXIOM || cst.cst_type === CstType.NOMINAL || !isBasicConcept(cst.cst_type)) {\n return 0;\n }\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT || !cst.effectiveType) {\n return 1;\n }\n\n const type = cst.effectiveType as Typification;\n return calculateTypificationComplexity(type) + 1;\n}\n\nfunction calculateTypificationComplexity(type: Typification): number {\n switch (type.typeID) {\n case TypeID.basic:\n case TypeID.integer:\n case TypeID.anyTypification:\n return 0;\n case TypeID.tuple:\n return (\n type.factors.length + type.factors.reduce((sum, factor) => sum + calculateTypificationComplexity(factor), 0)\n );\n case TypeID.collection:\n if (type.base.typeID === TypeID.tuple) {\n let sum = 0;\n type.base.factors.forEach(factor => {\n sum += calculateTypificationComplexity(factor);\n });\n return sum + type.base.factors.length;\n } else if (type.base.typeID === TypeID.collection) {\n return calculateTypificationComplexity(type.base) + 1;\n }\n return 0;\n }\n}\n\nfunction isMissingConvention(cst: Constituenta): boolean {\n if (isBasicConcept(cst.cst_type) && !isLogical(cst.cst_type)) {\n if (!cst.convention || !cst.term_resolved) {\n return true;\n }\n }\n return false;\n}\n\n/** Evaluate if {@link Typification} can be used to produce structure. */\nfunction typeCanProduceStructure(type: Typification): boolean {\n if (type.typeID === TypeID.basic || type.typeID === TypeID.integer || type.typeID === TypeID.anyTypification) {\n return false;\n } else if (type.typeID === TypeID.tuple) {\n return true;\n } else {\n return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Q,SAAQ,WAAU;KAClC,OAAO,gCAAgC,MAAM;IAC/C,CAAC;IACD,OAAO,MAAM,KAAK,KAAK,QAAQ;GACjC,OAAO,IAAI,KAAK,KAAK,WAAW,OAAO,YACrC,OAAO,gCAAgC,KAAK,IAAI,IAAI;GAEtD,OAAO;CACX;AACF;AAEA,SAAS,oBAAoB,KAA4B;CACvD,IAAI,eAAe,IAAI,QAAQ,KAAK,CAAC,UAAU,IAAI,QAAQ,GACzD;MAAI,CAAC,IAAI,cAAc,CAAC,IAAI,eAC1B,OAAO;CACT;CAEF,OAAO;AACT;;AAGA,SAAS,wBAAwB,MAA6B;CAC5D,IAAI,KAAK,WAAW,OAAO,SAAS,KAAK,WAAW,OAAO,WAAW,KAAK,WAAW,OAAO,iBAC3F,OAAO;MACF,IAAI,KAAK,WAAW,OAAO,OAChC,OAAO;MAEP,OACE,KAAK,KAAK,WAAW,OAAO,SAC5B,KAAK,KAAK,WAAW,OAAO,WAC5B,KAAK,KAAK,WAAW,OAAO;AAGlC"}
|
|
1
|
+
{"version":3,"file":"rsform-api.js","names":[],"sources":["../../src/library/rsform-api.ts"],"sourcesContent":["/**\n * Module: API for formal representation for systems of concepts.\n */\n\nimport {\n type AnalysisFull,\n RSErrorCode,\n TypeClass,\n TypeID,\n type TypePath,\n type Typification,\n ValueClass\n} from '../rslang';\nimport { basic, bool, constant, type EchelonFunctional, isTypification } from '../rslang/semantic/typification';\nimport { applyPath } from '../rslang/semantic/typification-api';\n\nimport { type LibraryItem } from './library';\nimport {\n type ArgumentValue,\n type Constituenta,\n CstClass,\n CstStatus,\n CstType,\n type RSForm,\n type RSFormStats\n} from './rsform';\n\n/** Record of {@link CstType} prefixes. */\nconst CST_TYPE_PREFIX: Record<CstType, string> = {\n [CstType.NOMINAL]: 'N',\n [CstType.BASE]: 'X',\n [CstType.CONSTANT]: 'C',\n [CstType.STRUCTURED]: 'S',\n [CstType.AXIOM]: 'A',\n [CstType.TERM]: 'D',\n [CstType.FUNCTION]: 'F',\n [CstType.PREDICATE]: 'P',\n [CstType.STATEMENT]: 'T'\n};\n\n/** Record of {@link CstType} to {@link CstClass} mapping. */\nconst CST_TYPE_TO_CLASS: Record<CstType, CstClass> = {\n [CstType.NOMINAL]: CstClass.NOMINAL,\n [CstType.BASE]: CstClass.BASIC,\n [CstType.CONSTANT]: CstClass.BASIC,\n [CstType.STRUCTURED]: CstClass.BASIC,\n [CstType.TERM]: CstClass.DERIVED,\n [CstType.FUNCTION]: CstClass.DERIVED,\n [CstType.AXIOM]: CstClass.STATEMENT,\n [CstType.PREDICATE]: CstClass.DERIVED,\n [CstType.STATEMENT]: CstClass.STATEMENT\n};\n\n/** Checks if {@link Constituenta} is a schema issue. */\nexport function isSchemaIssue(cst: Constituenta): boolean {\n if (\n cst.homonyms.length > 0 ||\n cst.formalDuplicates.length > 0 ||\n cst.status === CstStatus.INCORRECT ||\n cst.status === CstStatus.INCALCULABLE ||\n cst.is_type_mismatch\n ) {\n return true;\n }\n if (isBasicConcept(cst.cst_type) && !isLogical(cst.cst_type)) {\n if (!cst.convention || !cst.term_resolved) {\n return true;\n }\n }\n return false;\n}\n\n/** Infers the status of an expression based on parsing and value information. */\nexport function inferStatus(parse: boolean, value?: ValueClass | null): CstStatus {\n if (!parse) {\n return CstStatus.INCORRECT;\n }\n if (value === null) {\n return CstStatus.INCALCULABLE;\n }\n if (value === ValueClass.PROPERTY) {\n return CstStatus.PROPERTY;\n }\n return CstStatus.VERIFIED;\n}\n\n/** Infers type of constituent for a given template and arguments. */\nexport function inferTemplatedType(templateType: CstType, args: ArgumentValue[]): CstType {\n if (args.length === 0 || args.some(arg => !arg.value)) {\n return templateType;\n } else if (templateType === CstType.PREDICATE) {\n return CstType.AXIOM;\n } else {\n return CstType.TERM;\n }\n}\n\n/** Checks if given expression is a template. */\nexport function inferTemplate(expression: string): boolean {\n const match = expression.match(/R\\d+/g);\n return (match && match?.length > 0) ?? false;\n}\n\n/** Infers the {@link CstClass} based on the provided {@link CstType} and template status. */\nexport function inferClass(type: CstType, isTemplate: boolean = false): CstClass {\n if (isTemplate) {\n return CstClass.TEMPLATE;\n }\n return CST_TYPE_TO_CLASS[type];\n}\n\n/** Check if {@link Constituenta} is a template or a category. */\nexport function isTemplateCst(cst: Constituenta): boolean {\n return cst.cst_type === CstType.FUNCTION || cst.cst_type === CstType.PREDICATE || cst.cst_type === CstType.STATEMENT;\n}\n\n/** Apply filter based on start {@link Constituenta} type. */\nexport function applyFilterCategory(start: Constituenta, items: Constituenta[]): Constituenta[] {\n const startIndex = items.indexOf(start);\n if (startIndex === -1) {\n return [];\n }\n const nextCategoryIndex = items.findIndex((cst, index) => index > startIndex && cst.cst_type === CstType.STATEMENT);\n\n return items.filter((_, index) => index >= startIndex && (nextCategoryIndex === -1 || index < nextCategoryIndex));\n}\n\n/** Prefix for alias indicating {@link CstType}. */\nexport function getCstTypePrefix(type: CstType): string {\n return CST_TYPE_PREFIX[type];\n}\n\n/** Guess {@link CstType} from user input hint. */\nexport function guessCstType(hint: string): CstType | null {\n if (hint.length !== 1) {\n return null;\n }\n for (const [type, prefix] of Object.entries(CST_TYPE_PREFIX)) {\n if (hint === prefix) {\n return type as CstType;\n }\n }\n return null;\n}\n\n/** Evaluate if {@link CstType} is basic concept. */\nexport function isBasicConcept(type: CstType): boolean {\n switch (type) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n return true;\n\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is base set or constant set. */\nexport function isBaseSet(type: CstType): boolean {\n switch (type) {\n case CstType.BASE:\n case CstType.CONSTANT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is a function. */\nexport function isFunctional(type: CstType): boolean {\n switch (type) {\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.AXIOM:\n case CstType.TERM:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Evaluate if {@link CstType} is logical. */\nexport function isLogical(type: CstType): boolean {\n switch (type) {\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return false;\n }\n}\n\n/** Evaluate if {@link Constituenta} can be used produce structure. */\nexport function canProduceStructure(cst: Constituenta): boolean {\n switch (cst.cst_type) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.AXIOM:\n case CstType.STATEMENT:\n case CstType.PREDICATE:\n return false;\n }\n if (!cst.effectiveType) {\n return false;\n }\n if (cst.cst_type === CstType.FUNCTION) {\n const result = (cst.effectiveType as EchelonFunctional).result;\n return typeCanProduceStructure(result);\n }\n if (!isTypification(cst.effectiveType)) {\n return false;\n }\n return typeCanProduceStructure(cst.effectiveType as Typification);\n}\n\n/** Evaluate if {@link CstType} can have manual typification. */\nexport function canHaveManualTypification(type: CstType): boolean {\n switch (type) {\n case CstType.STRUCTURED:\n case CstType.TERM:\n case CstType.FUNCTION:\n case CstType.PREDICATE:\n return true;\n\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return false;\n }\n}\n\n/** Validate alias format for a given {@link CstType} (prefix + digits, min length 2). */\nexport function validateAliasFormat(alias: string, type: CstType): boolean {\n if (alias.length < 2) {\n return false;\n }\n const prefix = getCstTypePrefix(type);\n if (!alias.startsWith(prefix)) {\n return false;\n }\n if (!/^\\d+$/.exec(alias.substring(prefix.length))) {\n return false;\n }\n return true;\n}\n\n/** Validate new alias against {@link CstType} and {@link RSForm}. */\nexport function validateNewAlias(alias: string, type: CstType, schema: RSForm): boolean {\n if (!validateAliasFormat(alias, type)) {\n return false;\n }\n if (schema.cstByAlias.has(alias)) {\n return false;\n }\n return true;\n}\n\n/** Generate alias for new {@link Constituenta} of a given {@link CstType} for current {@link RSForm}. */\nexport function generateAlias(type: CstType, schema: RSForm, takenAliases: string[] = []): string {\n const prefix = getCstTypePrefix(type);\n if (schema.items.length <= 0) {\n return `${prefix}1`;\n }\n let index = schema.items.reduce((prev, cst, index) => {\n if (cst.cst_type !== type) {\n return prev;\n }\n index = Number(cst.alias.slice(1 - cst.alias.length)) + 1;\n return Math.max(prev, index);\n }, 1);\n let alias = `${prefix}${index}`;\n while (takenAliases.includes(alias)) {\n index = index + 1;\n alias = `${prefix}${index}`;\n }\n return alias;\n}\n\n/**\n * Id to pass as `insert_after` when creating a new {@link Constituenta} spawned by `targetId`:\n * after the last existing child of that spawner, or after the spawner itself if none.\n */\nexport function inferNewSpawnPosition(schema: RSForm, targetId: number): number {\n let last: number | null = null;\n for (const cst of schema.items) {\n if (cst.spawner === targetId) {\n last = cst.id;\n }\n }\n return last ?? targetId;\n}\n\n/** Sorts library items relevant for InlineSynthesis with specified {@link RSForm}. */\nexport function sortItemsForInlineSynthesis(receiver: RSForm, items: readonly LibraryItem[]): LibraryItem[] {\n const result = items.filter(item => item.location === receiver.location);\n for (const item of items) {\n if (item.visible && item.owner === item.owner && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (item.visible && !result.includes(item)) {\n result.push(item);\n }\n }\n for (const item of items) {\n if (!result.includes(item)) {\n result.push(item);\n }\n }\n return result;\n}\n\n/** Remove alias from expression. */\nexport function removeAliasReference(expression: string, alias: string): string {\n const result = expression.replaceAll(new RegExp(`\\\\b${alias}\\\\b`, 'g'), 'DEL');\n return result === 'DEL' ? '' : result;\n}\n\n/** Add alias to expression. */\nexport function addAliasReference(expression: string, alias: string): string {\n return expression + ' ' + alias;\n}\n\n/** Returns expected {@link TypeClass} of formal definition for {@link CstType}. */\nexport function typeClassForCstType(cstType: CstType): TypeClass {\n switch (cstType) {\n case CstType.NOMINAL:\n case CstType.BASE:\n case CstType.CONSTANT:\n case CstType.STRUCTURED:\n case CstType.TERM:\n return TypeClass.typification;\n case CstType.FUNCTION:\n return TypeClass.function;\n case CstType.PREDICATE:\n return TypeClass.predicate;\n case CstType.AXIOM:\n case CstType.STATEMENT:\n return TypeClass.logic;\n }\n}\n\n/** Checks whether a constituenta type supports formal definitions. */\nexport function canHaveFormalDefinition(cstType: CstType): boolean {\n return cstType !== CstType.BASE && cstType !== CstType.CONSTANT;\n}\n\n/** Analyze expression for {@link RSForm}. */\nexport function getAnalysisFor(expression: string, cstType: CstType, schema: RSForm, alias?: string): AnalysisFull {\n if (!canHaveFormalDefinition(cstType)) {\n if (expression.trim().length === 0) {\n const fallbackAlias = alias && alias.length > 0 ? alias : 'X0';\n const type = cstType === CstType.BASE ? bool(basic(fallbackAlias)) : bool(constant(fallbackAlias));\n return {\n success: true,\n type,\n valueClass: ValueClass.VALUE,\n errors: [],\n ast: null\n };\n }\n return {\n success: false,\n type: null,\n valueClass: null,\n errors: [\n {\n code: RSErrorCode.definitionNotAllowed,\n from: 0,\n to: Math.max(expression.length, 1),\n params: [cstType, alias ?? '']\n }\n ],\n ast: null\n };\n }\n return schema.analyzer.checkFull(expression, {\n expected: typeClassForCstType(cstType),\n isDomain: cstType === CstType.STRUCTURED\n });\n}\n\n/** Calculate statistics for {@link RSForm}. */\nexport function calculateSchemaStats(target: RSForm): RSFormStats {\n const items = target.items;\n return {\n count_all: items.length,\n count_crucial: items.reduce((sum, cst) => sum + (cst.crucial ? 1 : 0), 0),\n\n step_complexity: items.reduce((sum, cst) => sum + calculateStepComplexity(cst), 0),\n\n count_problematic: items.reduce((sum, cst) => sum + (isSchemaIssue(cst) ? 1 : 0), 0),\n count_homonyms: items.reduce((sum, cst) => sum + (cst.homonyms.length > 0 ? 1 : 0), 0),\n count_formal_duplicates: items.reduce((sum, cst) => sum + (cst.formalDuplicates.length > 0 ? 1 : 0), 0),\n count_missing_convention: items.reduce((sum, cst) => sum + (isMissingConvention(cst) ? 1 : 0), 0),\n count_type_mismatch: items.reduce((sum, cst) => sum + (cst.is_type_mismatch ? 1 : 0), 0),\n\n count_incorrect: items.reduce((sum, cst) => sum + (cst.status === CstStatus.INCORRECT ? 1 : 0), 0),\n count_property: items.reduce((sum, cst) => sum + (cst.analysis?.valueClass === ValueClass.PROPERTY ? 1 : 0), 0),\n count_incalculable: items.reduce(\n (sum, cst) => sum + (cst.analysis?.success && cst.analysis.valueClass === null ? 1 : 0),\n 0\n ),\n count_inherited: items.reduce((sum, cst) => sum + (cst.is_inherited ? 1 : 0), 0),\n\n count_text_term: items.reduce((sum, cst) => sum + (cst.term_raw ? 1 : 0), 0),\n count_definition: items.reduce((sum, cst) => sum + (cst.definition_raw ? 1 : 0), 0),\n count_convention: items.reduce((sum, cst) => sum + (isBasicConcept(cst.cst_type) && cst.convention ? 1 : 0), 0),\n count_comment: items.reduce((sum, cst) => sum + (!isBasicConcept(cst.cst_type) && !cst.convention ? 1 : 0), 0),\n\n count_base: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.BASE ? 1 : 0), 0),\n count_constant: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.CONSTANT ? 1 : 0), 0),\n count_structured: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.STRUCTURED ? 1 : 0), 0),\n count_axiom: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.AXIOM ? 1 : 0), 0),\n count_term: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.TERM ? 1 : 0), 0),\n count_function: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.FUNCTION ? 1 : 0), 0),\n count_predicate: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.PREDICATE ? 1 : 0), 0),\n count_statement: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.STATEMENT ? 1 : 0), 0),\n count_nominal: items.reduce((sum, cst) => sum + (cst.cst_type === CstType.NOMINAL ? 1 : 0), 0)\n };\n}\n\n/** Finds {@link Constituenta} by structure path. */\nexport function findCstByStructure(schema: RSForm, target: Constituenta, path: TypePath): Constituenta | null {\n for (const cst of schema.items) {\n if (cst.spawner === target.id && cst.spawner_path) {\n if (cst.spawner_path.length === path.length && cst.spawner_path.every((v, i) => v === path[i])) {\n return cst;\n }\n }\n }\n return null;\n}\n\n/** Retrieves name for piece of target {@link Constituenta} structure. */\nexport function getStructureName(schema: RSForm, target: Constituenta, path: TypePath): string {\n const representation = findCstByStructure(schema, target, path);\n if (representation) {\n return `${representation.alias}: ${representation.term_resolved}`;\n }\n if (!isTypification(target.effectiveType)) {\n return '';\n }\n const type = applyPath(target.effectiveType as Typification, path);\n if (type?.typeID === TypeID.basic) {\n const cst = schema.cstByAlias.get(type.baseID);\n if (cst?.term_resolved) {\n return `${cst.alias}: ${cst.term_resolved}`;\n }\n }\n return '';\n}\n\n// ========= Internals =====\nfunction calculateStepComplexity(cst: Constituenta): number {\n if (cst.cst_type === CstType.AXIOM || cst.cst_type === CstType.NOMINAL || !isBasicConcept(cst.cst_type)) {\n return 0;\n }\n if (cst.cst_type === CstType.BASE || cst.cst_type === CstType.CONSTANT || !cst.effectiveType) {\n return 1;\n }\n\n const type = cst.effectiveType as Typification;\n return calculateTypificationComplexity(type) + 1;\n}\n\nfunction calculateTypificationComplexity(type: Typification): number {\n switch (type.typeID) {\n case TypeID.basic:\n case TypeID.integer:\n case TypeID.anyTypification:\n return 0;\n case TypeID.tuple:\n return (\n type.factors.length + type.factors.reduce((sum, factor) => sum + calculateTypificationComplexity(factor), 0)\n );\n case TypeID.collection:\n if (type.base.typeID === TypeID.tuple) {\n let sum = 0;\n type.base.factors.forEach(factor => {\n sum += calculateTypificationComplexity(factor);\n });\n return sum + type.base.factors.length;\n } else if (type.base.typeID === TypeID.collection) {\n return calculateTypificationComplexity(type.base) + 1;\n }\n return 0;\n }\n}\n\nfunction isMissingConvention(cst: Constituenta): boolean {\n if (isBasicConcept(cst.cst_type) && !isLogical(cst.cst_type)) {\n if (!cst.convention || !cst.term_resolved) {\n return true;\n }\n }\n return false;\n}\n\n/** Evaluate if {@link Typification} can be used to produce structure. */\nfunction typeCanProduceStructure(type: Typification): boolean {\n if (type.typeID === TypeID.basic || type.typeID === TypeID.integer || type.typeID === TypeID.anyTypification) {\n return false;\n } else if (type.typeID === TypeID.tuple) {\n return true;\n } else {\n return (\n type.base.typeID !== TypeID.basic &&\n type.base.typeID !== TypeID.integer &&\n type.base.typeID !== TypeID.anyTypification\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AA4BA,MAAM,kBAA2C;EAC9C,QAAQ,UAAU;EAClB,QAAQ,OAAO;EACf,QAAQ,WAAW;EACnB,QAAQ,aAAa;EACrB,QAAQ,QAAQ;EAChB,QAAQ,OAAO;EACf,QAAQ,WAAW;EACnB,QAAQ,YAAY;EACpB,QAAQ,YAAY;AACvB;;AAGA,MAAM,oBAA+C;EAClD,QAAQ,UAAU,SAAS;EAC3B,QAAQ,OAAO,SAAS;EACxB,QAAQ,WAAW,SAAS;EAC5B,QAAQ,aAAa,SAAS;EAC9B,QAAQ,OAAO,SAAS;EACxB,QAAQ,WAAW,SAAS;EAC5B,QAAQ,QAAQ,SAAS;EACzB,QAAQ,YAAY,SAAS;EAC7B,QAAQ,YAAY,SAAS;AAChC;;AAGA,SAAgB,cAAc,KAA4B;CACxD,IACE,IAAI,SAAS,SAAS,KACtB,IAAI,iBAAiB,SAAS,KAC9B,IAAI,WAAW,UAAU,aACzB,IAAI,WAAW,UAAU,gBACzB,IAAI,kBAEJ,OAAO;CAET,IAAI,eAAe,IAAI,QAAQ,KAAK,CAAC,UAAU,IAAI,QAAQ,GACzD;MAAI,CAAC,IAAI,cAAc,CAAC,IAAI,eAC1B,OAAO;CACT;CAEF,OAAO;AACT;;AAGA,SAAgB,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M,OAAO,IAAI;CACjB,OAAO,gCAAgC,IAAI,IAAI;AACjD;AAEA,SAAS,gCAAgC,MAA4B;CACnE,QAAQ,KAAK,QAAb;EACE,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,OAAO,iBACV,OAAO;EACT,KAAK,OAAO,OACV,OACE,KAAK,QAAQ,SAAS,KAAK,QAAQ,QAAQ,KAAK,WAAW,MAAM,gCAAgC,MAAM,GAAG,CAAC;EAE/G,KAAK,OAAO;GACV,IAAI,KAAK,KAAK,WAAW,OAAO,OAAO;IACrC,IAAI,MAAM;IACV,KAAK,KAAK,QAAQ,SAAQ,WAAU;KAClC,OAAO,gCAAgC,MAAM;IAC/C,CAAC;IACD,OAAO,MAAM,KAAK,KAAK,QAAQ;GACjC,OAAO,IAAI,KAAK,KAAK,WAAW,OAAO,YACrC,OAAO,gCAAgC,KAAK,IAAI,IAAI;GAEtD,OAAO;CACX;AACF;AAEA,SAAS,oBAAoB,KAA4B;CACvD,IAAI,eAAe,IAAI,QAAQ,KAAK,CAAC,UAAU,IAAI,QAAQ,GACzD;MAAI,CAAC,IAAI,cAAc,CAAC,IAAI,eAC1B,OAAO;CACT;CAEF,OAAO;AACT;;AAGA,SAAS,wBAAwB,MAA6B;CAC5D,IAAI,KAAK,WAAW,OAAO,SAAS,KAAK,WAAW,OAAO,WAAW,KAAK,WAAW,OAAO,iBAC3F,OAAO;MACF,IAAI,KAAK,WAAW,OAAO,OAChC,OAAO;MAEP,OACE,KAAK,KAAK,WAAW,OAAO,SAC5B,KAAK,KAAK,WAAW,OAAO,WAC5B,KAAK,KAAK,WAAW,OAAO;AAGlC"}
|
package/dist/library/rsform.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as Graph } from "../graph-DR8rL2o3.js";
|
|
2
2
|
import { i as LibraryItemReference, n as CurrentVersion, r as LibraryItem, s as VersionInfo } from "../library-CYun28Xz.js";
|
|
3
3
|
import { f as ExpressionType, y as TypePath } from "../typification-Dk-fisgO.js";
|
|
4
|
-
import { a as RSLangAnalyzer, t as AnalysisBase } from "../analyzer-
|
|
4
|
+
import { a as RSLangAnalyzer, t as AnalysisBase } from "../analyzer-camCAEkQ.js";
|
|
5
5
|
//#region src/library/rsform.d.ts
|
|
6
6
|
/** Represents {@link Constituenta} type. */
|
|
7
7
|
declare const CstType: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as readTypeAnnotation, n as annotateType, r as readErrorAnnotation, t as annotateError } from "../ast-annotations-
|
|
1
|
+
import { i as readTypeAnnotation, n as annotateType, r as readErrorAnnotation, t as annotateError } from "../ast-annotations-DiXmFraa.js";
|
|
2
2
|
export { annotateError, annotateType, readErrorAnnotation, readTypeAnnotation };
|
package/dist/rslang/error.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RSErrorInfo, i as RSErrorDescription, n as RSErrorClass, o as getRSErrorPrefix, r as RSErrorCode, s as isCritical, t as ErrorReporter } from "../error-
|
|
1
|
+
import { a as RSErrorInfo, i as RSErrorDescription, n as RSErrorClass, o as getRSErrorPrefix, r as RSErrorCode, s as isCritical, t as ErrorReporter } from "../error-CZXO5Y6a.js";
|
|
2
2
|
export { ErrorReporter, RSErrorClass, RSErrorCode, RSErrorDescription, RSErrorInfo, getRSErrorPrefix, isCritical };
|
package/dist/rslang/error.js
CHANGED
|
@@ -11,6 +11,7 @@ const RSErrorClass = {
|
|
|
11
11
|
/** Represents RSLang expression error types. */
|
|
12
12
|
const RSErrorCode = {
|
|
13
13
|
unknownSyntax: 33792,
|
|
14
|
+
forbiddenCharacter: 33793,
|
|
14
15
|
bracketMismatch: 33801,
|
|
15
16
|
doubleParenthesis: 33802,
|
|
16
17
|
missingOpenBracket: 33803,
|
|
@@ -34,9 +35,12 @@ const RSErrorCode = {
|
|
|
34
35
|
invalidDebool: 34825,
|
|
35
36
|
globalFuncWithoutArgs: 34827,
|
|
36
37
|
invalidReduce: 34832,
|
|
37
|
-
invalidProjectionTuple: 34833,
|
|
38
|
-
invalidProjectionSet: 34834,
|
|
39
38
|
invalidEnumeration: 34835,
|
|
39
|
+
projectionSetArgumentNotSet: 34864,
|
|
40
|
+
projectionSetArgumentNotTupleSet: 34865,
|
|
41
|
+
projectionSetIndexOutOfRange: 34866,
|
|
42
|
+
projectionTupleArgumentNotTuple: 34867,
|
|
43
|
+
projectionTupleIndexOutOfRange: 34868,
|
|
40
44
|
invalidCortegeDeclare: 34836,
|
|
41
45
|
localOutOfScope: 34837,
|
|
42
46
|
invalidElementPredicate: 34838,
|
package/dist/rslang/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../src/rslang/error.ts"],"sourcesContent":["/** Module: Error types and functions. */\n\n/** Represents error class. */\nexport const RSErrorClass = {\n LEXER: 0,\n PARSER: 1,\n SEMANTIC: 2,\n EVALUATION: 3,\n UNKNOWN: 4\n} as const;\nexport type RSErrorClass = (typeof RSErrorClass)[keyof typeof RSErrorClass];\n\n/** Represents RSLang expression error information. */\nexport interface RSErrorInfo {\n code: RSErrorCode;\n params?: readonly string[];\n}\n\n/** Represents RSLang expression error description. */\nexport interface RSErrorDescription extends RSErrorInfo {\n from: number;\n to: number;\n}\n\n/** Error reporter function type. */\nexport type ErrorReporter = (error: RSErrorDescription) => void;\n\n/** Represents RSLang expression error types. */\nexport const RSErrorCode = {\n unknownSyntax: 0x8400, // 33792\n bracketMismatch: 0x8409, // 33801\n doubleParenthesis: 0x840a, // 33802\n missingOpenBracket: 0x840b, // 33803\n missingCloseBracket: 0x840c, // 33804\n invalidFilterSyntax: 0x8417, // 33815\n expectedFunctionBody: 0x8418, // 33816\n expectedExpressionBody: 0x8419, // 33817\n expectedLogicBody: 0x841a, // 33818\n expectedLocal: 0x8415, // 33813\n expectedType: 0x8416, // 33814\n\n localDoubleDeclare: 0x2801, // 10241\n localNotUsed: 0x2802, // 10242\n\n localUndeclared: 0x8801, // 34817\n localShadowing: 0x8802, // 34818\n\n typesNotEqual: 0x8803, // 34819\n globalNotTyped: 0x8804, // 34820\n invalidDecart: 0x8805, // 34821\n invalidBoolean: 0x8806, // 34822\n invalidTypeOperation: 0x8807, // 34823\n invalidCard: 0x8808, // 34824\n invalidDebool: 0x8809, // 34825\n globalFuncWithoutArgs: 0x880b, // 34827\n invalidReduce: 0x8810, // 34832\n
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../src/rslang/error.ts"],"sourcesContent":["/** Module: Error types and functions. */\n\n/** Represents error class. */\nexport const RSErrorClass = {\n LEXER: 0,\n PARSER: 1,\n SEMANTIC: 2,\n EVALUATION: 3,\n UNKNOWN: 4\n} as const;\nexport type RSErrorClass = (typeof RSErrorClass)[keyof typeof RSErrorClass];\n\n/** Represents RSLang expression error information. */\nexport interface RSErrorInfo {\n code: RSErrorCode;\n params?: readonly string[];\n}\n\n/** Represents RSLang expression error description. */\nexport interface RSErrorDescription extends RSErrorInfo {\n from: number;\n to: number;\n}\n\n/** Error reporter function type. */\nexport type ErrorReporter = (error: RSErrorDescription) => void;\n\n/** Represents RSLang expression error types. */\nexport const RSErrorCode = {\n unknownSyntax: 0x8400, // 33792\n forbiddenCharacter: 0x8401, // 33793\n bracketMismatch: 0x8409, // 33801\n doubleParenthesis: 0x840a, // 33802\n missingOpenBracket: 0x840b, // 33803\n missingCloseBracket: 0x840c, // 33804\n invalidFilterSyntax: 0x8417, // 33815\n expectedFunctionBody: 0x8418, // 33816\n expectedExpressionBody: 0x8419, // 33817\n expectedLogicBody: 0x841a, // 33818\n expectedLocal: 0x8415, // 33813\n expectedType: 0x8416, // 33814\n\n localDoubleDeclare: 0x2801, // 10241\n localNotUsed: 0x2802, // 10242\n\n localUndeclared: 0x8801, // 34817\n localShadowing: 0x8802, // 34818\n\n typesNotEqual: 0x8803, // 34819\n globalNotTyped: 0x8804, // 34820\n invalidDecart: 0x8805, // 34821\n invalidBoolean: 0x8806, // 34822\n invalidTypeOperation: 0x8807, // 34823\n invalidCard: 0x8808, // 34824\n invalidDebool: 0x8809, // 34825\n globalFuncWithoutArgs: 0x880b, // 34827\n invalidReduce: 0x8810, // 34832\n invalidEnumeration: 0x8813, // 34835\n projectionSetArgumentNotSet: 0x8830, // 34864\n projectionSetArgumentNotTupleSet: 0x8831, // 34865\n projectionSetIndexOutOfRange: 0x8832, // 34866\n projectionTupleArgumentNotTuple: 0x8833, // 34867\n projectionTupleIndexOutOfRange: 0x8834, // 34868\n invalidCortegeDeclare: 0x8814, // 34836\n localOutOfScope: 0x8815, // 34837\n invalidElementPredicate: 0x8816, // 34838\n invalidEmptySetUsage: 0x8817, // 34839\n invalidArgsArity: 0x8818, // 34840\n invalidArgumentType: 0x8819, // 34841\n globalStructure: 0x881c, // 34844\n radicalUsage: 0x8821, // 34849\n invalidFilterArgumentType: 0x8822, // 34850\n invalidFilterArity: 0x8823, // 34851\n arithmeticNotSupported: 0x8824, // 34852\n typesNotCompatible: 0x8825, // 34853\n orderingNotSupported: 0x8826, // 34854\n expectedLogic: 0x8827, // 34855\n expectedSetexpr: 0x8828, // 34856\n invalidArgumentCortegeDeclare: 0x8829, // 34857\n invalidQuantifierDomain: 0x882a, // 34858\n invalidFilterParameterType: 0x882b, // 34859\n invalidFilterIndex: 0x882c, // 34860\n invalidFilterBooleanEchelon: 0x882d, // 34861\n localOutOfScopeParentheses: 0x882e, // 34862\n localUndeclaredInSubexpr: 0x882f, // 34863\n\n globalNoValue: 0x8840, // 34880\n invalidPropertyUsage: 0x8841, // 34881\n\n // Value evaluation (runtime)\n calcUnknownError: 0x8100, // 35328\n setOverflow: 0x8101, // 35329\n booleanBaseLimit: 0x8102, // 35330\n calcGlobalMissing: 0x8103, // 35331\n iterationsLimit: 0x8104, // 35332\n calcInvalidDebool: 0x8105, // 35333\n iterateInfinity: 0x8106, // 35334\n calculationNotSupported: 0x8107, // 35335\n calcInvalidData: 0x8108, // 35336\n\n cstEmptyDerived: 0x8861, // 34913\n definitionNotAllowed: 0x8862 // 34914\n} as const;\nexport type RSErrorCode = (typeof RSErrorCode)[keyof typeof RSErrorCode];\n\nconst ERROR_EVALUATION_MASK = 0x0100;\nconst ERROR_LEXER_MASK = 0x0200;\nconst ERROR_PARSER_MASK = 0x0400;\nconst ERROR_SEMANTIC_MASK = 0x0800;\n\n/** Infers error class from error type (code). */\nfunction inferErrorClass(error: RSErrorCode): RSErrorClass {\n if ((error & ERROR_EVALUATION_MASK) !== 0) {\n return RSErrorClass.EVALUATION;\n } else if ((error & ERROR_LEXER_MASK) !== 0) {\n return RSErrorClass.LEXER;\n } else if ((error & ERROR_PARSER_MASK) !== 0) {\n return RSErrorClass.PARSER;\n } else if ((error & ERROR_SEMANTIC_MASK) !== 0) {\n return RSErrorClass.SEMANTIC;\n } else {\n return RSErrorClass.UNKNOWN;\n }\n}\n\n/** Generate ErrorID label. */\nexport function getRSErrorPrefix(code: RSErrorCode): string {\n const id = code.toString(16).toUpperCase();\n // prettier-ignore\n switch (inferErrorClass(code)) {\n case RSErrorClass.LEXER: return 'L' + id;\n case RSErrorClass.PARSER: return 'P' + id;\n case RSErrorClass.SEMANTIC: return 'S' + id;\n case RSErrorClass.EVALUATION: return 'E' + id;\n case RSErrorClass.UNKNOWN: return 'U' + id;\n }\n}\n\n/** Checks if error is critical. */\nexport function isCritical(code: RSErrorCode): boolean {\n return code !== RSErrorCode.localDoubleDeclare && code !== RSErrorCode.localNotUsed;\n}\n"],"mappings":";;;AAGA,MAAa,eAAe;CAC1B,OAAO;CACP,QAAQ;CACR,UAAU;CACV,YAAY;CACZ,SAAS;AACX;;AAmBA,MAAa,cAAc;CACzB,eAAe;CACf,oBAAoB;CACpB,iBAAiB;CACjB,mBAAmB;CACnB,oBAAoB;CACpB,qBAAqB;CACrB,qBAAqB;CACrB,sBAAsB;CACtB,wBAAwB;CACxB,mBAAmB;CACnB,eAAe;CACf,cAAc;CAEd,oBAAoB;CACpB,cAAc;CAEd,iBAAiB;CACjB,gBAAgB;CAEhB,eAAe;CACf,gBAAg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M;EACzC,KAAK,aAAa,YAAY,OAAO,MAAM;EAC3C,KAAK,aAAa,SAAS,OAAO,MAAM;CAC1C;AACF;;AAGA,SAAgB,WAAW,MAA4B;CACrD,OAAO,SAAS,YAAY,sBAAsB,SAAS,YAAY;AACzE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../../calculator-
|
|
1
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../../calculator-BuVooqpb.js";
|
|
2
2
|
export { CalculatorEvaluateOptions, CalculatorResult, RSCalculator };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as AstNode } from "../../ast-C8sIpKdL.js";
|
|
2
|
-
import { t as ErrorReporter } from "../../error-
|
|
2
|
+
import { t as ErrorReporter } from "../../error-CZXO5Y6a.js";
|
|
3
3
|
import { l as Value, u as ValueContext } from "../../value-BduA_ZGp.js";
|
|
4
4
|
|
|
5
5
|
//#region src/rslang/eval/evaluator.d.ts
|
package/dist/rslang/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { O as makeTypePath, b as Typification, d as EmptySetT, f as ExpressionType, g as TypeClass, m as LogicT, t as AnyTypificationT, v as TypeID, y as TypePath } from "../typification-Dk-fisgO.js";
|
|
2
|
-
import { i as RSErrorDescription, r as RSErrorCode } from "../error-
|
|
3
|
-
import { i as readTypeAnnotation, r as readErrorAnnotation } from "../ast-annotations-
|
|
2
|
+
import { i as RSErrorDescription, r as RSErrorCode } from "../error-CZXO5Y6a.js";
|
|
3
|
+
import { i as readTypeAnnotation, r as readErrorAnnotation } from "../ast-annotations-DiXmFraa.js";
|
|
4
4
|
import { d as ValuePath, l as Value, p as makeValuePath } from "../value-BduA_ZGp.js";
|
|
5
|
-
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-
|
|
5
|
+
import { n as CalculatorResult, r as RSCalculator, t as CalculatorEvaluateOptions } from "../calculator-BuVooqpb.js";
|
|
6
6
|
import { d as printValue } from "../value-api-B6T6f4Ia.js";
|
|
7
7
|
import { t as parser } from "../parser-Bwd8LxJ1.js";
|
|
8
8
|
import { t as TokenID } from "../token-DeXAmzwr.js";
|
|
9
9
|
import { t as ValueClass } from "../value-class-CNI-lqXJ.js";
|
|
10
|
-
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "../analyzer-
|
|
10
|
+
import { a as RSLangAnalyzer, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "../analyzer-camCAEkQ.js";
|
|
11
11
|
import { n as ArgumentsType } from "../arguments-extractor-1acwjQNc.js";
|
|
12
12
|
import { n as applyAsciiTypeSubstitutions, r as parseTypeText } from "../typification-parser-BBVx1RxP.js";
|
|
13
13
|
import { n as TypificationNodeData, t as TypificationGraph } from "../typification-graph-6HcZ-rKH.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as AstNode } from "../../ast-C8sIpKdL.js";
|
|
2
2
|
import { g as TypeClass } from "../../typification-Dk-fisgO.js";
|
|
3
|
-
import { t as ErrorReporter } from "../../error-
|
|
3
|
+
import { t as ErrorReporter } from "../../error-CZXO5Y6a.js";
|
|
4
4
|
|
|
5
5
|
//#region src/rslang/parser/syntax-errors.d.ts
|
|
6
6
|
/** Options for syntax error extraction. */
|
|
@@ -11,6 +11,14 @@ import "./parser.terms.js";
|
|
|
11
11
|
*/
|
|
12
12
|
/** Extracts syntax errors from an AST. */
|
|
13
13
|
function extractSyntaxErrors(ast, expression, reporter, annotateErrors = false, options) {
|
|
14
|
+
const forbiddenErrors = extractForbiddenCharacterErrors(expression);
|
|
15
|
+
if (forbiddenErrors.length > 0) {
|
|
16
|
+
for (const error of forbiddenErrors) {
|
|
17
|
+
reporter(error);
|
|
18
|
+
if (annotateErrors) annotateError(ast, error.code, error.params);
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
14
22
|
const collected = [];
|
|
15
23
|
const annotationTargets = /* @__PURE__ */ new Map();
|
|
16
24
|
const collect = (error, target) => {
|
|
@@ -174,6 +182,42 @@ function deduplicateErrors(errors) {
|
|
|
174
182
|
function rangesOverlap(a, b) {
|
|
175
183
|
return a.from < b.to && b.from < a.to;
|
|
176
184
|
}
|
|
185
|
+
const ALLOWED_EXPRESSION_CHARS = buildAllowedExpressionChars();
|
|
186
|
+
function buildAllowedExpressionChars() {
|
|
187
|
+
const chars = /* @__PURE__ */ new Set();
|
|
188
|
+
for (const chunk of [
|
|
189
|
+
"0123456789",
|
|
190
|
+
"abcdefghijklmnopqrstuvwxyz",
|
|
191
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
192
|
+
"_",
|
|
193
|
+
"∅¬∀∃⇔⇒∨&ℬ+-*∪\\∆∩×∈∉⊆⊄⊂<>≥≤≠=,:;|[]{}()"
|
|
194
|
+
]) for (const symbol of chunk) chars.add(symbol);
|
|
195
|
+
for (let codePoint = 945; codePoint <= 969; codePoint++) chars.add(String.fromCodePoint(codePoint));
|
|
196
|
+
return chars;
|
|
197
|
+
}
|
|
198
|
+
function isAllowedExpressionChar(symbol) {
|
|
199
|
+
return /\s/u.test(symbol) || ALLOWED_EXPRESSION_CHARS.has(symbol);
|
|
200
|
+
}
|
|
201
|
+
function extractForbiddenCharacterErrors(expression) {
|
|
202
|
+
const errors = [];
|
|
203
|
+
let pos = 0;
|
|
204
|
+
while (pos < expression.length) {
|
|
205
|
+
const symbol = expression[pos];
|
|
206
|
+
if (isAllowedExpressionChar(symbol)) {
|
|
207
|
+
pos++;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const start = pos;
|
|
211
|
+
while (pos < expression.length && !isAllowedExpressionChar(expression[pos])) pos++;
|
|
212
|
+
errors.push({
|
|
213
|
+
code: RSErrorCode.forbiddenCharacter,
|
|
214
|
+
from: start,
|
|
215
|
+
to: pos,
|
|
216
|
+
params: [expression.slice(start, pos)]
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
return errors;
|
|
220
|
+
}
|
|
177
221
|
function extractBracketErrors(expression) {
|
|
178
222
|
const stack = [];
|
|
179
223
|
for (let pos = 0; pos < expression.length; pos++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax-errors.js","names":["TypeClassEnum"],"sources":["../../../src/rslang/parser/syntax-errors.ts"],"sourcesContent":["/**\n * Module: Syntactic errors reporting.\n */\n\nimport { type AstNode, visitAstDFS } from '../../parsing';\nimport { annotateError } from '../ast-annotations';\nimport { type ErrorReporter, RSErrorCode, type RSErrorDescription } from '../error';\nimport { type TypeClass, TypeClass as TypeClassEnum } from '../semantic/typification';\n\nimport { Arguments, Filter, Function, Function_decl, Predicate, Variable } from './parser.terms';\nimport { TokenID } from './token';\n\n/** Options for syntax error extraction. */\nexport interface SyntaxErrorOptions {\n expected?: TypeClass;\n}\n\n/** Extracts syntax errors from an AST. */\nexport function extractSyntaxErrors(\n ast: AstNode,\n expression: string,\n reporter: ErrorReporter,\n annotateErrors: boolean = false,\n options?: SyntaxErrorOptions\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 if (bracketError !== null) {\n collect(bracketError, ast);\n }\n const hasBracketErrors = bracketError !== null;\n visitAstDFS(ast, node => extractInternal(node, expression, collect, hasBracketErrors, options));\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\n// ====== Internals =========\nfunction extractInternal(\n node: AstNode,\n expression: string,\n collect: (error: RSErrorDescription, target: AstNode) => void,\n ignoreUnknownErrors: boolean,\n options?: SyntaxErrorOptions\n) {\n if (node.typeID !== TokenID.ERROR) {\n return;\n }\n\n function emit(target: AstNode, code: RSErrorCode, params?: readonly string[]) {\n collect({ code: code, from: target.from, to: target.to, params }, target);\n }\n\n const classified = classifyParseError(node, expression, options);\n if (classified !== null) {\n collect(classified, node);\n return;\n }\n\n const parent = node.parent;\n if (parent === null) {\n if (!ignoreUnknownErrors) {\n return emit(node, RSErrorCode.unknownSyntax);\n }\n return;\n }\n\n if (parent.typeID === Variable) {\n return emit(parent, RSErrorCode.expectedLocal);\n }\n\n if (!ignoreUnknownErrors) {\n emit(node.from === node.to ? parent : node, RSErrorCode.unknownSyntax);\n }\n}\n\nfunction classifyParseError(\n node: AstNode,\n expression: string,\n options?: SyntaxErrorOptions\n): RSErrorDescription | null {\n const incompleteFunctionDecl = detectIncompleteFunctionDecl(node, expression, options?.expected);\n if (incompleteFunctionDecl !== null) {\n return incompleteFunctionDecl;\n }\n\n const filterParen = detectFilterParenMismatch(node, expression);\n if (filterParen !== null) {\n return filterParen;\n }\n\n return detectGlobalFuncWithoutArgs(node, expression);\n}\n\nfunction detectIncompleteFunctionDecl(\n node: AstNode,\n expression: string,\n expected?: TypeClass\n): RSErrorDescription | null {\n const funcDecl = findAncestor(node, isFunctionDeclNode);\n if (funcDecl === null) {\n return null;\n }\n\n const bodyChild = funcDecl.children[funcDecl.children.length - 1];\n if (bodyChild?.typeID !== TokenID.ERROR || node !== bodyChild) {\n return null;\n }\n\n const argsNode = funcDecl.children.find(child => child.typeID === Arguments || child.typeID === TokenID.NT_ARGUMENTS);\n if (argsNode === undefined || subtreeHasError(argsNode)) {\n return null;\n }\n\n if (expression.slice(funcDecl.to).trim().length > 0) {\n return null;\n }\n\n return {\n code: incompleteFormalExpressionCode(expected),\n from: bodyChild.from,\n to: bodyChild.to\n };\n}\n\nfunction incompleteFormalExpressionCode(expected?: TypeClass): 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 subtreeHasError(node: AstNode): boolean {\n if (node.typeID === TokenID.ERROR) {\n return true;\n }\n return node.children.some(subtreeHasError);\n}\n\nfunction detectFilterParenMismatch(node: AstNode, expression: string): RSErrorDescription | null {\n const filterNode = findAncestor(node, isFilterNode) ?? findRelatedNode(node, isFilterNode);\n if (filterNode === null) {\n return null;\n }\n\n const nextChar = expression[filterNode.to];\n if (nextChar === '(') {\n return {\n code: RSErrorCode.invalidFilterSyntax,\n from: filterNode.from,\n to: filterNode.to + 1\n };\n }\n return null;\n}\n\nfunction detectGlobalFuncWithoutArgs(node: AstNode, expression: string): RSErrorDescription | null {\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 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\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 // Function with nothing (or only whitespace) after it is genuinely called without arguments.\n if (/^\\s*$/.test(rest)) {\n return withoutArgs;\n }\n\n // Anything other than a bracketed argument form (e.g. parentheses or braces) is malformed call\n // syntax: defer to the bracket/syntax error handling instead of reporting a missing-arguments error.\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) {\n const inner = rest.slice(openBracket[0].length, closeIdx).trim();\n if (inner.length === 0) {\n return withoutArgs;\n }\n }\n\n return null;\n}\n\nfunction 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\nfunction isFunctionDeclNode(node: AstNode): boolean {\n return node.typeID === Function_decl || node.typeID === TokenID.NT_FUNC_DEFINITION;\n}\n\nfunction isFunctionNode(node: AstNode): boolean {\n return node.typeID === Function || node.typeID === TokenID.ID_FUNCTION;\n}\n\nfunction isPredicateNode(node: AstNode): boolean {\n return node.typeID === Predicate || node.typeID === TokenID.ID_PREDICATE;\n}\n\nfunction isFilterNode(node: AstNode): boolean {\n return node.typeID === Filter || node.typeID === TokenID.FILTER;\n}\n\nfunction findMatchingCloseBracket(expression: string, openPos: number): number {\n const open = expression[openPos];\n if (open !== '[') {\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\nfunction 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 return result.filter(\n error => error.code !== RSErrorCode.unknownSyntax || !specific.some(item => rangesOverlap(error, item))\n );\n}\n\nfunction rangesOverlap(a: RSErrorDescription, b: RSErrorDescription): boolean {\n return a.from < b.to && b.from < a.to;\n}\n\ntype OpenBracket = '(' | '[' | '{';\ntype CloseBracket = ')' | ']' | '}';\n\ninterface BracketFrame {\n bracket: OpenBracket;\n index: number;\n}\n\nfunction 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\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"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,oBACd,KACA,YACA,UACA,iBAA0B,OAC1B,SACA;CACA,MAAM,YAAkC,CAAC;CACzC,MAAM,oCAAoB,IAAI,IAAiC;CAC/D,MAAM,WAAW,OAA2B,WAAqB;EAC/D,UAAU,KAAK,KAAK;EACpB,IAAI,WAAW,QACb,kBAAkB,IAAI,OAAO,MAAM;CAEvC;CAEA,MAAM,eAAe,qBAAqB,UAAU;CACpD,IAAI,iBAAiB,MACnB,QAAQ,cAAc,GAAG;CAE3B,MAAM,mBAAmB,iBAAiB;CAC1C,YAAY,MAAK,SAAQ,gBAAgB,MAAM,YAAY,SAAS,kBAAkB,OAAO,CAAC;CAE9F,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;AAGA,SAAS,gBACP,MACA,YACA,SACA,qBACA,SACA;CACA,IAAI,KAAK,WAAW,QAAQ,OAC1B;CAGF,SAAS,KAAK,QAAiB,MAAmB,QAA4B;EAC5E,QAAQ;GAAQ;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":3,"file":"syntax-errors.js","names":["TypeClassEnum"],"sources":["../../../src/rslang/parser/syntax-errors.ts"],"sourcesContent":["/**\n * Module: Syntactic errors reporting.\n */\n\nimport { type AstNode, visitAstDFS } from '../../parsing';\nimport { annotateError } from '../ast-annotations';\nimport { type ErrorReporter, RSErrorCode, type RSErrorDescription } from '../error';\nimport { type TypeClass, TypeClass as TypeClassEnum } from '../semantic/typification';\n\nimport { Arguments, Filter, Function, Function_decl, Predicate, Variable } from './parser.terms';\nimport { TokenID } from './token';\n\n/** Options for syntax error extraction. */\nexport interface SyntaxErrorOptions {\n expected?: TypeClass;\n}\n\n/** Extracts syntax errors from an AST. */\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 if (bracketError !== null) {\n collect(bracketError, ast);\n }\n const hasBracketErrors = bracketError !== null;\n visitAstDFS(ast, node => extractInternal(node, expression, collect, hasBracketErrors, options));\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\n// ====== Internals =========\nfunction extractInternal(\n node: AstNode,\n expression: string,\n collect: (error: RSErrorDescription, target: AstNode) => void,\n ignoreUnknownErrors: boolean,\n options?: SyntaxErrorOptions\n) {\n if (node.typeID !== TokenID.ERROR) {\n return;\n }\n\n function emit(target: AstNode, code: RSErrorCode, params?: readonly string[]) {\n collect({ code: code, from: target.from, to: target.to, params }, target);\n }\n\n const classified = classifyParseError(node, expression, options);\n if (classified !== null) {\n collect(classified, node);\n return;\n }\n\n const parent = node.parent;\n if (parent === null) {\n if (!ignoreUnknownErrors) {\n return emit(node, RSErrorCode.unknownSyntax);\n }\n return;\n }\n\n if (parent.typeID === Variable) {\n return emit(parent, RSErrorCode.expectedLocal);\n }\n\n if (!ignoreUnknownErrors) {\n emit(node.from === node.to ? parent : node, RSErrorCode.unknownSyntax);\n }\n}\n\nfunction classifyParseError(\n node: AstNode,\n expression: string,\n options?: SyntaxErrorOptions\n): RSErrorDescription | null {\n const incompleteFunctionDecl = detectIncompleteFunctionDecl(node, expression, options?.expected);\n if (incompleteFunctionDecl !== null) {\n return incompleteFunctionDecl;\n }\n\n const filterParen = detectFilterParenMismatch(node, expression);\n if (filterParen !== null) {\n return filterParen;\n }\n\n return detectGlobalFuncWithoutArgs(node, expression);\n}\n\nfunction detectIncompleteFunctionDecl(\n node: AstNode,\n expression: string,\n expected?: TypeClass\n): RSErrorDescription | null {\n const funcDecl = findAncestor(node, isFunctionDeclNode);\n if (funcDecl === null) {\n return null;\n }\n\n const bodyChild = funcDecl.children[funcDecl.children.length - 1];\n if (bodyChild?.typeID !== TokenID.ERROR || node !== bodyChild) {\n return null;\n }\n\n const argsNode = funcDecl.children.find(child => child.typeID === Arguments || child.typeID === TokenID.NT_ARGUMENTS);\n if (argsNode === undefined || subtreeHasError(argsNode)) {\n return null;\n }\n\n if (expression.slice(funcDecl.to).trim().length > 0) {\n return null;\n }\n\n return {\n code: incompleteFormalExpressionCode(expected),\n from: bodyChild.from,\n to: bodyChild.to\n };\n}\n\nfunction incompleteFormalExpressionCode(expected?: TypeClass): 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 subtreeHasError(node: AstNode): boolean {\n if (node.typeID === TokenID.ERROR) {\n return true;\n }\n return node.children.some(subtreeHasError);\n}\n\nfunction detectFilterParenMismatch(node: AstNode, expression: string): RSErrorDescription | null {\n const filterNode = findAncestor(node, isFilterNode) ?? findRelatedNode(node, isFilterNode);\n if (filterNode === null) {\n return null;\n }\n\n const nextChar = expression[filterNode.to];\n if (nextChar === '(') {\n return {\n code: RSErrorCode.invalidFilterSyntax,\n from: filterNode.from,\n to: filterNode.to + 1\n };\n }\n return null;\n}\n\nfunction detectGlobalFuncWithoutArgs(node: AstNode, expression: string): RSErrorDescription | null {\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 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\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 // Function with nothing (or only whitespace) after it is genuinely called without arguments.\n if (/^\\s*$/.test(rest)) {\n return withoutArgs;\n }\n\n // Anything other than a bracketed argument form (e.g. parentheses or braces) is malformed call\n // syntax: defer to the bracket/syntax error handling instead of reporting a missing-arguments error.\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) {\n const inner = rest.slice(openBracket[0].length, closeIdx).trim();\n if (inner.length === 0) {\n return withoutArgs;\n }\n }\n\n return null;\n}\n\nfunction 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\nfunction isFunctionDeclNode(node: AstNode): boolean {\n return node.typeID === Function_decl || node.typeID === TokenID.NT_FUNC_DEFINITION;\n}\n\nfunction isFunctionNode(node: AstNode): boolean {\n return node.typeID === Function || node.typeID === TokenID.ID_FUNCTION;\n}\n\nfunction isPredicateNode(node: AstNode): boolean {\n return node.typeID === Predicate || node.typeID === TokenID.ID_PREDICATE;\n}\n\nfunction isFilterNode(node: AstNode): boolean {\n return node.typeID === Filter || node.typeID === TokenID.FILTER;\n}\n\nfunction findMatchingCloseBracket(expression: string, openPos: number): number {\n const open = expression[openPos];\n if (open !== '[') {\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\nfunction 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 return result.filter(\n error => error.code !== RSErrorCode.unknownSyntax || !specific.some(item => rangesOverlap(error, item))\n );\n}\n\nfunction rangesOverlap(a: RSErrorDescription, b: RSErrorDescription): boolean {\n return a.from < b.to && b.from < a.to;\n}\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\nfunction 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\nfunction 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\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"],"mappings":";;;;;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,aAAa,GACjC,OAAO;CAGT,OAAO,eAAe,aAAa;AACrC;AAEA,SAAS,uBAAuB,YAAoB,SAAyB;CAC3E,IAAI,WAAW,aAAa,KAC1B,OAAO;CAGT,MAAM,QAAuB,CAAC;CAC9B,KAAK,IAAI,QAAQ,SAAS,QAAQ,WAAW,QAAQ,SAAS;EAC5D,MAAM,SAAS,WAAW;EAC1B,IAAI,cAAc,MAAM,GAAG;GACzB,MAAM,KAAK,MAAM;GACjB;EACF;EACA,IAAI,CAAC,eAAe,MAAM,GACxB;EAEF,MAAM,MAAM,MAAM,IAAI;EACtB,IAAI,QAAQ,UAAa,QAAQ,YAAY,MAAM,GACjD,OAAO;EAET,IAAI,MAAM,WAAW,GACnB,OAAO;CAEX;CAEA,OAAO;AACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RSLangAnalyzer, i as AnalysisOptions, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "../../analyzer-
|
|
1
|
+
import { a as RSLangAnalyzer, i as AnalysisOptions, n as AnalysisFast, r as AnalysisFull, t as AnalysisBase } from "../../analyzer-camCAEkQ.js";
|
|
2
2
|
export { AnalysisBase, AnalysisFast, AnalysisFull, AnalysisOptions, RSLangAnalyzer };
|
|
@@ -4,6 +4,7 @@ import { buildTree } from "../../parsing/ast.js";
|
|
|
4
4
|
import "../../parsing/index.js";
|
|
5
5
|
import { TokenID } from "../parser/token.js";
|
|
6
6
|
import { TypeID, basic, bool, constant, debool } from "./typification.js";
|
|
7
|
+
import { labelType } from "../labels.js";
|
|
7
8
|
import { parser } from "../parser/parser.js";
|
|
8
9
|
import { normalizeAST } from "../parser/normalize.js";
|
|
9
10
|
import { extractSyntaxErrors } from "../parser/syntax-errors.js";
|
|
@@ -144,12 +145,14 @@ var RSLangAnalyzer = class {
|
|
|
144
145
|
};
|
|
145
146
|
}
|
|
146
147
|
if (options?.expected && getTypeClass(type.typeID) !== options.expected) {
|
|
148
|
+
const errorParams = [String(options.expected), labelType(type)];
|
|
147
149
|
reporter({
|
|
148
150
|
code: RSErrorCode.expectedType,
|
|
149
151
|
from: ast.from,
|
|
150
|
-
to: ast.to
|
|
152
|
+
to: ast.to,
|
|
153
|
+
params: errorParams
|
|
151
154
|
});
|
|
152
|
-
if (options?.annotateErrors) annotateError(ast, RSErrorCode.expectedType);
|
|
155
|
+
if (options?.annotateErrors) annotateError(ast, RSErrorCode.expectedType, errorParams);
|
|
153
156
|
return {
|
|
154
157
|
success: false,
|
|
155
158
|
type: null,
|