cobolx-2 1.2.3
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/.github/pull_request_template.md +9 -0
- package/.github/workflows/ci.yml +18 -0
- package/.vscode/launch.json +19 -0
- package/.vscode/tasks.json +14 -0
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +23 -0
- package/CargoX.lock +2 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/api-demo/CargoX.lock +1 -0
- package/api-demo/README.md +3 -0
- package/api-demo/benchmarks/arith.cbx +6 -0
- package/api-demo/cobolx.toml +6 -0
- package/api-demo/docs-output/index.html +1 -0
- package/api-demo/generated/LEGACYDEMO.cbx +5 -0
- package/api-demo/generated/client-types.ts +2 -0
- package/api-demo/generated/deploy.json +12 -0
- package/api-demo/generated/flowchart.mmd +4 -0
- package/api-demo/migrations/20260411215238_init.sql +1 -0
- package/api-demo/src/main.cbx +5 -0
- package/api-demo/tests/smoke.cbx +6 -0
- package/benchmarks/arithmetic.cbx +6 -0
- package/cargox/package.json +11 -0
- package/cargox/src/index.d.ts +4 -0
- package/cargox/src/index.js +5 -0
- package/cargox/src/index.js.map +1 -0
- package/cargox/src/index.ts +4 -0
- package/cargox/src/lockfile/index.d.ts +1 -0
- package/cargox/src/lockfile/index.js +9 -0
- package/cargox/src/lockfile/index.js.map +1 -0
- package/cargox/src/lockfile/index.ts +9 -0
- package/cargox/src/manifest.d.ts +10 -0
- package/cargox/src/manifest.js +49 -0
- package/cargox/src/manifest.js.map +1 -0
- package/cargox/src/manifest.ts +58 -0
- package/cargox/src/registry/index.d.ts +4 -0
- package/cargox/src/registry/index.js +13 -0
- package/cargox/src/registry/index.js.map +1 -0
- package/cargox/src/registry/index.ts +13 -0
- package/cargox/src/resolver/index.d.ts +5 -0
- package/cargox/src/resolver/index.js +4 -0
- package/cargox/src/resolver/index.js.map +1 -0
- package/cargox/src/resolver/index.ts +8 -0
- package/cargox/tsconfig.json +7 -0
- package/cli/cobolx-cli/package.json +23 -0
- package/cli/cobolx-cli/src/commands/add.ts +18 -0
- package/cli/cobolx-cli/src/commands/bench.ts +47 -0
- package/cli/cobolx-cli/src/commands/build.ts +74 -0
- package/cli/cobolx-cli/src/commands/check.ts +24 -0
- package/cli/cobolx-cli/src/commands/debug.ts +15 -0
- package/cli/cobolx-cli/src/commands/debug_rewind.ts +16 -0
- package/cli/cobolx-cli/src/commands/deploy.ts +18 -0
- package/cli/cobolx-cli/src/commands/dev.ts +24 -0
- package/cli/cobolx-cli/src/commands/doc.ts +19 -0
- package/cli/cobolx-cli/src/commands/fmt.ts +14 -0
- package/cli/cobolx-cli/src/commands/fuzz.ts +24 -0
- package/cli/cobolx-cli/src/commands/generate.ts +38 -0
- package/cli/cobolx-cli/src/commands/install.ts +25 -0
- package/cli/cobolx-cli/src/commands/legacy.ts +17 -0
- package/cli/cobolx-cli/src/commands/lint.ts +17 -0
- package/cli/cobolx-cli/src/commands/migrate.ts +27 -0
- package/cli/cobolx-cli/src/commands/new.ts +20 -0
- package/cli/cobolx-cli/src/commands/profile.ts +8 -0
- package/cli/cobolx-cli/src/commands/publish.ts +16 -0
- package/cli/cobolx-cli/src/commands/repl.ts +30 -0
- package/cli/cobolx-cli/src/commands/run.ts +22 -0
- package/cli/cobolx-cli/src/commands/task.ts +27 -0
- package/cli/cobolx-cli/src/commands/test.ts +44 -0
- package/cli/cobolx-cli/src/commands/update.ts +30 -0
- package/cli/cobolx-cli/src/commands/visualize.ts +25 -0
- package/cli/cobolx-cli/src/index.ts +101 -0
- package/cli/cobolx-cli/src/project.ts +74 -0
- package/cli/cobolx-cli/tsconfig.json +7 -0
- package/cobolx.toml +7 -0
- package/compiler/package.json +14 -0
- package/compiler/src/ast/types.d.ts +87 -0
- package/compiler/src/ast/types.js +2 -0
- package/compiler/src/ast/types.js.map +1 -0
- package/compiler/src/ast/types.ts +329 -0
- package/compiler/src/backend/custom.d.ts +8 -0
- package/compiler/src/backend/custom.js +12 -0
- package/compiler/src/backend/custom.js.map +1 -0
- package/compiler/src/backend/custom.ts +21 -0
- package/compiler/src/borrow_checker/checker.d.ts +3 -0
- package/compiler/src/borrow_checker/checker.js +82 -0
- package/compiler/src/borrow_checker/checker.js.map +1 -0
- package/compiler/src/borrow_checker/checker.ts +100 -0
- package/compiler/src/codegen/javascript.d.ts +2 -0
- package/compiler/src/codegen/javascript.js +89 -0
- package/compiler/src/codegen/javascript.js.map +1 -0
- package/compiler/src/codegen/javascript.ts +175 -0
- package/compiler/src/const_eval/evaluator.ts +58 -0
- package/compiler/src/diagnostics.d.ts +11 -0
- package/compiler/src/diagnostics.js +14 -0
- package/compiler/src/diagnostics.js.map +1 -0
- package/compiler/src/diagnostics.ts +20 -0
- package/compiler/src/hir/lower.d.ts +7 -0
- package/compiler/src/hir/lower.js +44 -0
- package/compiler/src/hir/lower.js.map +1 -0
- package/compiler/src/hir/lower.ts +60 -0
- package/compiler/src/hir/types.d.ts +21 -0
- package/compiler/src/hir/types.js +2 -0
- package/compiler/src/hir/types.js.map +1 -0
- package/compiler/src/hir/types.ts +26 -0
- package/compiler/src/index.d.ts +22 -0
- package/compiler/src/index.js +84 -0
- package/compiler/src/index.js.map +1 -0
- package/compiler/src/index.ts +122 -0
- package/compiler/src/lexer/lexer.d.ts +21 -0
- package/compiler/src/lexer/lexer.js +207 -0
- package/compiler/src/lexer/lexer.js.map +1 -0
- package/compiler/src/lexer/lexer.ts +274 -0
- package/compiler/src/lexer/tokens.d.ts +8 -0
- package/compiler/src/lexer/tokens.js +18 -0
- package/compiler/src/lexer/tokens.js.map +1 -0
- package/compiler/src/lexer/tokens.ts +126 -0
- package/compiler/src/macros/expand.ts +75 -0
- package/compiler/src/main.ts +4 -0
- package/compiler/src/mir/lower.d.ts +3 -0
- package/compiler/src/mir/lower.js +10 -0
- package/compiler/src/mir/lower.js.map +1 -0
- package/compiler/src/mir/lower.ts +12 -0
- package/compiler/src/mir/types.d.ts +13 -0
- package/compiler/src/mir/types.js +2 -0
- package/compiler/src/mir/types.js.map +1 -0
- package/compiler/src/mir/types.ts +16 -0
- package/compiler/src/optimizer/constantFold.d.ts +2 -0
- package/compiler/src/optimizer/constantFold.js +61 -0
- package/compiler/src/optimizer/constantFold.js.map +1 -0
- package/compiler/src/optimizer/constantFold.ts +109 -0
- package/compiler/src/parser/parser.d.ts +33 -0
- package/compiler/src/parser/parser.js +323 -0
- package/compiler/src/parser/parser.js.map +1 -0
- package/compiler/src/parser/parser.ts +710 -0
- package/compiler/src/plugins/api.ts +8 -0
- package/compiler/src/plugins/loader.ts +21 -0
- package/compiler/src/semantic/analyzer.d.ts +12 -0
- package/compiler/src/semantic/analyzer.js +144 -0
- package/compiler/src/semantic/analyzer.js.map +1 -0
- package/compiler/src/semantic/analyzer.ts +277 -0
- package/compiler/src/type_system/checker.d.ts +7 -0
- package/compiler/src/type_system/checker.js +84 -0
- package/compiler/src/type_system/checker.js.map +1 -0
- package/compiler/src/type_system/checker.ts +108 -0
- package/compiler/tsconfig.json +7 -0
- package/debugger/package.json +11 -0
- package/debugger/src/index.d.ts +1 -0
- package/debugger/src/index.js +9 -0
- package/debugger/src/index.js.map +1 -0
- package/debugger/src/index.ts +9 -0
- package/debugger/tsconfig.json +7 -0
- package/docs/CHANGELOG.md +11 -0
- package/docs/CONTRIBUTING.md +15 -0
- package/docs/LICENSE +21 -0
- package/docs/architecture.md +29 -0
- package/docs/cli.md +58 -0
- package/docs/language-spec.md +49 -0
- package/docs/packages.md +19 -0
- package/docs/platform-systems.md +31 -0
- package/docs/release-validation.md +22 -0
- package/docs/runtime.md +10 -0
- package/docs/tooling.md +17 -0
- package/docs/vscode-extension.md +40 -0
- package/enterprise-demo/CargoX.lock +2 -0
- package/enterprise-demo/README.md +3 -0
- package/enterprise-demo/benchmarks/arith.cbx +6 -0
- package/enterprise-demo/cobolx.toml +7 -0
- package/enterprise-demo/src/main.cbx +5 -0
- package/enterprise-demo/tests/smoke.cbx +6 -0
- package/examples/README.md +20 -0
- package/examples/actors-and-flags.md +8 -0
- package/examples/api-server/README.md +9 -0
- package/examples/api-server/cobolx.toml +6 -0
- package/examples/api-server/src/main.cbx +8 -0
- package/examples/debug-replay.md +7 -0
- package/examples/debugging-demo/README.md +3 -0
- package/examples/debugging-demo/cobolx.toml +6 -0
- package/examples/debugging-demo/src/main.cbx +7 -0
- package/examples/distributed-service.md +12 -0
- package/examples/distributed-system/README.md +3 -0
- package/examples/distributed-system/cobolx.toml +6 -0
- package/examples/distributed-system/generated/deploy.json +12 -0
- package/examples/distributed-system/src/main.cbx +6 -0
- package/examples/event-driven.md +5 -0
- package/examples/event-system/README.md +3 -0
- package/examples/event-system/cobolx.toml +6 -0
- package/examples/event-system/src/main.cbx +11 -0
- package/examples/functions.cbx +10 -0
- package/examples/functions.mjs +12 -0
- package/examples/hello.cbx +5 -0
- package/examples/hello.mjs +7 -0
- package/examples/legacy-sample.cob +5 -0
- package/examples/parallel-processing/README.md +3 -0
- package/examples/parallel-processing/cobolx.toml +6 -0
- package/examples/parallel-processing/src/main.cbx +6 -0
- package/examples/parallel-processing.md +8 -0
- package/examples/platform-features.cbx +32 -0
- package/examples/platform-features.mjs +35 -0
- package/examples/service.cbx +10 -0
- package/examples/workflow-engine/README.md +3 -0
- package/examples/workflow-engine/cobolx.toml +6 -0
- package/examples/workflow-engine/generated/flowchart.mmd +8 -0
- package/examples/workflow-engine/src/main.cbx +13 -0
- package/examples/workflow-engine.md +5 -0
- package/formatter/package.json +14 -0
- package/formatter/src/index.d.ts +1 -0
- package/formatter/src/index.js +59 -0
- package/formatter/src/index.js.map +1 -0
- package/formatter/src/index.ts +103 -0
- package/formatter/tsconfig.json +7 -0
- package/generated/LEGACYDEMO.cbx +5 -0
- package/install.ps1 +4 -0
- package/install.sh +5 -0
- package/linter/package.json +14 -0
- package/linter/src/index.d.ts +2 -0
- package/linter/src/index.js +18 -0
- package/linter/src/index.js.map +1 -0
- package/linter/src/index.ts +19 -0
- package/linter/tsconfig.json +7 -0
- package/lsp/server/package.json +16 -0
- package/lsp/server/src/index.ts +168 -0
- package/lsp/server/tsconfig.json +7 -0
- package/package.json +30 -0
- package/profiler/package.json +11 -0
- package/profiler/src/index.d.ts +5 -0
- package/profiler/src/index.js +11 -0
- package/profiler/src/index.js.map +1 -0
- package/profiler/src/index.ts +11 -0
- package/profiler/tsconfig.json +7 -0
- package/release.json +10 -0
- package/runtime/package.json +14 -0
- package/runtime/src/actors/index.ts +27 -0
- package/runtime/src/async/futures.ts +11 -0
- package/runtime/src/code_as_data/index.ts +5 -0
- package/runtime/src/config/index.ts +17 -0
- package/runtime/src/distributed/index.ts +13 -0
- package/runtime/src/events/index.ts +21 -0
- package/runtime/src/feature_flags/index.ts +9 -0
- package/runtime/src/gc_or_arc/index.ts +1 -0
- package/runtime/src/healing/index.ts +26 -0
- package/runtime/src/index.ts +20 -0
- package/runtime/src/intents/index.ts +9 -0
- package/runtime/src/iterators/index.ts +23 -0
- package/runtime/src/memory/arc.ts +22 -0
- package/runtime/src/observability/index.ts +23 -0
- package/runtime/src/repl/context.ts +7 -0
- package/runtime/src/scheduler/taskScheduler.ts +11 -0
- package/runtime/src/security/capabilities.ts +15 -0
- package/runtime/src/security/secrets.ts +13 -0
- package/runtime/src/state/versioned.ts +31 -0
- package/runtime/src/std_hooks/audit.ts +23 -0
- package/runtime/src/time_travel/index.ts +54 -0
- package/runtime/src/workflows/index.ts +35 -0
- package/runtime/tsconfig.json +7 -0
- package/sample-payroll/README.md +3 -0
- package/sample-payroll/cobolx.toml +3 -0
- package/sample-payroll/src/main.cbx +5 -0
- package/stdlib/business/index.js +15 -0
- package/stdlib/core/README.md +8 -0
- package/stdlib/core/runtime.js +191 -0
- package/stdlib/crypto/index.js +5 -0
- package/stdlib/datetime/index.js +3 -0
- package/stdlib/fs/index.js +9 -0
- package/stdlib/http/index.js +7 -0
- package/stdlib/io/index.js +1 -0
- package/stdlib/json/index.js +7 -0
- package/stdlib/net/index.js +4 -0
- package/tests/macros.cbx +10 -0
- package/tests/pattern_match.cbx +16 -0
- package/tests/smoke.cbx +7 -0
- package/tests/validate-release.mjs +54 -0
- package/tsconfig.base.json +24 -0
- package/vscode-extension/LICENSE +21 -0
- package/vscode-extension/README.md +47 -0
- package/vscode-extension/cobolx-1.2.0.vsix +0 -0
- package/vscode-extension/icon.png +0 -0
- package/vscode-extension/icon.svg +15 -0
- package/vscode-extension/language-configuration.json +17 -0
- package/vscode-extension/package.json +148 -0
- package/vscode-extension/snippets/cobolx.code-snippets +49 -0
- package/vscode-extension/src/extension.ts +283 -0
- package/vscode-extension/syntaxes/cobolx.tmLanguage.json +75 -0
- package/vscode-extension/tests/test.cbl +3 -0
- package/vscode-extension/tsconfig.json +7 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { BinaryExpressionNode, ExpressionNode, ProgramNode, StatementNode } from "../ast/types.js";
|
|
2
|
+
import type { Diagnostic } from "../diagnostics.js";
|
|
3
|
+
import type { CobolxType } from "../hir/types.js";
|
|
4
|
+
|
|
5
|
+
interface Scope {
|
|
6
|
+
values: Map<string, CobolxType>;
|
|
7
|
+
parent?: Scope;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function lookup(scope: Scope, name: string): CobolxType | undefined {
|
|
11
|
+
return scope.values.get(name) ?? scope.parent?.values.get(name) ?? (scope.parent ? lookup(scope.parent, name) : undefined);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function inferExpression(expression: ExpressionNode, scope: Scope, diagnostics: Diagnostic[]): CobolxType {
|
|
15
|
+
switch (expression.kind) {
|
|
16
|
+
case "NumberLiteral":
|
|
17
|
+
return "number";
|
|
18
|
+
case "StringLiteral":
|
|
19
|
+
return "string";
|
|
20
|
+
case "BooleanLiteral":
|
|
21
|
+
return "boolean";
|
|
22
|
+
case "Identifier":
|
|
23
|
+
return lookup(scope, expression.name) ?? "unknown";
|
|
24
|
+
case "UnaryExpression":
|
|
25
|
+
return inferExpression(expression.operand, scope, diagnostics);
|
|
26
|
+
case "TryExpression":
|
|
27
|
+
return inferExpression(expression.expression, scope, diagnostics);
|
|
28
|
+
case "MemberExpression":
|
|
29
|
+
return "unknown";
|
|
30
|
+
case "CallExpression":
|
|
31
|
+
case "MacroInvocation":
|
|
32
|
+
for (const arg of expression.args) inferExpression(arg, scope, diagnostics);
|
|
33
|
+
return "unknown";
|
|
34
|
+
case "EnumConstructorExpression":
|
|
35
|
+
for (const field of expression.fields) inferExpression(field, scope, diagnostics);
|
|
36
|
+
return "enum";
|
|
37
|
+
case "ArrayLiteral":
|
|
38
|
+
for (const item of expression.items) inferExpression(item, scope, diagnostics);
|
|
39
|
+
return "array";
|
|
40
|
+
case "BinaryExpression":
|
|
41
|
+
return inferBinaryExpression(expression, scope, diagnostics);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function inferBinaryExpression(expression: BinaryExpressionNode, scope: Scope, diagnostics: Diagnostic[]): CobolxType {
|
|
46
|
+
const left = inferExpression(expression.left, scope, diagnostics);
|
|
47
|
+
const right = inferExpression(expression.right, scope, diagnostics);
|
|
48
|
+
if (["+", "-", "*", "/", "%"].includes(expression.operator)) {
|
|
49
|
+
if (left !== "number" || right !== "number") {
|
|
50
|
+
diagnostics.push({ message: `Arithmetic operator '${expression.operator}' expects number operands`, severity: "warning", range: expression.range });
|
|
51
|
+
}
|
|
52
|
+
return "number";
|
|
53
|
+
}
|
|
54
|
+
if (["==", "!=", "<", "<=", ">", ">="].includes(expression.operator)) return "boolean";
|
|
55
|
+
return "unknown";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function inferProgramTypes(program: ProgramNode): { symbolTypes: Record<string, CobolxType>; diagnostics: Diagnostic[] } {
|
|
59
|
+
const diagnostics: Diagnostic[] = [];
|
|
60
|
+
const scope: Scope = { values: new Map() };
|
|
61
|
+
for (const constant of program.consts) scope.values.set(constant.name, inferExpression(constant.expression, scope, diagnostics));
|
|
62
|
+
|
|
63
|
+
const visitStatements = (statements: StatementNode[], localScope: Scope): void => {
|
|
64
|
+
for (const statement of statements) {
|
|
65
|
+
switch (statement.kind) {
|
|
66
|
+
case "LetStatement":
|
|
67
|
+
localScope.values.set(statement.binding.name, inferExpression(statement.expression, localScope, diagnostics));
|
|
68
|
+
break;
|
|
69
|
+
case "SetStatement":
|
|
70
|
+
localScope.values.set(statement.name, inferExpression(statement.expression, localScope, diagnostics));
|
|
71
|
+
break;
|
|
72
|
+
case "InputStatement":
|
|
73
|
+
localScope.values.set(statement.name, "string");
|
|
74
|
+
if (statement.prompt) inferExpression(statement.prompt, localScope, diagnostics);
|
|
75
|
+
break;
|
|
76
|
+
case "DisplayStatement":
|
|
77
|
+
case "ExpressionStatement":
|
|
78
|
+
case "ReturnStatement":
|
|
79
|
+
case "AssertStatement":
|
|
80
|
+
case "SpawnStatement":
|
|
81
|
+
inferExpression(statement.expression, localScope, diagnostics);
|
|
82
|
+
break;
|
|
83
|
+
case "IfStatement":
|
|
84
|
+
inferExpression(statement.condition, localScope, diagnostics);
|
|
85
|
+
visitStatements(statement.thenBranch, { values: new Map(localScope.values), parent: localScope.parent });
|
|
86
|
+
visitStatements(statement.elseBranch, { values: new Map(localScope.values), parent: localScope.parent });
|
|
87
|
+
break;
|
|
88
|
+
case "MatchStatement":
|
|
89
|
+
inferExpression(statement.expression, localScope, diagnostics);
|
|
90
|
+
for (const arm of statement.arms) visitStatements(arm.body, { values: new Map(localScope.values), parent: localScope.parent });
|
|
91
|
+
break;
|
|
92
|
+
case "UnsafeBlock":
|
|
93
|
+
case "BlockStatement":
|
|
94
|
+
visitStatements(statement.body, { values: new Map(localScope.values), parent: localScope });
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
for (const fn of program.functions) {
|
|
101
|
+
const fnScope: Scope = { values: new Map(), parent: scope };
|
|
102
|
+
for (const param of fn.signature.params) fnScope.values.set(param.name, param.typeName === "STRING" ? "string" : "unknown");
|
|
103
|
+
visitStatements(fn.body, fnScope);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
visitStatements(program.body, scope);
|
|
107
|
+
return { symbolTypes: Object.fromEntries(scope.values.entries()), diagnostics };
|
|
108
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cobolx/debugger",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "tsc -p tsconfig.json",
|
|
8
|
+
"check": "tsc -p tsconfig.json --noEmit",
|
|
9
|
+
"clean": "if (Test-Path dist) { Remove-Item -Recurse -Force dist }"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function debugNodeProgram(programPath: string): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
export function debugNodeProgram(programPath) {
|
|
3
|
+
console.log(`[debug] starting ${programPath}`);
|
|
4
|
+
const result = spawnSync(process.execPath, ["--inspect-brk=0", programPath], {
|
|
5
|
+
stdio: "inherit"
|
|
6
|
+
});
|
|
7
|
+
return result.status ?? 1;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,CAAC,GAAG,CAAC,oBAAoB,WAAW,EAAE,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,iBAAiB,EAAE,WAAW,CAAC,EAAE;QAC3E,KAAK,EAAE,SAAS;KACjB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
export function debugNodeProgram(programPath: string): number {
|
|
4
|
+
console.log(`[debug] starting ${programPath}`);
|
|
5
|
+
const result = spawnSync(process.execPath, ["--inspect-brk=0", programPath], {
|
|
6
|
+
stdio: "inherit"
|
|
7
|
+
});
|
|
8
|
+
return result.status ?? 1;
|
|
9
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- Expanded COBOLX into a multi-workspace ecosystem with runtime, package management, formatter, linter, debugger, and profiler packages
|
|
6
|
+
- Added compiler phase separation for HIR, MIR, type checking, borrow analysis, optimizer, and backend generation
|
|
7
|
+
- Added GitHub-ready documentation and repository metadata
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
10
|
+
|
|
11
|
+
- Initial TypeScript compiler, CLI, LSP, and VS Code extension
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Workflow
|
|
4
|
+
|
|
5
|
+
1. Install dependencies with `npm install`.
|
|
6
|
+
2. Build all workspaces with `npm run build`.
|
|
7
|
+
3. Verify changes with `npm run check`, `npm run test`, and targeted CLI commands.
|
|
8
|
+
4. Keep documentation in sync with behavior.
|
|
9
|
+
|
|
10
|
+
## Standards
|
|
11
|
+
|
|
12
|
+
- Prefer small, reviewable changes.
|
|
13
|
+
- Add tests or runnable examples for language features and tools.
|
|
14
|
+
- Keep compiler phases isolated by responsibility.
|
|
15
|
+
- Avoid introducing undocumented syntax.
|
package/docs/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 COBOLX
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# COBOL-X Architecture
|
|
2
|
+
|
|
3
|
+
## Compiler
|
|
4
|
+
|
|
5
|
+
- `lexer`: tokenization and source ranges
|
|
6
|
+
- `parser`: AST construction
|
|
7
|
+
- `semantic`: name and control-flow oriented validation
|
|
8
|
+
- `type_system`: basic type inference for literals and arithmetic expressions
|
|
9
|
+
- `hir`: semantic lowering stage
|
|
10
|
+
- `borrow_checker`: mutating alias checks across calls
|
|
11
|
+
- `mir`: instruction-oriented lowering stage
|
|
12
|
+
- `optimizer`: constant folding
|
|
13
|
+
- `backend`: custom JavaScript backend
|
|
14
|
+
|
|
15
|
+
## Toolchain
|
|
16
|
+
|
|
17
|
+
- `cargox`: manifest parsing, lockfile generation, dependency graph resolution, local registry publishing
|
|
18
|
+
- `cli/cobolx-cli`: user-facing command surface
|
|
19
|
+
- `formatter`, `linter`, `debugger`, `profiler`: standalone toolchain packages integrated into the CLI
|
|
20
|
+
|
|
21
|
+
## Runtime and Stdlib
|
|
22
|
+
|
|
23
|
+
- `runtime`: ARC-style references, futures, scheduling, and audit hooks
|
|
24
|
+
- `stdlib`: IO, filesystem, network, HTTP, JSON, crypto, datetime, and business modules
|
|
25
|
+
|
|
26
|
+
## Editor Support
|
|
27
|
+
|
|
28
|
+
- `lsp/server`: diagnostics, hover, and completion
|
|
29
|
+
- `vscode-extension`: syntax grammar, snippets, and LSP client wiring
|
package/docs/cli.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# COBOL-X CLI
|
|
2
|
+
|
|
3
|
+
## Commands
|
|
4
|
+
|
|
5
|
+
- `cobolx new my-project`
|
|
6
|
+
- `cobolx build`
|
|
7
|
+
- `cobolx run`
|
|
8
|
+
- `cobolx check`
|
|
9
|
+
- `cobolx test`
|
|
10
|
+
- `cobolx bench`
|
|
11
|
+
- `cobolx add dependency 1.0.0`
|
|
12
|
+
- `cobolx install`
|
|
13
|
+
- `cobolx update`
|
|
14
|
+
- `cobolx publish`
|
|
15
|
+
- `cobolx fmt`
|
|
16
|
+
- `cobolx lint`
|
|
17
|
+
- `cobolx debug`
|
|
18
|
+
- `cobolx profile`
|
|
19
|
+
- `cobolx dev`
|
|
20
|
+
- `cobolx doc`
|
|
21
|
+
- `cobolx repl`
|
|
22
|
+
- `cobolx visualize`
|
|
23
|
+
- `cobolx deploy`
|
|
24
|
+
|
|
25
|
+
## Project Layout
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
my-project/
|
|
29
|
+
├── src/
|
|
30
|
+
│ └── main.cbx
|
|
31
|
+
├── cobolx.toml
|
|
32
|
+
└── README.md
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Config
|
|
36
|
+
|
|
37
|
+
`cobolx.toml` uses a package/dependency layout:
|
|
38
|
+
|
|
39
|
+
```toml
|
|
40
|
+
[package]
|
|
41
|
+
name = "my-project"
|
|
42
|
+
version = "0.1.0"
|
|
43
|
+
entry = "src/main.cbx"
|
|
44
|
+
|
|
45
|
+
[dependencies]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Build output is written to `dist/main.mjs`.
|
|
49
|
+
|
|
50
|
+
## Validation Flow
|
|
51
|
+
|
|
52
|
+
Typical release validation:
|
|
53
|
+
|
|
54
|
+
```powershell
|
|
55
|
+
npm run build
|
|
56
|
+
npm run test
|
|
57
|
+
npm run validate
|
|
58
|
+
```
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# COBOL-X Language Specification
|
|
2
|
+
|
|
3
|
+
## File Format
|
|
4
|
+
|
|
5
|
+
COBOL-X source files use the `.cbx` extension.
|
|
6
|
+
|
|
7
|
+
## Program Structure
|
|
8
|
+
|
|
9
|
+
Every file starts with a `PROGRAM` declaration followed by a `BEGIN`/`END` block.
|
|
10
|
+
|
|
11
|
+
```cbx
|
|
12
|
+
PROGRAM Sample
|
|
13
|
+
|
|
14
|
+
BEGIN
|
|
15
|
+
DISPLAY "Hello"
|
|
16
|
+
END
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Statements
|
|
20
|
+
|
|
21
|
+
- `SET name = expression`
|
|
22
|
+
- `DISPLAY expression`
|
|
23
|
+
- `INPUT name`
|
|
24
|
+
- `IF expression THEN ... ELSE ... END-IF`
|
|
25
|
+
- `FUNCTION name(param, other) BEGIN ... END-FUNCTION`
|
|
26
|
+
- `RETURN expression`
|
|
27
|
+
|
|
28
|
+
## Expressions
|
|
29
|
+
|
|
30
|
+
- Numbers: `42`, `3.14`
|
|
31
|
+
- Strings: `"hello"`
|
|
32
|
+
- Booleans: `TRUE`, `FALSE`
|
|
33
|
+
- Variables: `salary`
|
|
34
|
+
- Arithmetic: `+`, `-`, `*`, `/`
|
|
35
|
+
- Comparison: `=`, `!=`, `<`, `<=`, `>`, `>=`
|
|
36
|
+
- Calls: `compute_tax(salary)`
|
|
37
|
+
|
|
38
|
+
## Semantics
|
|
39
|
+
|
|
40
|
+
- Variables must be assigned before they are read.
|
|
41
|
+
- Functions must be declared before they are called.
|
|
42
|
+
- Duplicate function names are rejected.
|
|
43
|
+
- Function argument counts are checked.
|
|
44
|
+
- Arithmetic diagnostics are emitted when non-numeric values are used in numeric operators.
|
|
45
|
+
- Borrow-style alias diagnostics reject passing the same identifier repeatedly to mutating functions.
|
|
46
|
+
|
|
47
|
+
## Code Generation
|
|
48
|
+
|
|
49
|
+
The compiler lowers source through HIR and MIR, performs constant folding, and emits JavaScript through the custom backend.
|
package/docs/packages.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# CargoX Packages
|
|
2
|
+
|
|
3
|
+
Implemented CargoX features in this repository:
|
|
4
|
+
|
|
5
|
+
- Manifest parsing from `cobolx.toml`
|
|
6
|
+
- Dependency graph resolution
|
|
7
|
+
- Lockfile writing to `CargoX.lock`
|
|
8
|
+
- Install materialization into `.cargox/packages/`
|
|
9
|
+
- Dependency update flow with manifest rewrite + lockfile refresh
|
|
10
|
+
- Local package publishing to `.cargox-registry/`
|
|
11
|
+
|
|
12
|
+
The current implementation is intentionally local-first and workspace-friendly.
|
|
13
|
+
|
|
14
|
+
Core commands:
|
|
15
|
+
|
|
16
|
+
- `cobolx add ledger 1.2.3`
|
|
17
|
+
- `cobolx install`
|
|
18
|
+
- `cobolx update`
|
|
19
|
+
- `cobolx publish`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# COBOL-X Platform Systems
|
|
2
|
+
|
|
3
|
+
This repository now includes working foundations for:
|
|
4
|
+
|
|
5
|
+
1. Effect-oriented compiler evolution groundwork through compiler metadata and plugin hooks
|
|
6
|
+
2. Capability-based runtime security types in `runtime/src/security`
|
|
7
|
+
3. Hot reload via `cobolx dev`
|
|
8
|
+
4. Typed configuration via `runtime/src/config`
|
|
9
|
+
5. Migrations via `cobolx migrate create|run`
|
|
10
|
+
6. Observability via `runtime/src/observability`
|
|
11
|
+
7. Feature flags via `runtime/src/feature_flags`
|
|
12
|
+
8. Version-ready API scaffolding via `cobolx generate api`
|
|
13
|
+
9. Actor model primitives via `runtime/src/actors`
|
|
14
|
+
10. Shared client type generation via `cobolx generate client typescript`
|
|
15
|
+
11. Task pipeline automation via `cobolx task`
|
|
16
|
+
12. Fuzz testing via `cobolx fuzz`
|
|
17
|
+
13. Secret management via `runtime/src/security/secrets`
|
|
18
|
+
14. DSL evolution hooks through macros, plugins, and code generation entry points
|
|
19
|
+
15. Distributed tooling via `runtime/src/distributed`
|
|
20
|
+
16. Build caching and incremental reuse in `cobolx build`
|
|
21
|
+
17. Interactive REPL via `cobolx repl`
|
|
22
|
+
18. Code generation via `cobolx generate`
|
|
23
|
+
19. Legacy COBOL conversion via `cobolx legacy`
|
|
24
|
+
20. Project templates via `cobolx new <name> [api|microservice|cli]`
|
|
25
|
+
21. Time-travel debugging via `runtime/src/time_travel` and `cobolx debug --rewind`
|
|
26
|
+
22. Event bus support via `runtime/src/events`
|
|
27
|
+
23. Workflow execution via `runtime/src/workflows`
|
|
28
|
+
24. Self-healing supervisor and health checks via `runtime/src/healing`
|
|
29
|
+
25. Versioned state tracking via `runtime/src/state/versioned`
|
|
30
|
+
26. Visual flow generation via `cobolx visualize`
|
|
31
|
+
27. Deploy metadata and distributed registration via `cobolx deploy`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Release Validation
|
|
2
|
+
|
|
3
|
+
The repository includes a scripted validation pass in [tests/validate-release.mjs](/c:/Users/matth/Desktop/temp%20folder/tests/validate-release.mjs:1).
|
|
4
|
+
|
|
5
|
+
It verifies:
|
|
6
|
+
|
|
7
|
+
- workspace build
|
|
8
|
+
- compiler-backed tests
|
|
9
|
+
- benchmark execution
|
|
10
|
+
- project scaffolding
|
|
11
|
+
- package add/install/update
|
|
12
|
+
- docs generation
|
|
13
|
+
- migrations
|
|
14
|
+
- visualization
|
|
15
|
+
- deploy metadata
|
|
16
|
+
- debug trace rewind
|
|
17
|
+
|
|
18
|
+
Run it with:
|
|
19
|
+
|
|
20
|
+
```powershell
|
|
21
|
+
npm run validate
|
|
22
|
+
```
|
package/docs/runtime.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# COBOL-X Runtime
|
|
2
|
+
|
|
3
|
+
The runtime package provides:
|
|
4
|
+
|
|
5
|
+
- `ArcBox<T>` for deterministic shared ownership semantics
|
|
6
|
+
- `TaskScheduler` for cooperative async execution
|
|
7
|
+
- `futureOf()` for future-style wrappers
|
|
8
|
+
- `audit()` and `getAuditTrail()` for enterprise audit hooks
|
|
9
|
+
|
|
10
|
+
These modules are intentionally small and composable so services can build deterministic infrastructure behavior on top of them.
|
package/docs/tooling.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# COBOL-X Tooling
|
|
2
|
+
|
|
3
|
+
## Formatter
|
|
4
|
+
|
|
5
|
+
`@cobolx/formatter` parses and prints canonical `.cbx` source.
|
|
6
|
+
|
|
7
|
+
## Linter
|
|
8
|
+
|
|
9
|
+
`@cobolx/linter` combines compiler diagnostics with style warnings like lowercase keyword usage.
|
|
10
|
+
|
|
11
|
+
## Debugger
|
|
12
|
+
|
|
13
|
+
`@cobolx/debugger` launches Node inspection against compiled output.
|
|
14
|
+
|
|
15
|
+
## Profiler
|
|
16
|
+
|
|
17
|
+
`@cobolx/profiler` measures build and run phases used by `cobolx bench` and `cobolx profile`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# VS Code Extension
|
|
2
|
+
|
|
3
|
+
The COBOL-X VS Code extension lives in [vscode-extension](/c:/Users/matth/Desktop/temp%20folder/vscode-extension:1).
|
|
4
|
+
|
|
5
|
+
## Included Features
|
|
6
|
+
|
|
7
|
+
- Language registration for `cobolx`
|
|
8
|
+
- File associations for `.cbx`, `.cob`, and `.col`
|
|
9
|
+
- TextMate grammar for syntax highlighting
|
|
10
|
+
- Snippets for programs, functions, enums, and match blocks
|
|
11
|
+
- Language client integration with the local COBOL-X language server
|
|
12
|
+
- Commands for build, run, REPL, and basic debug launch
|
|
13
|
+
|
|
14
|
+
Command routing:
|
|
15
|
+
|
|
16
|
+
- In the COBOL-X monorepo, the extension uses the local `cli/cobolx-cli/dist/index.js`
|
|
17
|
+
- In standalone projects, it falls back to `cobolx` on the system `PATH`
|
|
18
|
+
|
|
19
|
+
## Local Testing
|
|
20
|
+
|
|
21
|
+
1. Run `npm install`
|
|
22
|
+
2. Run `npm run build`
|
|
23
|
+
3. Open the repo in VS Code
|
|
24
|
+
4. Press `F5` to launch an Extension Development Host
|
|
25
|
+
5. Open a `.cbx` file and confirm syntax coloring, hover text, diagnostics, and command palette entries
|
|
26
|
+
|
|
27
|
+
## Marketplace Packaging
|
|
28
|
+
|
|
29
|
+
```powershell
|
|
30
|
+
cd vscode-extension
|
|
31
|
+
npm install -g vsce
|
|
32
|
+
npx @vscode/vsce package
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Publishing
|
|
36
|
+
|
|
37
|
+
```powershell
|
|
38
|
+
vsce login Magnexis
|
|
39
|
+
vsce publish
|
|
40
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# COBOL-X Examples
|
|
2
|
+
|
|
3
|
+
This directory contains runnable COBOL-X projects that exercise the CLI, compiler, runtime, and platform tooling.
|
|
4
|
+
|
|
5
|
+
Projects:
|
|
6
|
+
|
|
7
|
+
- `api-server/`
|
|
8
|
+
- `distributed-system/`
|
|
9
|
+
- `workflow-engine/`
|
|
10
|
+
- `event-system/`
|
|
11
|
+
- `parallel-processing/`
|
|
12
|
+
- `debugging-demo/`
|
|
13
|
+
|
|
14
|
+
Typical flow:
|
|
15
|
+
|
|
16
|
+
```powershell
|
|
17
|
+
cd examples/api-server
|
|
18
|
+
node ..\..\cli\cobolx-cli\dist\index.js check
|
|
19
|
+
node ..\..\cli\cobolx-cli\dist\index.js run
|
|
20
|
+
```
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Actors And Flags
|
|
2
|
+
|
|
3
|
+
This example is represented at the platform/runtime layer:
|
|
4
|
+
|
|
5
|
+
- Use `createActor("payments", handler)` from `@cobolx/runtime`
|
|
6
|
+
- Use `setFeatureFlag("new_checkout", true)` and `featureEnabled("new_checkout")`
|
|
7
|
+
- Use `log()`, `incrementMetric()`, and `trace()` for observability
|
|
8
|
+
- Use `registerService()` and `discoverService()` for distributed service lookup
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Distributed Service
|
|
2
|
+
|
|
3
|
+
Use the runtime distributed registry:
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { registerService, discoverService } from "@cobolx/runtime";
|
|
7
|
+
|
|
8
|
+
registerService("payments", "node://payments");
|
|
9
|
+
console.log(discoverService("payments"));
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The CLI `cobolx deploy` writes deployment metadata and service discovery output.
|