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,44 @@
|
|
|
1
|
+
import { inferProgramTypes } from "../type_system/checker.js";
|
|
2
|
+
function collectMutatedParams(params, statements) {
|
|
3
|
+
const mutated = new Set();
|
|
4
|
+
for (const statement of statements) {
|
|
5
|
+
switch (statement.kind) {
|
|
6
|
+
case "SetStatement":
|
|
7
|
+
case "InputStatement":
|
|
8
|
+
if (params.includes(statement.name)) {
|
|
9
|
+
mutated.add(statement.name);
|
|
10
|
+
}
|
|
11
|
+
break;
|
|
12
|
+
case "IfStatement":
|
|
13
|
+
for (const name of collectMutatedParams(params, statement.thenBranch)) {
|
|
14
|
+
mutated.add(name);
|
|
15
|
+
}
|
|
16
|
+
for (const name of collectMutatedParams(params, statement.elseBranch)) {
|
|
17
|
+
mutated.add(name);
|
|
18
|
+
}
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return [...mutated];
|
|
23
|
+
}
|
|
24
|
+
function lowerFunction(program) {
|
|
25
|
+
return program.functions.map((fn) => ({
|
|
26
|
+
name: fn.name,
|
|
27
|
+
params: [...fn.params],
|
|
28
|
+
mutatedParams: collectMutatedParams(fn.params, fn.body),
|
|
29
|
+
body: fn.body.map((statement) => ({ statement }))
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
export function lowerToHIR(program) {
|
|
33
|
+
const typeInfo = inferProgramTypes(program);
|
|
34
|
+
return {
|
|
35
|
+
diagnostics: typeInfo.diagnostics,
|
|
36
|
+
hir: {
|
|
37
|
+
program,
|
|
38
|
+
functions: lowerFunction(program),
|
|
39
|
+
body: program.body.map((statement) => ({ statement })),
|
|
40
|
+
symbolTypes: typeInfo.symbolTypes
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=lower.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lower.js","sourceRoot":"","sources":["lower.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,SAAS,oBAAoB,CAAC,MAAgB,EAAE,UAA2B;IACzE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;YACvB,KAAK,cAAc,CAAC;YACpB,KAAK,gBAAgB;gBACnB,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;oBACpC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBAC9B,CAAC;gBACD,MAAM;YACR,KAAK,aAAa;gBAChB,KAAK,MAAM,IAAI,IAAI,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;oBACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC;gBACD,KAAK,MAAM,IAAI,IAAI,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;oBACtE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpB,CAAC;gBACD,MAAM;QACV,CAAC;IACH,CAAC;IACD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,aAAa,CAAC,OAAoB;IACzC,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;QACtB,aAAa,EAAE,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC;QACvD,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;KAClD,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,OAAoB;IAC7C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO;QACL,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,GAAG,EAAE;YACH,OAAO;YACP,SAAS,EAAE,aAAa,CAAC,OAAO,CAAC;YACjC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;YACtD,WAAW,EAAE,QAAQ,CAAC,WAAW;SAClC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ProgramNode, StatementNode } from "../ast/types.js";
|
|
2
|
+
import type { Diagnostic } from "../diagnostics.js";
|
|
3
|
+
import type { HIRFunction, HIRProgram } from "./types.js";
|
|
4
|
+
import { inferProgramTypes } from "../type_system/checker.js";
|
|
5
|
+
|
|
6
|
+
function collectMutatedParams(params: string[], statements: StatementNode[]): string[] {
|
|
7
|
+
const mutated = new Set<string>();
|
|
8
|
+
for (const statement of statements) {
|
|
9
|
+
switch (statement.kind) {
|
|
10
|
+
case "LetStatement":
|
|
11
|
+
break;
|
|
12
|
+
case "SetStatement":
|
|
13
|
+
case "InputStatement":
|
|
14
|
+
if (params.includes(statement.name)) {
|
|
15
|
+
mutated.add(statement.name);
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case "IfStatement":
|
|
19
|
+
for (const name of collectMutatedParams(params, statement.thenBranch)) {
|
|
20
|
+
mutated.add(name);
|
|
21
|
+
}
|
|
22
|
+
for (const name of collectMutatedParams(params, statement.elseBranch)) {
|
|
23
|
+
mutated.add(name);
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
case "MatchStatement":
|
|
27
|
+
for (const arm of statement.arms) {
|
|
28
|
+
for (const name of collectMutatedParams(params, arm.body)) mutated.add(name);
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
case "UnsafeBlock":
|
|
32
|
+
case "BlockStatement":
|
|
33
|
+
for (const name of collectMutatedParams(params, statement.body)) mutated.add(name);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return [...mutated];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function lowerFunction(program: ProgramNode): HIRFunction[] {
|
|
41
|
+
return program.functions.map((fn) => ({
|
|
42
|
+
name: fn.signature.name,
|
|
43
|
+
params: fn.signature.params.map((param) => param.name),
|
|
44
|
+
mutatedParams: collectMutatedParams(fn.signature.params.map((param) => param.name), fn.body),
|
|
45
|
+
body: fn.body.map((statement) => ({ statement }))
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function lowerToHIR(program: ProgramNode): { hir: HIRProgram; diagnostics: Diagnostic[] } {
|
|
50
|
+
const typeInfo = inferProgramTypes(program);
|
|
51
|
+
return {
|
|
52
|
+
diagnostics: typeInfo.diagnostics,
|
|
53
|
+
hir: {
|
|
54
|
+
program,
|
|
55
|
+
functions: lowerFunction(program),
|
|
56
|
+
body: program.body.map((statement) => ({ statement })),
|
|
57
|
+
symbolTypes: typeInfo.symbolTypes
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ExpressionNode, ProgramNode, StatementNode } from "../ast/types.js";
|
|
2
|
+
export type CobolxType = "number" | "string" | "boolean" | "unknown" | "void";
|
|
3
|
+
export interface HIRExpression {
|
|
4
|
+
expression: ExpressionNode;
|
|
5
|
+
inferredType: CobolxType;
|
|
6
|
+
}
|
|
7
|
+
export interface HIRStatement {
|
|
8
|
+
statement: StatementNode;
|
|
9
|
+
}
|
|
10
|
+
export interface HIRFunction {
|
|
11
|
+
name: string;
|
|
12
|
+
params: string[];
|
|
13
|
+
mutatedParams: string[];
|
|
14
|
+
body: HIRStatement[];
|
|
15
|
+
}
|
|
16
|
+
export interface HIRProgram {
|
|
17
|
+
program: ProgramNode;
|
|
18
|
+
functions: HIRFunction[];
|
|
19
|
+
body: HIRStatement[];
|
|
20
|
+
symbolTypes: Record<string, CobolxType>;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ExpressionNode, ProgramNode, StatementNode } from "../ast/types.js";
|
|
2
|
+
|
|
3
|
+
export type CobolxType = "number" | "string" | "boolean" | "unknown" | "void" | "enum" | "array";
|
|
4
|
+
|
|
5
|
+
export interface HIRExpression {
|
|
6
|
+
expression: ExpressionNode;
|
|
7
|
+
inferredType: CobolxType;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface HIRStatement {
|
|
11
|
+
statement: StatementNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface HIRFunction {
|
|
15
|
+
name: string;
|
|
16
|
+
params: string[];
|
|
17
|
+
mutatedParams: string[];
|
|
18
|
+
body: HIRStatement[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface HIRProgram {
|
|
22
|
+
program: ProgramNode;
|
|
23
|
+
functions: HIRFunction[];
|
|
24
|
+
body: HIRStatement[];
|
|
25
|
+
symbolTypes: Record<string, CobolxType>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProgramNode } from "./ast/types.js";
|
|
2
|
+
import type { Diagnostic } from "./diagnostics.js";
|
|
3
|
+
import type { HIRProgram } from "./hir/types.js";
|
|
4
|
+
import type { MIRProgram } from "./mir/types.js";
|
|
5
|
+
export interface CompileResult {
|
|
6
|
+
program: ProgramNode;
|
|
7
|
+
diagnostics: Diagnostic[];
|
|
8
|
+
output?: string;
|
|
9
|
+
hir?: HIRProgram;
|
|
10
|
+
mir?: MIRProgram;
|
|
11
|
+
}
|
|
12
|
+
export declare function parseSource(source: string): ProgramNode;
|
|
13
|
+
export declare function analyzeSource(source: string): CompileResult;
|
|
14
|
+
export declare function compileSource(source: string, outputFilePath: string, stdlibDir: string): CompileResult;
|
|
15
|
+
export declare function compileFile(inputPath: string, outputPath: string, stdlibDir: string): Diagnostic[];
|
|
16
|
+
export declare function checkFile(inputPath: string): Diagnostic[];
|
|
17
|
+
export declare function printDiagnostics(filePath: string, diagnostics: Diagnostic[]): void;
|
|
18
|
+
export declare function compilerStdlibDir(): string;
|
|
19
|
+
export declare function runCompilerCli(argv: string[]): number;
|
|
20
|
+
export { CobolxError, formatDiagnostic } from "./diagnostics.js";
|
|
21
|
+
export type { Diagnostic } from "./diagnostics.js";
|
|
22
|
+
export type { ExpressionNode, ProgramNode, StatementNode } from "./ast/types.js";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { CobolxError, formatDiagnostic } from "./diagnostics.js";
|
|
5
|
+
import { Lexer } from "./lexer/lexer.js";
|
|
6
|
+
import { Parser } from "./parser/parser.js";
|
|
7
|
+
import { emitCustomBackend } from "./backend/custom.js";
|
|
8
|
+
import { runBorrowChecker } from "./borrow_checker/checker.js";
|
|
9
|
+
import { lowerToHIR } from "./hir/lower.js";
|
|
10
|
+
import { SemanticAnalyzer } from "./semantic/analyzer.js";
|
|
11
|
+
import { lowerToMIR } from "./mir/lower.js";
|
|
12
|
+
import { optimizeMIR } from "./optimizer/constantFold.js";
|
|
13
|
+
export function parseSource(source) {
|
|
14
|
+
const lexer = new Lexer(source);
|
|
15
|
+
const tokens = lexer.tokenize();
|
|
16
|
+
const parser = new Parser(tokens);
|
|
17
|
+
return parser.parseProgram();
|
|
18
|
+
}
|
|
19
|
+
export function analyzeSource(source) {
|
|
20
|
+
const program = parseSource(source);
|
|
21
|
+
const semanticDiagnostics = new SemanticAnalyzer().analyze(program);
|
|
22
|
+
const hirResult = lowerToHIR(program);
|
|
23
|
+
const borrowDiagnostics = runBorrowChecker(hirResult.hir);
|
|
24
|
+
const diagnostics = [...semanticDiagnostics, ...hirResult.diagnostics, ...borrowDiagnostics];
|
|
25
|
+
const mir = optimizeMIR(lowerToMIR(hirResult.hir));
|
|
26
|
+
return { program, diagnostics, hir: hirResult.hir, mir };
|
|
27
|
+
}
|
|
28
|
+
export function compileSource(source, outputFilePath, stdlibDir) {
|
|
29
|
+
const analyzed = analyzeSource(source);
|
|
30
|
+
if (analyzed.diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
31
|
+
return analyzed;
|
|
32
|
+
}
|
|
33
|
+
const backend = emitCustomBackend(analyzed.program, analyzed.mir, outputFilePath, stdlibDir);
|
|
34
|
+
return {
|
|
35
|
+
...analyzed,
|
|
36
|
+
output: backend.code
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export function compileFile(inputPath, outputPath, stdlibDir) {
|
|
40
|
+
const source = fs.readFileSync(inputPath, "utf8");
|
|
41
|
+
const result = compileSource(source, outputPath, stdlibDir);
|
|
42
|
+
if (result.diagnostics.length > 0 || !result.output) {
|
|
43
|
+
return result.diagnostics;
|
|
44
|
+
}
|
|
45
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
46
|
+
fs.writeFileSync(outputPath, result.output, "utf8");
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
export function checkFile(inputPath) {
|
|
50
|
+
const source = fs.readFileSync(inputPath, "utf8");
|
|
51
|
+
return analyzeSource(source).diagnostics;
|
|
52
|
+
}
|
|
53
|
+
export function printDiagnostics(filePath, diagnostics) {
|
|
54
|
+
for (const diagnostic of diagnostics) {
|
|
55
|
+
console.error(formatDiagnostic(filePath, diagnostic));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function compilerStdlibDir() {
|
|
59
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..", "stdlib/core");
|
|
60
|
+
}
|
|
61
|
+
export function runCompilerCli(argv) {
|
|
62
|
+
const [inputPath, outputPath] = argv;
|
|
63
|
+
if (!inputPath || !outputPath) {
|
|
64
|
+
console.error("Usage: cobolxc <input.cbx> <output.js>");
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const diagnostics = compileFile(path.resolve(inputPath), path.resolve(outputPath), compilerStdlibDir());
|
|
69
|
+
if (diagnostics.length > 0) {
|
|
70
|
+
printDiagnostics(inputPath, diagnostics);
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof CobolxError) {
|
|
77
|
+
console.error(formatDiagnostic(inputPath, error.diagnostic));
|
|
78
|
+
return 1;
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export { CobolxError, formatDiagnostic } from "./diagnostics.js";
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,C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AO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;YAC7D,OAAO,CAAC,CAAC;QACX,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import type { ProgramNode } from "./ast/types.js";
|
|
5
|
+
import type { Diagnostic } from "./diagnostics.js";
|
|
6
|
+
import { CobolxError, formatDiagnostic } from "./diagnostics.js";
|
|
7
|
+
import { Lexer } from "./lexer/lexer.js";
|
|
8
|
+
import { Parser } from "./parser/parser.js";
|
|
9
|
+
import { emitCustomBackend } from "./backend/custom.js";
|
|
10
|
+
import { runBorrowChecker } from "./borrow_checker/checker.js";
|
|
11
|
+
import { evaluateConstDeclarations } from "./const_eval/evaluator.js";
|
|
12
|
+
import { lowerToHIR } from "./hir/lower.js";
|
|
13
|
+
import { expandMacros } from "./macros/expand.js";
|
|
14
|
+
import { applyCompilerPlugins } from "./plugins/loader.js";
|
|
15
|
+
import { SemanticAnalyzer } from "./semantic/analyzer.js";
|
|
16
|
+
import { lowerToMIR } from "./mir/lower.js";
|
|
17
|
+
import { optimizeMIR } from "./optimizer/constantFold.js";
|
|
18
|
+
import type { HIRProgram } from "./hir/types.js";
|
|
19
|
+
import type { MIRProgram } from "./mir/types.js";
|
|
20
|
+
|
|
21
|
+
export interface CompileResult {
|
|
22
|
+
program: ProgramNode;
|
|
23
|
+
diagnostics: Diagnostic[];
|
|
24
|
+
output?: string;
|
|
25
|
+
hir?: HIRProgram;
|
|
26
|
+
mir?: MIRProgram;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function parseSource(source: string): ProgramNode {
|
|
30
|
+
const lexer = new Lexer(source);
|
|
31
|
+
const tokens = lexer.tokenize();
|
|
32
|
+
const parser = new Parser(tokens);
|
|
33
|
+
return parser.parseProgram();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function analyzeSource(source: string): CompileResult {
|
|
37
|
+
const program = expandMacros(evaluateConstDeclarations(parseSource(source)));
|
|
38
|
+
return analyzeProgram(program);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function analyzeProgram(program: ProgramNode): CompileResult {
|
|
42
|
+
const semanticDiagnostics = new SemanticAnalyzer().analyze(program);
|
|
43
|
+
const hirResult = lowerToHIR(program);
|
|
44
|
+
const borrowDiagnostics = runBorrowChecker(hirResult.hir);
|
|
45
|
+
const diagnostics = [...semanticDiagnostics, ...hirResult.diagnostics, ...borrowDiagnostics];
|
|
46
|
+
const mir = optimizeMIR(lowerToMIR(hirResult.hir));
|
|
47
|
+
return { program, diagnostics, hir: hirResult.hir, mir };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function compileSource(source: string, outputFilePath: string, stdlibDir: string): CompileResult {
|
|
51
|
+
const analyzed = analyzeProgram(expandMacros(evaluateConstDeclarations(parseSource(source))));
|
|
52
|
+
if (analyzed.diagnostics.some((diagnostic) => diagnostic.severity === "error")) {
|
|
53
|
+
return analyzed;
|
|
54
|
+
}
|
|
55
|
+
const backend = emitCustomBackend(analyzed.program, analyzed.mir!, outputFilePath, stdlibDir);
|
|
56
|
+
return {
|
|
57
|
+
...analyzed,
|
|
58
|
+
output: backend.code
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function compileFile(inputPath: string, outputPath: string, stdlibDir: string): Diagnostic[] {
|
|
63
|
+
const source = fs.readFileSync(inputPath, "utf8");
|
|
64
|
+
const parsed = expandMacros(evaluateConstDeclarations(parseSource(source)));
|
|
65
|
+
const pluginResult = applyCompilerPlugins(parsed, path.dirname(inputPath));
|
|
66
|
+
const result = analyzeProgram(pluginResult.program);
|
|
67
|
+
result.diagnostics.unshift(...pluginResult.diagnostics);
|
|
68
|
+
const hasErrors = result.diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
69
|
+
if (!hasErrors) {
|
|
70
|
+
const backend = emitCustomBackend(result.program, result.mir!, outputPath, stdlibDir);
|
|
71
|
+
result.output = backend.code;
|
|
72
|
+
}
|
|
73
|
+
if (hasErrors || !result.output) {
|
|
74
|
+
return result.diagnostics;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
78
|
+
fs.writeFileSync(outputPath, result.output, "utf8");
|
|
79
|
+
return result.diagnostics;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function checkFile(inputPath: string): Diagnostic[] {
|
|
83
|
+
const source = fs.readFileSync(inputPath, "utf8");
|
|
84
|
+
return analyzeSource(source).diagnostics;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function printDiagnostics(filePath: string, diagnostics: Diagnostic[]): void {
|
|
88
|
+
for (const diagnostic of diagnostics) {
|
|
89
|
+
console.error(formatDiagnostic(filePath, diagnostic));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function compilerStdlibDir(): string {
|
|
94
|
+
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..", "stdlib/core");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function runCompilerCli(argv: string[]): number {
|
|
98
|
+
const [inputPath, outputPath] = argv;
|
|
99
|
+
if (!inputPath || !outputPath) {
|
|
100
|
+
console.error("Usage: cobolxc <input.cbx> <output.js>");
|
|
101
|
+
return 1;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
try {
|
|
105
|
+
const diagnostics = compileFile(path.resolve(inputPath), path.resolve(outputPath), compilerStdlibDir());
|
|
106
|
+
if (diagnostics.length > 0) {
|
|
107
|
+
printDiagnostics(inputPath, diagnostics);
|
|
108
|
+
return 1;
|
|
109
|
+
}
|
|
110
|
+
return 0;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof CobolxError) {
|
|
113
|
+
console.error(formatDiagnostic(inputPath, error.diagnostic));
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
116
|
+
throw error;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { CobolxError, formatDiagnostic } from "./diagnostics.js";
|
|
121
|
+
export type { Diagnostic } from "./diagnostics.js";
|
|
122
|
+
export type { ExpressionNode, PatternNode, ProgramNode, StatementNode } from "./ast/types.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Token } from "./tokens.js";
|
|
2
|
+
export declare class Lexer {
|
|
3
|
+
private readonly source;
|
|
4
|
+
private index;
|
|
5
|
+
private location;
|
|
6
|
+
constructor(source: string);
|
|
7
|
+
tokenize(): Token[];
|
|
8
|
+
private newlineToken;
|
|
9
|
+
private consumeComment;
|
|
10
|
+
private identifier;
|
|
11
|
+
private number;
|
|
12
|
+
private string;
|
|
13
|
+
private symbol;
|
|
14
|
+
private advance;
|
|
15
|
+
private peek;
|
|
16
|
+
private peekNext;
|
|
17
|
+
private isAtEnd;
|
|
18
|
+
private isAlpha;
|
|
19
|
+
private isDigit;
|
|
20
|
+
private isAlphaNumeric;
|
|
21
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { CobolxError } from "../diagnostics.js";
|
|
2
|
+
import { KEYWORDS } from "./tokens.js";
|
|
3
|
+
function cloneLocation(location) {
|
|
4
|
+
return { ...location };
|
|
5
|
+
}
|
|
6
|
+
export class Lexer {
|
|
7
|
+
source;
|
|
8
|
+
index = 0;
|
|
9
|
+
location = { line: 1, column: 1, offset: 0 };
|
|
10
|
+
constructor(source) {
|
|
11
|
+
this.source = source;
|
|
12
|
+
}
|
|
13
|
+
tokenize() {
|
|
14
|
+
const tokens = [];
|
|
15
|
+
while (!this.isAtEnd()) {
|
|
16
|
+
const char = this.peek();
|
|
17
|
+
if (char === " " || char === "\t" || char === "\r") {
|
|
18
|
+
this.advance();
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (char === "\n") {
|
|
22
|
+
tokens.push(this.newlineToken());
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (char === "*" && this.peekNext() === ">") {
|
|
26
|
+
this.consumeComment();
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (this.isAlpha(char)) {
|
|
30
|
+
tokens.push(this.identifier());
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (this.isDigit(char)) {
|
|
34
|
+
tokens.push(this.number());
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (char === "\"") {
|
|
38
|
+
tokens.push(this.string());
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
tokens.push(this.symbol());
|
|
42
|
+
}
|
|
43
|
+
const eofRange = {
|
|
44
|
+
start: cloneLocation(this.location),
|
|
45
|
+
end: cloneLocation(this.location)
|
|
46
|
+
};
|
|
47
|
+
tokens.push({ type: "EOF", lexeme: "", range: eofRange });
|
|
48
|
+
return tokens;
|
|
49
|
+
}
|
|
50
|
+
newlineToken() {
|
|
51
|
+
const start = cloneLocation(this.location);
|
|
52
|
+
const lexeme = this.advance();
|
|
53
|
+
return {
|
|
54
|
+
type: "NEWLINE",
|
|
55
|
+
lexeme,
|
|
56
|
+
range: { start, end: cloneLocation(this.location) }
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
consumeComment() {
|
|
60
|
+
while (!this.isAtEnd() && this.peek() !== "\n") {
|
|
61
|
+
this.advance();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
identifier() {
|
|
65
|
+
const start = cloneLocation(this.location);
|
|
66
|
+
let value = "";
|
|
67
|
+
while (!this.isAtEnd() && (this.isAlphaNumeric(this.peek()) || this.peek() === "-")) {
|
|
68
|
+
value += this.advance();
|
|
69
|
+
}
|
|
70
|
+
const upper = value.toUpperCase();
|
|
71
|
+
const type = KEYWORDS[upper] ?? "IDENTIFIER";
|
|
72
|
+
const lexeme = type === "IDENTIFIER" ? value : upper;
|
|
73
|
+
return {
|
|
74
|
+
type,
|
|
75
|
+
lexeme,
|
|
76
|
+
range: { start, end: cloneLocation(this.location) }
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
number() {
|
|
80
|
+
const start = cloneLocation(this.location);
|
|
81
|
+
let value = "";
|
|
82
|
+
while (!this.isAtEnd() && this.isDigit(this.peek())) {
|
|
83
|
+
value += this.advance();
|
|
84
|
+
}
|
|
85
|
+
if (!this.isAtEnd() && this.peek() === "." && this.isDigit(this.peekNext())) {
|
|
86
|
+
value += this.advance();
|
|
87
|
+
while (!this.isAtEnd() && this.isDigit(this.peek())) {
|
|
88
|
+
value += this.advance();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
type: "NUMBER",
|
|
93
|
+
lexeme: value,
|
|
94
|
+
range: { start, end: cloneLocation(this.location) }
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
string() {
|
|
98
|
+
const start = cloneLocation(this.location);
|
|
99
|
+
this.advance();
|
|
100
|
+
let value = "";
|
|
101
|
+
while (!this.isAtEnd() && this.peek() !== "\"") {
|
|
102
|
+
if (this.peek() === "\n") {
|
|
103
|
+
throw new CobolxError({
|
|
104
|
+
message: "Unterminated string literal",
|
|
105
|
+
range: { start, end: cloneLocation(this.location) },
|
|
106
|
+
severity: "error"
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
value += this.advance();
|
|
110
|
+
}
|
|
111
|
+
if (this.isAtEnd()) {
|
|
112
|
+
throw new CobolxError({
|
|
113
|
+
message: "Unterminated string literal",
|
|
114
|
+
range: { start, end: cloneLocation(this.location) },
|
|
115
|
+
severity: "error"
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
this.advance();
|
|
119
|
+
return {
|
|
120
|
+
type: "STRING",
|
|
121
|
+
lexeme: value,
|
|
122
|
+
range: { start, end: cloneLocation(this.location) }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
symbol() {
|
|
126
|
+
const start = cloneLocation(this.location);
|
|
127
|
+
const char = this.advance();
|
|
128
|
+
const emit = (type, lexeme) => ({
|
|
129
|
+
type,
|
|
130
|
+
lexeme,
|
|
131
|
+
range: { start, end: cloneLocation(this.location) }
|
|
132
|
+
});
|
|
133
|
+
switch (char) {
|
|
134
|
+
case "+":
|
|
135
|
+
return emit("PLUS", char);
|
|
136
|
+
case "-":
|
|
137
|
+
return emit("MINUS", char);
|
|
138
|
+
case "*":
|
|
139
|
+
return emit("STAR", char);
|
|
140
|
+
case "/":
|
|
141
|
+
return emit("SLASH", char);
|
|
142
|
+
case "(":
|
|
143
|
+
return emit("LPAREN", char);
|
|
144
|
+
case ")":
|
|
145
|
+
return emit("RPAREN", char);
|
|
146
|
+
case ",":
|
|
147
|
+
return emit("COMMA", char);
|
|
148
|
+
case "=":
|
|
149
|
+
return emit("ASSIGN", char);
|
|
150
|
+
case "!":
|
|
151
|
+
if (this.peek() === "=") {
|
|
152
|
+
this.advance();
|
|
153
|
+
return emit("NOT_EQUAL", "!=");
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "<":
|
|
157
|
+
if (this.peek() === "=") {
|
|
158
|
+
this.advance();
|
|
159
|
+
return emit("LESS_EQUAL", "<=");
|
|
160
|
+
}
|
|
161
|
+
return emit("LESS", char);
|
|
162
|
+
case ">":
|
|
163
|
+
if (this.peek() === "=") {
|
|
164
|
+
this.advance();
|
|
165
|
+
return emit("GREATER_EQUAL", ">=");
|
|
166
|
+
}
|
|
167
|
+
return emit("GREATER", char);
|
|
168
|
+
}
|
|
169
|
+
throw new CobolxError({
|
|
170
|
+
message: `Unexpected character '${char}'`,
|
|
171
|
+
range: { start, end: cloneLocation(this.location) },
|
|
172
|
+
severity: "error"
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
advance() {
|
|
176
|
+
const char = this.source[this.index] ?? "\0";
|
|
177
|
+
this.index += 1;
|
|
178
|
+
this.location.offset += 1;
|
|
179
|
+
if (char === "\n") {
|
|
180
|
+
this.location.line += 1;
|
|
181
|
+
this.location.column = 1;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.location.column += 1;
|
|
185
|
+
}
|
|
186
|
+
return char;
|
|
187
|
+
}
|
|
188
|
+
peek() {
|
|
189
|
+
return this.source[this.index] ?? "\0";
|
|
190
|
+
}
|
|
191
|
+
peekNext() {
|
|
192
|
+
return this.source[this.index + 1] ?? "\0";
|
|
193
|
+
}
|
|
194
|
+
isAtEnd() {
|
|
195
|
+
return this.index >= this.source.length;
|
|
196
|
+
}
|
|
197
|
+
isAlpha(char) {
|
|
198
|
+
return /[A-Za-z_]/.test(char);
|
|
199
|
+
}
|
|
200
|
+
isDigit(char) {
|
|
201
|
+
return /[0-9]/.test(char);
|
|
202
|
+
}
|
|
203
|
+
isAlphaNumeric(char) {
|
|
204
|
+
return this.isAlpha(char) || this.isDigit(char);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=lexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lexer.js","sourceRoot":"","sources":["lexer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,SAAS,aAAa,CAAC,QAAwB;IAC7C,OAAO,EAAE,GAAG,QAAQ,EAAE,CAAC;AACzB,CAAC;AAED,MAAM,OAAO,KAAK;IAIa;IAHrB,KAAK,GAAG,CAAC,CAAC;IACV,QAAQ,GAAmB,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAErE,YA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