From 23f3ab313deefd55ec65ba89d9e4e56b9b4b84b0 Mon Sep 17 00:00:00 2001 From: Bryan Loh Date: Sat, 13 Apr 2024 14:24:25 +0800 Subject: [PATCH 1/5] Export typeCheck method from src index.js --- src/index.ts | 3 ++- src/types/index.ts | 22 +++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/index.ts b/src/index.ts index 61d2c4e8..3602740e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ import * as JVM from './jvm' +import { typeCheck } from './types' -export { JVM } +export { JVM, typeCheck } diff --git a/src/types/index.ts b/src/types/index.ts index 409819bc..d7d680f6 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,25 +1,21 @@ import { check } from './checker' -import { Node } from './ast/types' import { parse } from './ast' import { TypeCheckerError } from './errors' -export type TypeCheckResult = { hasTypeErrors: boolean; errors: Error[] } +type TypeCheckResult = { hasTypeErrors: boolean; errorMsgs: string[] } -export const parseProgram = (program: string): Node => { - return parse(program) +const convertErrorsToReadableMsgs = (program: string, errors: Error[]): string[] => { + return errors.map(error => { + if (!(error instanceof TypeCheckerError)) return error.message + return error.toReadableMessage(program) + }) } -export const typeCheck = (ast: Node): TypeCheckResult => { +export const typeCheck = (program: string): TypeCheckResult => { + const ast = parse(program) const result = check(ast) return { hasTypeErrors: result.errors.length > 0, - errors: result.errors + errorMsgs: convertErrorsToReadableMsgs(program, result.errors) } } - -export const convertErrorsToReadableMsgs = (program: string, errors: Error[]): string[] => { - return errors.map(error => { - if (!(error instanceof TypeCheckerError)) return error.message - return error.toReadableMessage(program) - }) -} From 5294aa07f95a4aaa17abed887767174468f12aad Mon Sep 17 00:00:00 2001 From: Bryan Loh Date: Sat, 13 Apr 2024 14:24:52 +0800 Subject: [PATCH 2/5] Bump java-slang to 1.0.13 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aea29190..87093d66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "java-slang", - "version": "1.0.12", + "version": "1.0.13", "main": "dist/index.js", "types": "dist/index.d.ts", "files": ["dist"], From b672b81aa61257ccba4a756bad8c655348f36351 Mon Sep 17 00:00:00 2001 From: 1001mei <77192251+1001mei@users.noreply.github.com> Date: Sat, 13 Apr 2024 14:49:45 +0800 Subject: [PATCH 3/5] Add compiler exports to index.ts --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 3602740e..869fe79b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import * as JVM from './jvm' import { typeCheck } from './types' +import { compile, compileFromSource} from './compiler' -export { JVM, typeCheck } +export { JVM, typeCheck, compile, compileFromSource } From ac8ab70ff3de22a64dcd5a36cf4232fcdd291b5c Mon Sep 17 00:00:00 2001 From: xyliew25 Date: Sat, 13 Apr 2024 14:59:17 +0800 Subject: [PATCH 4/5] Add ece exports to index.ts --- src/ec-evaluator/index.ts | 5 +++++ src/index.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ec-evaluator/index.ts b/src/ec-evaluator/index.ts index 72d9115b..c133dcbb 100644 --- a/src/ec-evaluator/index.ts +++ b/src/ec-evaluator/index.ts @@ -5,6 +5,11 @@ import { RuntimeError } from "./errors"; import { evaluate } from "./interpreter"; import { Context, Error, Finished, Result } from "./types"; +export * from './components'; +export * from './errors'; +export * from './types'; +export { isInstr, isNode } from './utils'; + export const runECEvaluator = ( code: string, targetStep: number = STEP_LIMIT, diff --git a/src/index.ts b/src/index.ts index 869fe79b..1a04929b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,6 @@ +import * as ECE from './ec-evaluator' import * as JVM from './jvm' import { typeCheck } from './types' import { compile, compileFromSource} from './compiler' -export { JVM, typeCheck, compile, compileFromSource } +export { ECE, JVM, typeCheck, compile, compileFromSource } From 07c718302065d234bc2639985c26eda8526c68f3 Mon Sep 17 00:00:00 2001 From: xyliew25 Date: Sat, 13 Apr 2024 15:07:48 +0800 Subject: [PATCH 5/5] Export astToString --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 1a04929b..e32b7ec8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ +import { astToString } from './ast/utils/astToString' import * as ECE from './ec-evaluator' import * as JVM from './jvm' import { typeCheck } from './types' import { compile, compileFromSource} from './compiler' -export { ECE, JVM, typeCheck, compile, compileFromSource } +export { astToString, ECE, JVM, typeCheck, compile, compileFromSource }