diff --git a/package.json b/package.json index aea2919..87093d6 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"], diff --git a/src/ec-evaluator/index.ts b/src/ec-evaluator/index.ts index 72d9115..c133dcb 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 61d2c4e..e32b7ec 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +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 { JVM } +export { astToString, ECE, JVM, typeCheck, compile, compileFromSource } diff --git a/src/types/index.ts b/src/types/index.ts index 409819b..d7d680f 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) - }) -}