@stevenvo780/st-lang 0.3.0 → 0.4.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/README.md +86 -0
- package/dist/api.d.ts +7 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +20 -19
- package/dist/api.js.map +1 -1
- package/dist/ast/nodes.d.ts +1 -0
- package/dist/ast/nodes.d.ts.map +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +116 -182
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lexer/lexer.d.ts +3 -0
- package/dist/lexer/lexer.d.ts.map +1 -1
- package/dist/lexer/lexer.js +15 -7
- package/dist/lexer/lexer.js.map +1 -1
- package/dist/lexer/tokens.d.ts +4 -0
- package/dist/lexer/tokens.d.ts.map +1 -1
- package/dist/lexer/tokens.js +28 -21
- package/dist/lexer/tokens.js.map +1 -1
- package/dist/parser/parser.d.ts +4 -0
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js +107 -23
- package/dist/parser/parser.js.map +1 -1
- package/dist/profiles/classical/first-order.d.ts +7 -2
- package/dist/profiles/classical/first-order.d.ts.map +1 -1
- package/dist/profiles/classical/first-order.js +144 -29
- package/dist/profiles/classical/first-order.js.map +1 -1
- package/dist/profiles/classical/propositional.d.ts +1 -0
- package/dist/profiles/classical/propositional.d.ts.map +1 -1
- package/dist/profiles/classical/propositional.js +175 -61
- package/dist/profiles/classical/propositional.js.map +1 -1
- package/dist/profiles/interface.d.ts.map +1 -1
- package/dist/profiles/modal/k.d.ts +11 -3
- package/dist/profiles/modal/k.d.ts.map +1 -1
- package/dist/profiles/modal/k.js +305 -11
- package/dist/profiles/modal/k.js.map +1 -1
- package/dist/profiles/paraconsistent/belnap.d.ts +17 -1
- package/dist/profiles/paraconsistent/belnap.d.ts.map +1 -1
- package/dist/profiles/paraconsistent/belnap.js +195 -11
- package/dist/profiles/paraconsistent/belnap.js.map +1 -1
- package/dist/protocol/handler.d.ts.map +1 -1
- package/dist/protocol/handler.js +208 -22
- package/dist/protocol/handler.js.map +1 -1
- package/dist/repl/repl.d.ts.map +1 -1
- package/dist/repl/repl.js +9 -6
- package/dist/repl/repl.js.map +1 -1
- package/dist/runtime/interpreter.d.ts +4 -2
- package/dist/runtime/interpreter.d.ts.map +1 -1
- package/dist/runtime/interpreter.js +86 -48
- package/dist/runtime/interpreter.js.map +1 -1
- package/dist/tests/cli.test.d.ts +1 -1
- package/dist/tests/cli.test.d.ts.map +1 -1
- package/dist/tests/cli.test.js +112 -115
- package/dist/tests/cli.test.js.map +1 -1
- package/dist/tests/core.test.d.ts +1 -1
- package/dist/tests/core.test.d.ts.map +1 -1
- package/dist/tests/core.test.js +175 -174
- package/dist/tests/core.test.js.map +1 -1
- package/dist/tests/engines.test.d.ts +2 -0
- package/dist/tests/engines.test.d.ts.map +1 -0
- package/dist/tests/engines.test.js +81 -0
- package/dist/tests/engines.test.js.map +1 -0
- package/dist/tests/parser.test.d.ts +1 -1
- package/dist/tests/parser.test.d.ts.map +1 -1
- package/dist/tests/parser.test.js +162 -165
- package/dist/tests/parser.test.js.map +1 -1
- package/dist/tests/philosophy.test.d.ts +2 -0
- package/dist/tests/philosophy.test.d.ts.map +1 -0
- package/dist/tests/philosophy.test.js +588 -0
- package/dist/tests/philosophy.test.js.map +1 -0
- package/dist/text-layer/compiler.d.ts +5 -9
- package/dist/text-layer/compiler.d.ts.map +1 -1
- package/dist/text-layer/compiler.js +6 -4
- package/dist/text-layer/compiler.js.map +1 -1
- package/dist/types/index.d.ts +10 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +24 -7
- package/dist/tests/runner.d.ts +0 -6
- package/dist/tests/runner.d.ts.map +0 -1
- package/dist/tests/runner.js +0 -69
- package/dist/tests/runner.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# ST — Symbolic Theory Language
|
|
2
|
+
|
|
3
|
+
**ST** is a modular logical environment and executable language designed for formalizing, verifying, and exploring logical theories across multiple systems (Classical, Modal, Paraconsistent). It features a unique **Text Layer** that bridges natural language documents with formal logical claims.
|
|
4
|
+
|
|
5
|
+
[](package.json)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
## 🚀 Key Features
|
|
9
|
+
|
|
10
|
+
- **Multi-Logic Support**: Pluggable profiles for Classical Propositional, First-Order, Modal (K), and Paraconsistent (Belnap) logic.
|
|
11
|
+
- **Automated Reasoning**: Built-in engines for automated derivations, truth tables, and countermodel generation.
|
|
12
|
+
- **Text Layer**: Map logical claims directly to document anchors (e.g., `file.md#heading`), enabling formal verification of "live" documents.
|
|
13
|
+
- **Interactive REPL**: A powerful CLI to explore theories in real-time.
|
|
14
|
+
- **Programmatic API**: Full TypeScript/JavaScript support to integrate logical verification into your own applications.
|
|
15
|
+
- **Editor Integration**: Protocol-ready for high-level features like hover, go-to-definition, and symbols.
|
|
16
|
+
|
|
17
|
+
## 📦 Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -g @stevenvo780/st-lang
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 🛠️ Quick Start (CLI)
|
|
24
|
+
|
|
25
|
+
Create a file named `demo.st`:
|
|
26
|
+
|
|
27
|
+
```st
|
|
28
|
+
logic classical.propositional
|
|
29
|
+
|
|
30
|
+
axiom a1 : P -> Q
|
|
31
|
+
axiom a2 : P
|
|
32
|
+
|
|
33
|
+
derive Q from {a1, a2}
|
|
34
|
+
check valid (P | !P)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Run it:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
st demo.st
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or enter the REPL:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
st
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 💻 Programmatic API
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { evaluate, createInterpreter } from '@stevenvo780/st-lang/api';
|
|
53
|
+
|
|
54
|
+
// Stateless evaluation
|
|
55
|
+
const result = evaluate(`
|
|
56
|
+
logic classical.propositional
|
|
57
|
+
check valid (A -> (B -> A))
|
|
58
|
+
`);
|
|
59
|
+
console.log(result.results[0].status); // 'valid'
|
|
60
|
+
|
|
61
|
+
// Stateful interpreter
|
|
62
|
+
const st = createInterpreter();
|
|
63
|
+
st.exec('logic classical.propositional');
|
|
64
|
+
st.exec('axiom a1 : P -> Q');
|
|
65
|
+
const r = st.exec('check satisfiable a1');
|
|
66
|
+
console.log(r.ok); // true
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🏗️ Architecture
|
|
70
|
+
|
|
71
|
+
ST is built with a traditional compiler architecture but specialized for logic:
|
|
72
|
+
|
|
73
|
+
1. **Lexer/Parser**: Consumes `.st` scripts into a typed AST.
|
|
74
|
+
2. **Interpreter**: Manages the **Theory** (axioms, theorems, claims) and executes statements.
|
|
75
|
+
3. **Logic Profiles**: Pluggable engines that implement the `LogicProfile` interface. Each profile provides its own solvers (Tableau, Truth Tables, etc.).
|
|
76
|
+
4. **Text Layer State**: Tracks references to external documents and maps them to logical formulas.
|
|
77
|
+
|
|
78
|
+
## 📚 Documentation
|
|
79
|
+
|
|
80
|
+
For a deep dive into the language syntax, logic profiles, and the Text Layer, see [DOCS.md](./DOCS.md).
|
|
81
|
+
|
|
82
|
+
Check [LOGIC_LIMITATIONS.md](./LOGIC_LIMITATIONS.md) for known boundaries of the current solvers.
|
|
83
|
+
|
|
84
|
+
## 📄 License
|
|
85
|
+
|
|
86
|
+
MIT © [Steven Velez](https://github.com/stevenvo780)
|
package/dist/api.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ST — API programática para uso como librería
|
|
3
|
+
*
|
|
4
|
+
* Uso:
|
|
5
|
+
* import { evaluate, parse, check, createInterpreter } from 'st-lang/api';
|
|
6
|
+
* const result = evaluate('logic classical.propositional\ncheck valid (P -> P)');
|
|
7
|
+
*/
|
|
1
8
|
import type { Diagnostic, RunResult, SymbolInfo, HoverInfo, CompletionItem, SourceLocation } from './types';
|
|
2
9
|
import type { Program } from './ast/nodes';
|
|
3
10
|
/** Resultado de evaluate() */
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,cAAc,EACd,cAAc,EACf,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAI3C,8BAA8B;AAC9B,MAAM,WAAW,YAAY;IAC3B,8BAA8B;IAC9B,EAAE,EAAE,OAAO,CAAC;IACZ,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,oEAAoE;IACpE,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,8CAA8C;IAC9C,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,2BAA2B;AAC3B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED,2BAA2B;AAC3B,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B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api.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
/**
|
|
3
|
+
* ST — API programática para uso como librería
|
|
4
|
+
*
|
|
5
|
+
* Uso:
|
|
6
|
+
* import { evaluate, parse, check, createInterpreter } from 'st-lang/api';
|
|
7
|
+
* const result = evaluate('logic classical.propositional\ncheck valid (P -> P)');
|
|
8
|
+
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.formulaToString = void 0;
|
|
11
11
|
exports.evaluate = evaluate;
|
|
@@ -22,6 +22,7 @@ exports.render = render;
|
|
|
22
22
|
const parser_1 = require("./parser/parser");
|
|
23
23
|
const interpreter_1 = require("./runtime/interpreter");
|
|
24
24
|
const handler_1 = require("./protocol/handler");
|
|
25
|
+
const interface_1 = require("./profiles/interface");
|
|
25
26
|
// ── Funciones estateless (una sola invocación) ────────────────
|
|
26
27
|
/**
|
|
27
28
|
* Ejecuta código ST completo y devuelve resultado estructurado.
|
|
@@ -56,7 +57,7 @@ function evaluate(source, file) {
|
|
|
56
57
|
function parse(source, file) {
|
|
57
58
|
const parser = new parser_1.Parser(file || '<api>');
|
|
58
59
|
const program = parser.parse(source);
|
|
59
|
-
const hasErrors = parser.diagnostics.some(d => d.severity === 'error');
|
|
60
|
+
const hasErrors = parser.diagnostics.some((d) => d.severity === 'error');
|
|
60
61
|
return {
|
|
61
62
|
ok: !hasErrors,
|
|
62
63
|
program: hasErrors ? null : program,
|
|
@@ -70,7 +71,7 @@ function parse(source, file) {
|
|
|
70
71
|
function check(source, file) {
|
|
71
72
|
const parser = new parser_1.Parser(file || '<api>');
|
|
72
73
|
parser.parse(source);
|
|
73
|
-
const hasErrors = parser.diagnostics.some(d => d.severity === 'error');
|
|
74
|
+
const hasErrors = parser.diagnostics.some((d) => d.severity === 'error');
|
|
74
75
|
return {
|
|
75
76
|
ok: !hasErrors,
|
|
76
77
|
diagnostics: parser.diagnostics,
|
|
@@ -148,11 +149,11 @@ var propositional_1 = require("./profiles/classical/propositional");
|
|
|
148
149
|
Object.defineProperty(exports, "formulaToString", { enumerable: true, get: function () { return propositional_1.formulaToString; } });
|
|
149
150
|
/** Lista los perfiles lógicos disponibles */
|
|
150
151
|
function listProfiles() {
|
|
151
|
-
// Los perfiles se registran al
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return registry.list();
|
|
152
|
+
// Los perfiles se registran al instanciar un Interpreter,
|
|
153
|
+
// pero ya deberían estar en el registry si se cargan sus archivos.
|
|
154
|
+
// Sin embargo, para asegurar, instanciamos uno.
|
|
155
|
+
new interpreter_1.Interpreter();
|
|
156
|
+
return interface_1.registry.list();
|
|
156
157
|
}
|
|
157
158
|
/**
|
|
158
159
|
* Obtiene información de hover para una posición en el código ST.
|
|
@@ -165,7 +166,7 @@ function hover(source, line, column, file) {
|
|
|
165
166
|
const resp = handler.handle({
|
|
166
167
|
id: 0,
|
|
167
168
|
method: 'hover',
|
|
168
|
-
params: { source, line, column, file: file || '<api>' }
|
|
169
|
+
params: { source, line, column, file: file || '<api>' },
|
|
169
170
|
});
|
|
170
171
|
return resp.result ?? null;
|
|
171
172
|
}
|
|
@@ -178,7 +179,7 @@ function symbols(source, file) {
|
|
|
178
179
|
const resp = handler.handle({
|
|
179
180
|
id: 0,
|
|
180
181
|
method: 'symbols',
|
|
181
|
-
params: { source, file: file || '<api>' }
|
|
182
|
+
params: { source, file: file || '<api>' },
|
|
182
183
|
});
|
|
183
184
|
return resp.result ?? [];
|
|
184
185
|
}
|
|
@@ -193,7 +194,7 @@ function gotoDefinition(source, name, file) {
|
|
|
193
194
|
const resp = handler.handle({
|
|
194
195
|
id: 0,
|
|
195
196
|
method: 'goto_definition',
|
|
196
|
-
params: { source, name, file: file || '<api>' }
|
|
197
|
+
params: { source, name, file: file || '<api>' },
|
|
197
198
|
});
|
|
198
199
|
return resp.result ?? null;
|
|
199
200
|
}
|
|
@@ -206,7 +207,7 @@ function completion() {
|
|
|
206
207
|
const resp = handler.handle({
|
|
207
208
|
id: 0,
|
|
208
209
|
method: 'completion',
|
|
209
|
-
params: {}
|
|
210
|
+
params: {},
|
|
210
211
|
});
|
|
211
212
|
return resp.result ?? [];
|
|
212
213
|
}
|
|
@@ -220,7 +221,7 @@ function render(source, format, file) {
|
|
|
220
221
|
const resp = handler.handle({
|
|
221
222
|
id: 0,
|
|
222
223
|
method: 'render',
|
|
223
|
-
params: { source, format: format || 'markdown', file: file || '<api>' }
|
|
224
|
+
params: { source, format: format || 'markdown', file: file || '<api>' },
|
|
224
225
|
});
|
|
225
226
|
const result = resp.result;
|
|
226
227
|
return {
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAgEH,4BAWC;AAKD,sBASC;AAMD,sBAQC;AAaD,8BAEC;AAiDD,8CAwDC;AAQD,oCAMC;AAuBD,sBAaC;AAMD,0BAQC;AAQD,wCAQC;AAMD,gCAQC;AAOD,wBAaC;AA/UD,4CAAyC;AACzC,uDAAoD;AACpD,gDAAqD;AACrD,oDAAgD;AA0ChD,iEAAiE;AAEjE;;;;;;;;;;;;;;GAcG;AACH,SAAgB,QAAQ,CAAC,MAAc,EAAE,IAAa;IACpD,MAAM,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,IAAI,OAAO,CAAC,CAAC;IAC5D,OAAO;QACL,EAAE,EAAE,MAAM,CAAC,QAAQ,KAAK,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,MAAM,EAA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,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAA0D,CAAC;IAC/E,OAAO;QACL,QAAQ,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE;QAChC,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,MAAM,IAAI,UAAU;QAC9C,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,EAAE;KACpC,CAAC;AACJ,CAAC"}
|
package/dist/ast/nodes.d.ts
CHANGED
package/dist/ast/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ast/nodes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAInD,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,YAAY,GACZ,iBAAiB,GACjB,uBAAuB,GACvB,sBAAsB,GACtB,WAAW,GACX,kBAAkB,GAClB,iBAAiB,GACjB,UAAU,GACV,YAAY,GACZ,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,YAAY,CAAC;AAEjB,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,cAAc,CAAC;CACxB;AAID,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,IAAI,EAAE,YAA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AAc,GAAG,gBAAgB,CAAC;AAE5D,MAAM,WAAW,aAAc,SAAQ,OAAO;IAC5C,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IACjD,IAAI,EAAE,iBAAiB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAgB,SAAQ,OAAO;IAC9C,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAID,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,aAAa,GACb,eAAe,GACf,aAAa,GACb,iBAAiB,GACjB,uBAAuB,GACvB,sBAAsB,GACtB,YAAY,GACZ,mBAAmB,GACnB,iBAAiB,GACjB,WAAW,GACX,aAAa,GACb,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,aAAa,CAAC;AAElB,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd"}
|
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
// ============================================================
|
|
3
|
-
// ST CLI — Entry point principal
|
|
4
|
+
// ST CLI — Entry point principal (Commander based)
|
|
4
5
|
// ============================================================
|
|
5
6
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
7
|
if (k2 === undefined) k2 = k;
|
|
@@ -35,227 +36,133 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
36
|
return result;
|
|
36
37
|
};
|
|
37
38
|
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
38
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
43
|
const fs = __importStar(require("fs"));
|
|
40
44
|
const path = __importStar(require("path"));
|
|
45
|
+
const readline = __importStar(require("readline"));
|
|
46
|
+
const commander_1 = require("commander");
|
|
47
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
48
|
const interpreter_1 = require("../runtime/interpreter");
|
|
42
49
|
const repl_1 = require("../repl/repl");
|
|
43
50
|
const handler_1 = require("../protocol/handler");
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
st
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Codigos de salida:
|
|
60
|
-
0 Ejecucion correcta
|
|
61
|
-
1 Error de parseo o tipado
|
|
62
|
-
2 Error de resolucion
|
|
63
|
-
3 Error de runtime
|
|
64
|
-
4 Resultado logico negativo esperado
|
|
65
|
-
|
|
66
|
-
Ejemplos:
|
|
67
|
-
st run demo.st
|
|
68
|
-
st check demo.st
|
|
69
|
-
st eval "check valid (P -> (Q -> P))"
|
|
70
|
-
st repl
|
|
71
|
-
`);
|
|
72
|
-
}
|
|
73
|
-
function main() {
|
|
74
|
-
const args = process.argv.slice(2);
|
|
75
|
-
if (args.length === 0) {
|
|
76
|
-
printUsage();
|
|
77
|
-
process.exit(0);
|
|
78
|
-
}
|
|
79
|
-
const command = args[0];
|
|
80
|
-
switch (command) {
|
|
81
|
-
case 'run':
|
|
82
|
-
return cmdRun(args.slice(1));
|
|
83
|
-
case 'check':
|
|
84
|
-
return cmdCheck(args.slice(1));
|
|
85
|
-
case 'repl':
|
|
86
|
-
return cmdRepl();
|
|
87
|
-
case 'eval':
|
|
88
|
-
return cmdEval(args.slice(1));
|
|
89
|
-
case 'render':
|
|
90
|
-
return cmdRender(args.slice(1));
|
|
91
|
-
case 'version':
|
|
92
|
-
case '--version':
|
|
93
|
-
case '-v':
|
|
94
|
-
console.log(`st v${VERSION}`);
|
|
95
|
-
process.exit(0);
|
|
96
|
-
break;
|
|
97
|
-
case 'help':
|
|
98
|
-
case '--help':
|
|
99
|
-
case '-h':
|
|
100
|
-
printUsage();
|
|
101
|
-
process.exit(0);
|
|
102
|
-
break;
|
|
103
|
-
case 'profiles':
|
|
104
|
-
return cmdProfiles();
|
|
105
|
-
case 'protocol':
|
|
106
|
-
return cmdProtocol(args.slice(1));
|
|
107
|
-
default:
|
|
108
|
-
// Si es un archivo, ejecutar como `st run`
|
|
109
|
-
if (args[0].endsWith('.st') || args[0].endsWith('.md.st')) {
|
|
110
|
-
return cmdRun(args);
|
|
111
|
-
}
|
|
112
|
-
console.error(`Comando desconocido: ${command}`);
|
|
113
|
-
console.error(`Usa 'st help' para ver los comandos disponibles.`);
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function cmdRun(args) {
|
|
118
|
-
if (args.length === 0) {
|
|
119
|
-
console.error('Error: se necesita un archivo. Uso: st run <archivo.st>');
|
|
51
|
+
const interface_1 = require("../profiles/interface");
|
|
52
|
+
const program = new commander_1.Command();
|
|
53
|
+
program
|
|
54
|
+
.name('st')
|
|
55
|
+
.description('ST — Lenguaje ejecutable con nucleo logico y capa textual')
|
|
56
|
+
.version('0.3.0');
|
|
57
|
+
program
|
|
58
|
+
.command('run')
|
|
59
|
+
.description('Ejecutar script .st')
|
|
60
|
+
.argument('<archivo>', 'Ruta al archivo .st')
|
|
61
|
+
.option('-d, --diagnostics', 'Escribir diagnósticos en un archivo .json')
|
|
62
|
+
.action((filePath, options) => {
|
|
63
|
+
const fullPath = path.resolve(filePath);
|
|
64
|
+
if (!fs.existsSync(fullPath)) {
|
|
65
|
+
console.error(chalk_1.default.red(`Error: archivo no encontrado: ${fullPath}`));
|
|
120
66
|
process.exit(1);
|
|
121
67
|
}
|
|
122
|
-
const
|
|
123
|
-
if (!fs.existsSync(filePath)) {
|
|
124
|
-
console.error(`Error: archivo no encontrado: ${filePath}`);
|
|
125
|
-
process.exit(1);
|
|
126
|
-
}
|
|
127
|
-
const source = fs.readFileSync(filePath, 'utf-8');
|
|
68
|
+
const source = fs.readFileSync(fullPath, 'utf-8');
|
|
128
69
|
const interpreter = new interpreter_1.Interpreter();
|
|
129
|
-
const output = interpreter.execute(source,
|
|
130
|
-
if (output.stdout)
|
|
70
|
+
const output = interpreter.execute(source, fullPath);
|
|
71
|
+
if (output.stdout)
|
|
131
72
|
console.log(output.stdout);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
// Escribir diagnósticos si se pide
|
|
137
|
-
if (args.includes('--diagnostics')) {
|
|
138
|
-
const diagPath = filePath.replace(/\.st$/, '.diagnostics.json');
|
|
73
|
+
if (output.stderr)
|
|
74
|
+
console.error(chalk_1.default.red(output.stderr));
|
|
75
|
+
if (options.diagnostics) {
|
|
76
|
+
const diagPath = fullPath.replace(/\.st$/, '.diagnostics.json');
|
|
139
77
|
fs.writeFileSync(diagPath, JSON.stringify(output.diagnostics, null, 2));
|
|
140
|
-
console.log(`Diagnosticos escritos en: ${diagPath}`);
|
|
78
|
+
console.log(chalk_1.default.blue(`Diagnosticos escritos en: ${diagPath}`));
|
|
141
79
|
}
|
|
142
80
|
process.exit(output.exitCode);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
if (!fs.existsSync(
|
|
151
|
-
console.error(`Error: archivo no encontrado: ${
|
|
81
|
+
});
|
|
82
|
+
program
|
|
83
|
+
.command('check')
|
|
84
|
+
.description('Verificar sintaxis y bien-formacion de un archivo .st')
|
|
85
|
+
.argument('<archivo>', 'Ruta al archivo .st')
|
|
86
|
+
.action((filePath) => {
|
|
87
|
+
const fullPath = path.resolve(filePath);
|
|
88
|
+
if (!fs.existsSync(fullPath)) {
|
|
89
|
+
console.error(chalk_1.default.red(`Error: archivo no encontrado: ${fullPath}`));
|
|
152
90
|
process.exit(1);
|
|
153
91
|
}
|
|
154
|
-
const source = fs.readFileSync(
|
|
92
|
+
const source = fs.readFileSync(fullPath, 'utf-8');
|
|
155
93
|
const interpreter = new interpreter_1.Interpreter();
|
|
156
|
-
const output = interpreter.execute(source,
|
|
157
|
-
const errors = output.diagnostics.filter(d => d.severity === 'error');
|
|
158
|
-
const warnings = output.diagnostics.filter(d => d.severity === 'warning');
|
|
94
|
+
const output = interpreter.execute(source, fullPath);
|
|
95
|
+
const errors = output.diagnostics.filter((d) => d.severity === 'error');
|
|
96
|
+
const warnings = output.diagnostics.filter((d) => d.severity === 'warning');
|
|
159
97
|
if (errors.length === 0) {
|
|
160
|
-
console.log(`✓ ${
|
|
98
|
+
console.log(chalk_1.default.green(`✓ ${fullPath}: sin errores`));
|
|
161
99
|
if (warnings.length > 0) {
|
|
162
|
-
console.log(` ${warnings.length} advertencia(s)`);
|
|
100
|
+
console.log(chalk_1.default.yellow(` ${warnings.length} advertencia(s)`));
|
|
163
101
|
for (const w of warnings) {
|
|
164
|
-
console.log(` ⚠ ${w.message}${w.line ? ` (linea ${w.line})` : ''}`);
|
|
102
|
+
console.log(chalk_1.default.yellow(` ⚠ ${w.message}${w.line ? ` (linea ${w.line})` : ''}`));
|
|
165
103
|
}
|
|
166
104
|
}
|
|
167
|
-
// Mostrar resultados lógicos
|
|
168
105
|
for (const r of output.results) {
|
|
169
106
|
if (r.status === 'invalid' || r.status === 'refutable' || r.status === 'unsatisfiable') {
|
|
170
|
-
console.log(` ✗ Resultado negativo: ${r.output}`);
|
|
107
|
+
console.log(chalk_1.default.red(` ✗ Resultado negativo: ${r.output}`));
|
|
171
108
|
}
|
|
172
109
|
}
|
|
173
|
-
const hasNegativeResults = output.results.some(r => r.status === 'invalid' || r.status === 'refutable');
|
|
110
|
+
const hasNegativeResults = output.results.some((r) => r.status === 'invalid' || r.status === 'refutable');
|
|
174
111
|
process.exit(hasNegativeResults ? 4 : 0);
|
|
175
112
|
}
|
|
176
113
|
else {
|
|
177
|
-
console.error(`✗ ${
|
|
114
|
+
console.error(chalk_1.default.red(`✗ ${fullPath}: ${errors.length} error(es)`));
|
|
178
115
|
for (const e of errors) {
|
|
179
|
-
console.error(` ✗ ${e.message}${e.line ? ` (linea ${e.line})` : ''}`);
|
|
116
|
+
console.error(chalk_1.default.red(` ✗ ${e.message}${e.line ? ` (linea ${e.line})` : ''}`));
|
|
180
117
|
}
|
|
181
118
|
process.exit(1);
|
|
182
119
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
120
|
+
});
|
|
121
|
+
program
|
|
122
|
+
.command('repl')
|
|
123
|
+
.description('Iniciar REPL interactivo')
|
|
124
|
+
.action(() => {
|
|
185
125
|
const repl = new repl_1.REPL();
|
|
186
126
|
repl.start();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const source = args.join(' ');
|
|
127
|
+
});
|
|
128
|
+
program
|
|
129
|
+
.command('eval')
|
|
130
|
+
.description('Evaluar una expresion directa')
|
|
131
|
+
.argument('<expresion>', 'Expresion ST a evaluar')
|
|
132
|
+
.action((expression) => {
|
|
194
133
|
const interpreter = new interpreter_1.Interpreter();
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
fullSource = `logic classical.propositional\n${source}`;
|
|
134
|
+
let fullSource = expression;
|
|
135
|
+
if (!expression.trim().startsWith('logic ')) {
|
|
136
|
+
fullSource = `logic classical.propositional\n${expression}`;
|
|
199
137
|
}
|
|
200
138
|
const output = interpreter.execute(fullSource, '<eval>');
|
|
201
|
-
if (output.stdout)
|
|
139
|
+
if (output.stdout)
|
|
202
140
|
console.log(output.stdout);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
console.error(output.stderr);
|
|
206
|
-
}
|
|
141
|
+
if (output.stderr)
|
|
142
|
+
console.error(chalk_1.default.red(output.stderr));
|
|
207
143
|
process.exit(output.exitCode);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
console.error(`Error: archivo no encontrado: ${filePath}`);
|
|
222
|
-
process.exit(1);
|
|
223
|
-
}
|
|
224
|
-
const source = fs.readFileSync(filePath, 'utf-8');
|
|
225
|
-
const handler = new handler_1.ProtocolHandler();
|
|
226
|
-
const response = handler.handle({
|
|
227
|
-
id: 1,
|
|
228
|
-
method: 'render',
|
|
229
|
-
params: { source, file: filePath, format },
|
|
230
|
-
});
|
|
231
|
-
if (response.result) {
|
|
232
|
-
const res = response.result;
|
|
233
|
-
console.log(res.rendered);
|
|
234
|
-
}
|
|
235
|
-
if (response.error) {
|
|
236
|
-
console.error(response.error.message);
|
|
237
|
-
process.exit(3);
|
|
238
|
-
}
|
|
239
|
-
process.exit(0);
|
|
240
|
-
}
|
|
241
|
-
function cmdProfiles() {
|
|
242
|
-
// Forzar registro
|
|
243
|
-
const interpreter = new interpreter_1.Interpreter();
|
|
244
|
-
const { registry } = require('../profiles/interface');
|
|
245
|
-
console.log('Perfiles logicos disponibles:\n');
|
|
246
|
-
for (const name of registry.list()) {
|
|
247
|
-
const p = registry.get(name);
|
|
248
|
-
const status = name === 'classical.propositional' ? '✓ completo' : '○ stub';
|
|
249
|
-
console.log(` ${name}`);
|
|
250
|
-
console.log(` ${p?.description || ''}`);
|
|
251
|
-
console.log(` Estado: ${status}`);
|
|
144
|
+
});
|
|
145
|
+
program
|
|
146
|
+
.command('profiles')
|
|
147
|
+
.description('Listar perfiles logicos disponibles')
|
|
148
|
+
.action(() => {
|
|
149
|
+
new interpreter_1.Interpreter(); // Asegura registro
|
|
150
|
+
console.log(chalk_1.default.bold('Perfiles logicos disponibles:\n'));
|
|
151
|
+
for (const name of interface_1.registry.list()) {
|
|
152
|
+
const p = interface_1.registry.get(name);
|
|
153
|
+
const status = name === 'classical.propositional' ? chalk_1.default.green('completo') : chalk_1.default.yellow('stub');
|
|
154
|
+
console.log(` ${chalk_1.default.cyan(name)} [${status}]`);
|
|
155
|
+
if (p?.description)
|
|
156
|
+
console.log(` ${p.description}`);
|
|
252
157
|
console.log('');
|
|
253
158
|
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
159
|
+
});
|
|
160
|
+
program
|
|
161
|
+
.command('protocol')
|
|
162
|
+
.description('Modo JSON-RPC para integracion con editores (LSP-like)')
|
|
163
|
+
.action(() => {
|
|
257
164
|
const handler = new handler_1.ProtocolHandler();
|
|
258
|
-
const rl =
|
|
165
|
+
const rl = readline.createInterface({
|
|
259
166
|
input: process.stdin,
|
|
260
167
|
output: process.stdout,
|
|
261
168
|
terminal: false,
|
|
@@ -267,12 +174,39 @@ function cmdProtocol(args) {
|
|
|
267
174
|
console.log(JSON.stringify(response));
|
|
268
175
|
}
|
|
269
176
|
catch (e) {
|
|
177
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
270
178
|
console.log(JSON.stringify({
|
|
271
179
|
id: -1,
|
|
272
|
-
error: { code: -32700, message: `Parse error: ${
|
|
180
|
+
error: { code: -32700, message: `Parse error: ${message}` },
|
|
273
181
|
}));
|
|
274
182
|
}
|
|
275
183
|
});
|
|
184
|
+
});
|
|
185
|
+
// Handle unknown commands
|
|
186
|
+
program.on('command:*', () => {
|
|
187
|
+
const args = program.args;
|
|
188
|
+
if (args.length > 0 && (args[0].endsWith('.st') || args[0].endsWith('.md.st'))) {
|
|
189
|
+
// Legacy support for `st file.st`
|
|
190
|
+
const filePath = path.resolve(args[0]);
|
|
191
|
+
if (fs.existsSync(filePath)) {
|
|
192
|
+
const source = fs.readFileSync(filePath, 'utf-8');
|
|
193
|
+
const interpreter = new interpreter_1.Interpreter();
|
|
194
|
+
const output = interpreter.execute(source, filePath);
|
|
195
|
+
if (output.stdout)
|
|
196
|
+
console.log(output.stdout);
|
|
197
|
+
if (output.stderr)
|
|
198
|
+
console.error(chalk_1.default.red(output.stderr));
|
|
199
|
+
process.exit(output.exitCode);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
console.error(chalk_1.default.red(`Comando desconocido: ${program.args.join(' ')}`));
|
|
203
|
+
console.error(`Usa 'st --help' para ver los comandos disponibles.`);
|
|
204
|
+
process.exit(1);
|
|
205
|
+
});
|
|
206
|
+
if (process.argv.length === 2) {
|
|
207
|
+
program.help();
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
program.parse(process.argv);
|
|
276
211
|
}
|
|
277
|
-
main();
|
|
278
212
|
//# sourceMappingURL=index.js.map
|