@stevenvo780/st-lang 0.3.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/LICENSE +21 -0
- package/bin/st +3 -0
- package/dist/api.d.ts +157 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +232 -0
- package/dist/api.js.map +1 -0
- package/dist/ast/nodes.d.ts +97 -0
- package/dist/ast/nodes.d.ts.map +1 -0
- package/dist/ast/nodes.js +6 -0
- package/dist/ast/nodes.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +278 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/lexer/lexer.d.ts +25 -0
- package/dist/lexer/lexer.d.ts.map +1 -0
- package/dist/lexer/lexer.js +358 -0
- package/dist/lexer/lexer.js.map +1 -0
- package/dist/lexer/tokens.d.ts +56 -0
- package/dist/lexer/tokens.d.ts.map +1 -0
- package/dist/lexer/tokens.js +85 -0
- package/dist/lexer/tokens.js.map +1 -0
- package/dist/parser/parser.d.ts +46 -0
- package/dist/parser/parser.d.ts.map +1 -0
- package/dist/parser/parser.js +415 -0
- package/dist/parser/parser.js.map +1 -0
- package/dist/profiles/classical/first-order.d.ts +13 -0
- package/dist/profiles/classical/first-order.d.ts.map +1 -0
- package/dist/profiles/classical/first-order.js +67 -0
- package/dist/profiles/classical/first-order.js.map +1 -0
- package/dist/profiles/classical/propositional.d.ts +16 -0
- package/dist/profiles/classical/propositional.d.ts.map +1 -0
- package/dist/profiles/classical/propositional.js +597 -0
- package/dist/profiles/classical/propositional.js.map +1 -0
- package/dist/profiles/interface.d.ts +11 -0
- package/dist/profiles/interface.d.ts.map +1 -0
- package/dist/profiles/interface.js +26 -0
- package/dist/profiles/interface.js.map +1 -0
- package/dist/profiles/modal/k.d.ts +13 -0
- package/dist/profiles/modal/k.d.ts.map +1 -0
- package/dist/profiles/modal/k.js +39 -0
- package/dist/profiles/modal/k.js.map +1 -0
- package/dist/profiles/paraconsistent/belnap.d.ts +13 -0
- package/dist/profiles/paraconsistent/belnap.d.ts.map +1 -0
- package/dist/profiles/paraconsistent/belnap.js +39 -0
- package/dist/profiles/paraconsistent/belnap.js.map +1 -0
- package/dist/protocol/handler.d.ts +17 -0
- package/dist/protocol/handler.d.ts.map +1 -0
- package/dist/protocol/handler.js +219 -0
- package/dist/protocol/handler.js.map +1 -0
- package/dist/repl/repl.d.ts +12 -0
- package/dist/repl/repl.d.ts.map +1 -0
- package/dist/repl/repl.js +237 -0
- package/dist/repl/repl.js.map +1 -0
- package/dist/runtime/interpreter.d.ts +41 -0
- package/dist/runtime/interpreter.d.ts.map +1 -0
- package/dist/runtime/interpreter.js +355 -0
- package/dist/runtime/interpreter.js.map +1 -0
- package/dist/tests/cli.test.d.ts +2 -0
- package/dist/tests/cli.test.d.ts.map +1 -0
- package/dist/tests/cli.test.js +184 -0
- package/dist/tests/cli.test.js.map +1 -0
- package/dist/tests/core.test.d.ts +2 -0
- package/dist/tests/core.test.d.ts.map +1 -0
- package/dist/tests/core.test.js +220 -0
- package/dist/tests/core.test.js.map +1 -0
- package/dist/tests/parser.test.d.ts +2 -0
- package/dist/tests/parser.test.d.ts.map +1 -0
- package/dist/tests/parser.test.js +180 -0
- package/dist/tests/parser.test.js.map +1 -0
- package/dist/tests/runner.d.ts +6 -0
- package/dist/tests/runner.d.ts.map +1 -0
- package/dist/tests/runner.js +69 -0
- package/dist/tests/runner.js.map +1 -0
- package/dist/text-layer/compiler.d.ts +19 -0
- package/dist/text-layer/compiler.d.ts.map +1 -0
- package/dist/text-layer/compiler.js +151 -0
- package/dist/text-layer/compiler.js.map +1 -0
- package/dist/types/index.d.ts +178 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/profiles/interface.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,6DAA6D;AAC7D,+DAA+D;;;AAM/D,8BAA8B;AAC9B,MAAa,eAAe;IAClB,QAAQ,GAA8B,IAAI,GAAG,EAAE,CAAC;IAExD,QAAQ,CAAC,OAAqB;QAC5B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACF;AAlBD,0CAkBC;AAED,mBAAmB;AACN,QAAA,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Formula, Diagnostic, RunResult, Theory, LogicProfile } from '../../types';
|
|
2
|
+
export declare class ModalK implements LogicProfile {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
checkWellFormed(formula: Formula): Diagnostic[];
|
|
6
|
+
checkValid(formula: Formula): RunResult;
|
|
7
|
+
checkSatisfiable(formula: Formula): RunResult;
|
|
8
|
+
prove(goal: Formula, theory: Theory): RunResult;
|
|
9
|
+
derive(goal: Formula, premises: string[], theory: Theory): RunResult;
|
|
10
|
+
countermodel(formula: Formula): RunResult;
|
|
11
|
+
explain(formula: Formula): RunResult;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=k.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"k.d.ts","sourceRoot":"","sources":["../../../src/profiles/modal/k.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EACrD,MAAM,aAAa,CAAC;AAGrB,qBAAa,MAAO,YAAW,YAAY;IACzC,IAAI,SAAa;IACjB,WAAW,SAAgE;IAE3E,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE;IAI/C,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IASvC,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAI7C,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAI/C,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpE,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAIzC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;CAGrC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Modal K — Stub (contrato definido)
|
|
4
|
+
// ============================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ModalK = void 0;
|
|
7
|
+
const propositional_1 = require("../classical/propositional");
|
|
8
|
+
class ModalK {
|
|
9
|
+
name = 'modal.k';
|
|
10
|
+
description = 'Logica modal K (stub — contrato definido, motor pendiente)';
|
|
11
|
+
checkWellFormed(formula) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
checkValid(formula) {
|
|
15
|
+
return {
|
|
16
|
+
status: 'unknown',
|
|
17
|
+
output: `[modal.k] Motor no implementado aun. Formula: ${(0, propositional_1.formulaToString)(formula)}`,
|
|
18
|
+
diagnostics: [{ severity: 'warning', message: 'Perfil modal.k aun no tiene motor completo' }],
|
|
19
|
+
formula,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
checkSatisfiable(formula) {
|
|
23
|
+
return { status: 'unknown', output: '[modal.k] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula };
|
|
24
|
+
}
|
|
25
|
+
prove(goal, theory) {
|
|
26
|
+
return { status: 'unknown', output: '[modal.k] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula: goal };
|
|
27
|
+
}
|
|
28
|
+
derive(goal, premises, theory) {
|
|
29
|
+
return { status: 'unknown', output: '[modal.k] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula: goal };
|
|
30
|
+
}
|
|
31
|
+
countermodel(formula) {
|
|
32
|
+
return { status: 'unknown', output: '[modal.k] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula };
|
|
33
|
+
}
|
|
34
|
+
explain(formula) {
|
|
35
|
+
return { status: 'unknown', output: '[modal.k] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ModalK = ModalK;
|
|
39
|
+
//# sourceMappingURL=k.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"k.js","sourceRoot":"","sources":["../../../src/profiles/modal/k.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,wCAAwC;AACxC,+DAA+D;;;AAK/D,8DAA6D;AAE7D,MAAa,MAAM;IACjB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAAG,4DAA4D,CAAC;IAE3E,eAAe,CAAC,OAAgB;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,OAAgB;QACzB,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,iDAAiD,IAAA,+BAAe,EAAC,OAAO,CAAC,EAAE;YACnF,WAAW,EAAE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F;AApCD,wBAoCC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Formula, Diagnostic, RunResult, Theory, LogicProfile } from '../../types';
|
|
2
|
+
export declare class ParaconsistentBelnap implements LogicProfile {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
checkWellFormed(formula: Formula): Diagnostic[];
|
|
6
|
+
checkValid(formula: Formula): RunResult;
|
|
7
|
+
checkSatisfiable(formula: Formula): RunResult;
|
|
8
|
+
prove(goal: Formula, theory: Theory): RunResult;
|
|
9
|
+
derive(goal: Formula, premises: string[], theory: Theory): RunResult;
|
|
10
|
+
countermodel(formula: Formula): RunResult;
|
|
11
|
+
explain(formula: Formula): RunResult;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=belnap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"belnap.d.ts","sourceRoot":"","sources":["../../../src/profiles/paraconsistent/belnap.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EACrD,MAAM,aAAa,CAAC;AAGrB,qBAAa,oBAAqB,YAAW,YAAY;IACvD,IAAI,SAA2B;IAC/B,WAAW,SAAoF;IAE/F,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,EAAE;IAI/C,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IASvC,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAI7C,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAI/C,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS;IAIpE,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;IAIzC,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS;CAGrC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Paraconsistent Belnap — Stub (contrato definido)
|
|
4
|
+
// ============================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ParaconsistentBelnap = void 0;
|
|
7
|
+
const propositional_1 = require("../classical/propositional");
|
|
8
|
+
class ParaconsistentBelnap {
|
|
9
|
+
name = 'paraconsistent.belnap';
|
|
10
|
+
description = 'Logica paraconsistente Belnap-Dunn (stub — contrato definido, motor pendiente)';
|
|
11
|
+
checkWellFormed(formula) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
checkValid(formula) {
|
|
15
|
+
return {
|
|
16
|
+
status: 'unknown',
|
|
17
|
+
output: `[paraconsistent.belnap] Motor no implementado aun. Formula: ${(0, propositional_1.formulaToString)(formula)}`,
|
|
18
|
+
diagnostics: [{ severity: 'warning', message: 'Perfil paraconsistent.belnap aun no tiene motor completo' }],
|
|
19
|
+
formula,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
checkSatisfiable(formula) {
|
|
23
|
+
return { status: 'unknown', output: '[paraconsistent.belnap] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula };
|
|
24
|
+
}
|
|
25
|
+
prove(goal, theory) {
|
|
26
|
+
return { status: 'unknown', output: '[paraconsistent.belnap] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula: goal };
|
|
27
|
+
}
|
|
28
|
+
derive(goal, premises, theory) {
|
|
29
|
+
return { status: 'unknown', output: '[paraconsistent.belnap] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula: goal };
|
|
30
|
+
}
|
|
31
|
+
countermodel(formula) {
|
|
32
|
+
return { status: 'unknown', output: '[paraconsistent.belnap] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula };
|
|
33
|
+
}
|
|
34
|
+
explain(formula) {
|
|
35
|
+
return { status: 'unknown', output: '[paraconsistent.belnap] No implementado', diagnostics: [{ severity: 'warning', message: 'Motor no implementado' }], formula };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ParaconsistentBelnap = ParaconsistentBelnap;
|
|
39
|
+
//# sourceMappingURL=belnap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"belnap.js","sourceRoot":"","sources":["../../../src/profiles/paraconsistent/belnap.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,sDAAsD;AACtD,+DAA+D;;;AAK/D,8DAA6D;AAE7D,MAAa,oBAAoB;IAC/B,IAAI,GAAG,uBAAuB,CAAC;IAC/B,WAAW,GAAG,gFAAgF,CAAC;IAE/F,eAAe,CAAC,OAAgB;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,OAAgB;QACzB,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,MAAM,EAAE,+DAA+D,IAAA,+BAAe,EAAC,OAAO,CAAC,EAAE;YACjG,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,0DAA0D,EAAE,CAAC;YAC3G,OAAO;SACR,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,OAAgB;QAC/B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,yCAAyC,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;IACrK,CAAC;IAED,KAAK,CAAC,IAAa,EAAE,MAAc;QACjC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,yCAAyC,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3K,CAAC;IAED,MAAM,CAAC,IAAa,EAAE,QAAkB,EAAE,MAAc;QACtD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,yCAAyC,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3K,CAAC;IAED,YAAY,CAAC,OAAgB;QAC3B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,yCAAyC,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;IACrK,CAAC;IAED,OAAO,CAAC,OAAgB;QACtB,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,yCAAyC,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC;IACrK,CAAC;CACF;AApCD,oDAoCC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProtocolRequest, ProtocolResponse } from '../types';
|
|
2
|
+
export declare class ProtocolHandler {
|
|
3
|
+
private interpreter;
|
|
4
|
+
constructor();
|
|
5
|
+
handle(request: ProtocolRequest): ProtocolResponse;
|
|
6
|
+
private handleParse;
|
|
7
|
+
private handleCheck;
|
|
8
|
+
private handleRun;
|
|
9
|
+
private handleHover;
|
|
10
|
+
private handleSymbols;
|
|
11
|
+
private handleGotoDefinition;
|
|
12
|
+
private handleCompletion;
|
|
13
|
+
private handleRender;
|
|
14
|
+
private getStatementHoverInfo;
|
|
15
|
+
private renderOutput;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/protocol/handler.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,eAAe,EAAE,gBAAgB,EAElC,MAAM,UAAU,CAAC;AAMlB,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAc;;IAMjC,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,gBAAgB;IA0BlD,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,WAAW;IAsBnB,OAAO,CAAC,aAAa;IA4CrB,OAAO,CAAC,oBAAoB;IAgB5B,OAAO,CAAC,gBAAgB;IAuBxB,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,qBAAqB;IAa7B,OAAO,CAAC,YAAY;CAoBrB"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST Editor Protocol — Handler
|
|
4
|
+
// ============================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProtocolHandler = void 0;
|
|
7
|
+
const parser_1 = require("../parser/parser");
|
|
8
|
+
const interpreter_1 = require("../runtime/interpreter");
|
|
9
|
+
const propositional_1 = require("../profiles/classical/propositional");
|
|
10
|
+
class ProtocolHandler {
|
|
11
|
+
interpreter;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.interpreter = new interpreter_1.Interpreter();
|
|
14
|
+
}
|
|
15
|
+
handle(request) {
|
|
16
|
+
switch (request.method) {
|
|
17
|
+
case 'parse':
|
|
18
|
+
return this.handleParse(request);
|
|
19
|
+
case 'check':
|
|
20
|
+
return this.handleCheck(request);
|
|
21
|
+
case 'run':
|
|
22
|
+
return this.handleRun(request);
|
|
23
|
+
case 'hover':
|
|
24
|
+
return this.handleHover(request);
|
|
25
|
+
case 'symbols':
|
|
26
|
+
return this.handleSymbols(request);
|
|
27
|
+
case 'goto_definition':
|
|
28
|
+
return this.handleGotoDefinition(request);
|
|
29
|
+
case 'completion':
|
|
30
|
+
return this.handleCompletion(request);
|
|
31
|
+
case 'render':
|
|
32
|
+
return this.handleRender(request);
|
|
33
|
+
default:
|
|
34
|
+
return {
|
|
35
|
+
id: request.id,
|
|
36
|
+
error: { code: -1, message: `Metodo desconocido: ${request.method}` },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
handleParse(request) {
|
|
41
|
+
const source = request.params.source;
|
|
42
|
+
const file = request.params.file || '<stdin>';
|
|
43
|
+
const parser = new parser_1.Parser(file);
|
|
44
|
+
const program = parser.parse(source);
|
|
45
|
+
return {
|
|
46
|
+
id: request.id,
|
|
47
|
+
result: { statements: program.statements.length, file: program.file },
|
|
48
|
+
diagnostics: parser.diagnostics,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
handleCheck(request) {
|
|
52
|
+
const source = request.params.source;
|
|
53
|
+
const file = request.params.file || '<stdin>';
|
|
54
|
+
const parser = new parser_1.Parser(file);
|
|
55
|
+
const program = parser.parse(source);
|
|
56
|
+
const diagnostics = [...parser.diagnostics];
|
|
57
|
+
// Solo chequear sintaxis y bien-formación
|
|
58
|
+
if (diagnostics.length === 0) {
|
|
59
|
+
diagnostics.push({
|
|
60
|
+
severity: 'info',
|
|
61
|
+
message: `Archivo parseado correctamente: ${program.statements.length} statements`,
|
|
62
|
+
file,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
id: request.id,
|
|
67
|
+
result: { valid: diagnostics.filter(d => d.severity === 'error').length === 0 },
|
|
68
|
+
diagnostics,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
handleRun(request) {
|
|
72
|
+
const source = request.params.source;
|
|
73
|
+
const file = request.params.file || '<stdin>';
|
|
74
|
+
const output = this.interpreter.execute(source, file);
|
|
75
|
+
return {
|
|
76
|
+
id: request.id,
|
|
77
|
+
result: output,
|
|
78
|
+
diagnostics: output.diagnostics,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
handleHover(request) {
|
|
82
|
+
const source = request.params.source;
|
|
83
|
+
const line = request.params.line;
|
|
84
|
+
const column = request.params.column;
|
|
85
|
+
const file = request.params.file || '<stdin>';
|
|
86
|
+
const parser = new parser_1.Parser(file);
|
|
87
|
+
const program = parser.parse(source);
|
|
88
|
+
// Buscar statement en la posición
|
|
89
|
+
for (const stmt of program.statements) {
|
|
90
|
+
if (stmt.source.line === line) {
|
|
91
|
+
const info = this.getStatementHoverInfo(stmt);
|
|
92
|
+
if (info) {
|
|
93
|
+
return { id: request.id, result: info };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { id: request.id, result: null };
|
|
98
|
+
}
|
|
99
|
+
handleSymbols(request) {
|
|
100
|
+
const source = request.params.source;
|
|
101
|
+
const file = request.params.file || '<stdin>';
|
|
102
|
+
const parser = new parser_1.Parser(file);
|
|
103
|
+
const program = parser.parse(source);
|
|
104
|
+
const symbols = [];
|
|
105
|
+
for (const stmt of program.statements) {
|
|
106
|
+
switch (stmt.kind) {
|
|
107
|
+
case 'axiom_decl':
|
|
108
|
+
symbols.push({
|
|
109
|
+
name: stmt.name,
|
|
110
|
+
kind: 'axiom',
|
|
111
|
+
location: stmt.source,
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
case 'theorem_decl':
|
|
115
|
+
symbols.push({
|
|
116
|
+
name: stmt.name,
|
|
117
|
+
kind: 'theorem',
|
|
118
|
+
location: stmt.source,
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
case 'claim_decl':
|
|
122
|
+
symbols.push({
|
|
123
|
+
name: stmt.name,
|
|
124
|
+
kind: 'claim',
|
|
125
|
+
location: stmt.source,
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
case 'let_decl':
|
|
129
|
+
symbols.push({
|
|
130
|
+
name: stmt.name,
|
|
131
|
+
kind: stmt.letType === 'passage' ? 'passage' : 'formula',
|
|
132
|
+
location: stmt.source,
|
|
133
|
+
});
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { id: request.id, result: symbols };
|
|
138
|
+
}
|
|
139
|
+
handleGotoDefinition(request) {
|
|
140
|
+
const source = request.params.source;
|
|
141
|
+
const name = request.params.name;
|
|
142
|
+
const file = request.params.file || '<stdin>';
|
|
143
|
+
const parser = new parser_1.Parser(file);
|
|
144
|
+
const program = parser.parse(source);
|
|
145
|
+
for (const stmt of program.statements) {
|
|
146
|
+
if ('name' in stmt && stmt.name === name) {
|
|
147
|
+
return { id: request.id, result: stmt.source };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return { id: request.id, result: null };
|
|
151
|
+
}
|
|
152
|
+
handleCompletion(request) {
|
|
153
|
+
const items = [
|
|
154
|
+
{ label: 'logic', kind: 'keyword', detail: 'Declarar perfil logico', insertText: 'logic ' },
|
|
155
|
+
{ label: 'axiom', kind: 'keyword', detail: 'Declarar axioma', insertText: 'axiom ${1:name} = ${2:formula}' },
|
|
156
|
+
{ label: 'theorem', kind: 'keyword', detail: 'Declarar teorema', insertText: 'theorem ${1:name} = ${2:formula}' },
|
|
157
|
+
{ label: 'derive', kind: 'keyword', detail: 'Derivar formula', insertText: 'derive ${1:formula} from {${2:premises}}' },
|
|
158
|
+
{ label: 'check valid', kind: 'keyword', detail: 'Verificar validez', insertText: 'check valid ${1:formula}' },
|
|
159
|
+
{ label: 'check satisfiable', kind: 'keyword', detail: 'Verificar satisfacibilidad', insertText: 'check satisfiable ${1:formula}' },
|
|
160
|
+
{ label: 'prove', kind: 'keyword', detail: 'Probar formula', insertText: 'prove ${1:formula} from {${2:premises}}' },
|
|
161
|
+
{ label: 'countermodel', kind: 'keyword', detail: 'Buscar contramodelo', insertText: 'countermodel ${1:formula}' },
|
|
162
|
+
{ label: 'truth_table', kind: 'keyword', detail: 'Tabla de verdad', insertText: 'truth_table ${1:formula}' },
|
|
163
|
+
{ label: 'let', kind: 'keyword', detail: 'Declarar variable', insertText: 'let ${1:name} = ' },
|
|
164
|
+
{ label: 'passage', kind: 'keyword', detail: 'Declarar pasaje', insertText: 'passage([[${1:path}]])' },
|
|
165
|
+
{ label: 'formalize', kind: 'keyword', detail: 'Formalizar pasaje', insertText: 'formalize ${1:passage} as ${2:formula}' },
|
|
166
|
+
{ label: 'claim', kind: 'keyword', detail: 'Declarar claim', insertText: 'claim ${1:name} = ${2:value}' },
|
|
167
|
+
{ label: 'support', kind: 'keyword', detail: 'Registrar soporte', insertText: 'support ${1:claim} <- ${2:source}' },
|
|
168
|
+
{ label: 'confidence', kind: 'keyword', detail: 'Registrar confianza', insertText: 'confidence ${1:claim} = ${2:value}' },
|
|
169
|
+
{ label: 'context', kind: 'keyword', detail: 'Registrar contexto', insertText: 'context ${1:claim} = "${2:text}"' },
|
|
170
|
+
];
|
|
171
|
+
return { id: request.id, result: items };
|
|
172
|
+
}
|
|
173
|
+
handleRender(request) {
|
|
174
|
+
const source = request.params.source;
|
|
175
|
+
const format = request.params.format || 'markdown';
|
|
176
|
+
const file = request.params.file || '<stdin>';
|
|
177
|
+
const output = this.interpreter.execute(source, file);
|
|
178
|
+
const rendered = this.renderOutput(output, format);
|
|
179
|
+
return {
|
|
180
|
+
id: request.id,
|
|
181
|
+
result: { rendered, format },
|
|
182
|
+
diagnostics: output.diagnostics,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
getStatementHoverInfo(stmt) {
|
|
186
|
+
switch (stmt.kind) {
|
|
187
|
+
case 'axiom_decl':
|
|
188
|
+
return { content: `**Axioma** \`${stmt.name}\` = ${(0, propositional_1.formulaToString)(stmt.formula)}`, range: stmt.source };
|
|
189
|
+
case 'theorem_decl':
|
|
190
|
+
return { content: `**Teorema** \`${stmt.name}\` = ${(0, propositional_1.formulaToString)(stmt.formula)}`, range: stmt.source };
|
|
191
|
+
case 'claim_decl':
|
|
192
|
+
return { content: `**Claim** \`${stmt.name}\``, range: stmt.source };
|
|
193
|
+
default:
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
renderOutput(output, format) {
|
|
198
|
+
if (format === 'json') {
|
|
199
|
+
return JSON.stringify(output, null, 2);
|
|
200
|
+
}
|
|
201
|
+
// Default: markdown
|
|
202
|
+
let md = '';
|
|
203
|
+
if (output.stdout) {
|
|
204
|
+
md += output.stdout;
|
|
205
|
+
}
|
|
206
|
+
if (output.diagnostics && output.diagnostics.length > 0) {
|
|
207
|
+
md += '\n\n## Diagnosticos\n\n';
|
|
208
|
+
for (const d of output.diagnostics) {
|
|
209
|
+
md += `- **${d.severity}**: ${d.message}`;
|
|
210
|
+
if (d.line)
|
|
211
|
+
md += ` (linea ${d.line})`;
|
|
212
|
+
md += '\n';
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return md;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
exports.ProtocolHandler = ProtocolHandler;
|
|
219
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/protocol/handler.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,+BAA+B;AAC/B,+DAA+D;;;AAM/D,6CAA0C;AAC1C,wDAAqD;AAErD,uEAAsE;AAEtE,MAAa,eAAe;IAClB,WAAW,CAAc;IAEjC;QACE,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,OAAwB;QAC7B,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACnC,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;YACnC,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;YACjC,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAA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C,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxD,EAAE,IAAI,yBAAyB,CAAC;YAChC,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;gBACnC,EAAE,IAAI,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC1C,IAAI,CAAC,CAAC,IAAI;oBAAE,EAAE,IAAI,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC;gBACvC,EAAE,IAAI,IAAI,CAAC;YACb,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAxOD,0CAwOC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class REPL {
|
|
2
|
+
private interpreter;
|
|
3
|
+
private rl;
|
|
4
|
+
constructor();
|
|
5
|
+
start(): void;
|
|
6
|
+
private executeBuffer;
|
|
7
|
+
private handleMetaCommand;
|
|
8
|
+
private printHelp;
|
|
9
|
+
private printTheory;
|
|
10
|
+
private printClaims;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=repl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repl.d.ts","sourceRoot":"","sources":["../../src/repl/repl.ts"],"names":[],"mappings":"AASA,qBAAa,IAAI;IACf,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,EAAE,CAAmC;;IAM7C,KAAK,IAAI,IAAI;IAqDb,OAAO,CAAC,aAAa;IAgBrB,OAAO,CAAC,iBAAiB;IAoDzB,OAAO,CAAC,SAAS;IAyCjB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,WAAW;CAsBpB"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ============================================================
|
|
3
|
+
// ST REPL — Read-Eval-Print Loop interactivo
|
|
4
|
+
// ============================================================
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.REPL = void 0;
|
|
40
|
+
const readline = __importStar(require("readline"));
|
|
41
|
+
const interpreter_1 = require("../runtime/interpreter");
|
|
42
|
+
const propositional_1 = require("../profiles/classical/propositional");
|
|
43
|
+
const interface_1 = require("../profiles/interface");
|
|
44
|
+
class REPL {
|
|
45
|
+
interpreter;
|
|
46
|
+
rl = null;
|
|
47
|
+
constructor() {
|
|
48
|
+
this.interpreter = new interpreter_1.Interpreter();
|
|
49
|
+
}
|
|
50
|
+
start() {
|
|
51
|
+
this.rl = readline.createInterface({
|
|
52
|
+
input: process.stdin,
|
|
53
|
+
output: process.stdout,
|
|
54
|
+
prompt: 'st> ',
|
|
55
|
+
terminal: true,
|
|
56
|
+
});
|
|
57
|
+
console.log('ST REPL v0.1.0');
|
|
58
|
+
console.log('Lenguaje ejecutable con nucleo logico y capa textual');
|
|
59
|
+
console.log('Escribe :help para ver comandos. :quit para salir.\n');
|
|
60
|
+
this.rl.prompt();
|
|
61
|
+
let buffer = '';
|
|
62
|
+
this.rl.on('line', (line) => {
|
|
63
|
+
const trimmed = line.trim();
|
|
64
|
+
// Comandos especiales del REPL
|
|
65
|
+
if (trimmed.startsWith(':')) {
|
|
66
|
+
this.handleMetaCommand(trimmed);
|
|
67
|
+
this.rl.prompt();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
// Línea vacía ejecuta el buffer si hay algo
|
|
71
|
+
if (trimmed === '' && buffer !== '') {
|
|
72
|
+
this.executeBuffer(buffer);
|
|
73
|
+
buffer = '';
|
|
74
|
+
this.rl.prompt();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (trimmed === '') {
|
|
78
|
+
this.rl.prompt();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
// Acumular o ejecutar directo
|
|
82
|
+
// Si la línea parece un statement completo, ejecutar directo
|
|
83
|
+
buffer = trimmed;
|
|
84
|
+
this.executeBuffer(buffer);
|
|
85
|
+
buffer = '';
|
|
86
|
+
this.rl.prompt();
|
|
87
|
+
});
|
|
88
|
+
this.rl.on('close', () => {
|
|
89
|
+
console.log('\nAdios.');
|
|
90
|
+
process.exit(0);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
executeBuffer(source) {
|
|
94
|
+
const output = this.interpreter.executeSingle(source);
|
|
95
|
+
if (output.stdout) {
|
|
96
|
+
console.log(output.stdout);
|
|
97
|
+
}
|
|
98
|
+
if (output.stderr) {
|
|
99
|
+
console.error(`Error: ${output.stderr}`);
|
|
100
|
+
}
|
|
101
|
+
for (const d of output.diagnostics) {
|
|
102
|
+
if (d.severity === 'warning') {
|
|
103
|
+
console.log(`Advertencia: ${d.message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
handleMetaCommand(cmd) {
|
|
108
|
+
const parts = cmd.split(/\s+/);
|
|
109
|
+
const command = parts[0].toLowerCase();
|
|
110
|
+
switch (command) {
|
|
111
|
+
case ':help':
|
|
112
|
+
case ':h':
|
|
113
|
+
this.printHelp();
|
|
114
|
+
break;
|
|
115
|
+
case ':quit':
|
|
116
|
+
case ':q':
|
|
117
|
+
case ':exit':
|
|
118
|
+
console.log('Adios.');
|
|
119
|
+
process.exit(0);
|
|
120
|
+
break;
|
|
121
|
+
case ':profiles':
|
|
122
|
+
console.log('Perfiles disponibles:');
|
|
123
|
+
for (const name of interface_1.registry.list()) {
|
|
124
|
+
const p = interface_1.registry.get(name);
|
|
125
|
+
console.log(` ${name} — ${p?.description || ''}`);
|
|
126
|
+
}
|
|
127
|
+
break;
|
|
128
|
+
case ':theory':
|
|
129
|
+
this.printTheory();
|
|
130
|
+
break;
|
|
131
|
+
case ':reset':
|
|
132
|
+
this.interpreter.reset();
|
|
133
|
+
console.log('Estado reiniciado.');
|
|
134
|
+
break;
|
|
135
|
+
case ':profile':
|
|
136
|
+
const p = this.interpreter.getProfile();
|
|
137
|
+
if (p) {
|
|
138
|
+
console.log(`Perfil actual: ${p.name}`);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
console.log('No hay perfil activo. Use: logic <perfil>');
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
case ':claims':
|
|
145
|
+
this.printClaims();
|
|
146
|
+
break;
|
|
147
|
+
default:
|
|
148
|
+
console.log(`Comando desconocido: ${command}. Escribe :help para ver comandos.`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
printHelp() {
|
|
152
|
+
console.log(`
|
|
153
|
+
Comandos del REPL:
|
|
154
|
+
:help, :h Mostrar esta ayuda
|
|
155
|
+
:quit, :q, :exit Salir
|
|
156
|
+
:profiles Listar perfiles logicos disponibles
|
|
157
|
+
:profile Mostrar perfil activo
|
|
158
|
+
:theory Mostrar teoria actual (axiomas, teoremas)
|
|
159
|
+
:claims Mostrar claims registrados
|
|
160
|
+
:reset Reiniciar estado
|
|
161
|
+
|
|
162
|
+
Sintaxis ST:
|
|
163
|
+
logic <perfil> Seleccionar perfil logico
|
|
164
|
+
axiom <nombre> = <formula> Declarar axioma
|
|
165
|
+
theorem <nombre> = <formula> Declarar teorema
|
|
166
|
+
derive <formula> from {p1, p2, ...} Derivar formula
|
|
167
|
+
check valid <formula> Verificar validez (tautologia)
|
|
168
|
+
check satisfiable <formula> Verificar satisfacibilidad
|
|
169
|
+
check equivalent <f1>, <f2> Verificar equivalencia
|
|
170
|
+
prove <formula> from {p1, p2, ...} Probar formula
|
|
171
|
+
countermodel <formula> Buscar contramodelo
|
|
172
|
+
truth_table <formula> Tabla de verdad
|
|
173
|
+
|
|
174
|
+
let <nombre> = passage([[path]]) Declarar pasaje
|
|
175
|
+
let <nombre> = formalize p as F Formalizar pasaje
|
|
176
|
+
claim <nombre> = <ref> Declarar claim
|
|
177
|
+
support <claim> <- <fuente> Registrar soporte
|
|
178
|
+
confidence <claim> = <0..1> Registrar confianza
|
|
179
|
+
context <claim> = "texto" Registrar contexto
|
|
180
|
+
|
|
181
|
+
Formulas:
|
|
182
|
+
P, Q, R Atomos proposicionales
|
|
183
|
+
!P Negacion
|
|
184
|
+
P & Q Conjuncion
|
|
185
|
+
P | Q Disyuncion
|
|
186
|
+
P -> Q Implicacion
|
|
187
|
+
P <-> Q Bicondicional
|
|
188
|
+
(P -> Q) Agrupacion con parentesis
|
|
189
|
+
`);
|
|
190
|
+
}
|
|
191
|
+
printTheory() {
|
|
192
|
+
const theory = this.interpreter.getTheory();
|
|
193
|
+
const profile = this.interpreter.getProfile();
|
|
194
|
+
console.log(`Perfil: ${profile?.name || '(ninguno)'}`);
|
|
195
|
+
if (theory.axioms.size > 0) {
|
|
196
|
+
console.log('Axiomas:');
|
|
197
|
+
for (const [name, formula] of theory.axioms) {
|
|
198
|
+
console.log(` ${name} = ${(0, propositional_1.formulaToString)(formula)}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
console.log('Axiomas: (ninguno)');
|
|
203
|
+
}
|
|
204
|
+
if (theory.theorems.size > 0) {
|
|
205
|
+
console.log('Teoremas:');
|
|
206
|
+
for (const [name, formula] of theory.theorems) {
|
|
207
|
+
console.log(` ${name} = ${(0, propositional_1.formulaToString)(formula)}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
printClaims() {
|
|
212
|
+
const tl = this.interpreter.getTextLayer();
|
|
213
|
+
if (tl.passages.size > 0) {
|
|
214
|
+
console.log('Passages:');
|
|
215
|
+
for (const [name, p] of tl.passages) {
|
|
216
|
+
console.log(` ${name} -> ${p.anchor.path}${p.anchor.fragment ? '#' + p.anchor.fragment : ''}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (tl.claims.size > 0) {
|
|
220
|
+
console.log('Claims:');
|
|
221
|
+
for (const [name, c] of tl.claims) {
|
|
222
|
+
let info = name;
|
|
223
|
+
if (c.formula)
|
|
224
|
+
info += ` = ${(0, propositional_1.formulaToString)(c.formula)}`;
|
|
225
|
+
if (c.support)
|
|
226
|
+
info += ` (soporte: ${c.support})`;
|
|
227
|
+
if (c.confidence !== undefined)
|
|
228
|
+
info += ` [confianza: ${c.confidence}]`;
|
|
229
|
+
if (c.context)
|
|
230
|
+
info += ` {contexto: "${c.context}"}`;
|
|
231
|
+
console.log(` ${info}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.REPL = REPL;
|
|
237
|
+
//# sourceMappingURL=repl.js.map
|