Skip to content

Commit

Permalink
add index.ts
Browse files Browse the repository at this point in the history
+ package entry point
+ evaluate's default export
+ version bump
  • Loading branch information
michal-kapala committed Mar 23, 2024
1 parent c158274 commit f290532
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "jitterbit-script",
"version": "0.2.1",
"version": "0.2.2",
"description": "Static typechecker and interpreter for Jitterbit Script",
"main": "build/main.js",
"main": "build/index.js",
"scripts": {
"build": "tsc --removeComments && tsc --declaration --emitDeclarationOnly",
"exec": "tsc && node ./build/main.js",
Expand Down
2 changes: 1 addition & 1 deletion src/api/functions/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { randomUUID } from "crypto";
import { reverse } from "dns/promises";
import { RuntimeError, UnimplementedError } from "../../errors";
import { Expr } from "../../frontend/ast";
import { evaluate } from "../../runtime/interpreter";
import evaluate from "../../runtime/interpreter";
import { TypedExpr, TypedGlobalIdentifier, TypedIdentifier, TypeInfo } from "../../typechecker/ast";
import TypeEnv from "../../typechecker/environment";

Expand Down
2 changes: 1 addition & 1 deletion src/api/functions/logical.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RuntimeError, UnimplementedError } from "../../errors";
import { Expr } from "../../frontend/ast";
import { evaluate } from "../../runtime/interpreter";
import evaluate from "../../runtime/interpreter";
import Scope from "../../runtime/scope";
import { JbArray, JbBool, JbNull } from "../../runtime/types";
import { RuntimeVal } from "../../runtime/values";
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/ast.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { evaluate } from "../runtime/interpreter";
import evaluate from "../runtime/interpreter";
import Scope from "../runtime/scope";
import { RuntimeVal } from "../runtime/values";
import { Position, Token } from "./types";
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Parser from "./frontend/parser";
import Diagnostic from "./diagnostic";
import Scope from "./runtime/scope";
import evaluate from "./runtime/interpreter";
import Typechecker from "./typechecker/typechecker";

export {Parser, Scope, evaluate, Typechecker, Diagnostic};
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Parser from "./frontend/parser";
import Scope from "./runtime/scope";
import { evaluate } from "./runtime/interpreter";
import evaluate from "./runtime/interpreter";
import fs from "fs";
import Typechecker from "./typechecker/typechecker";
import Diagnostic from "./diagnostic";
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { JbNull } from "./types";
* @param scope the current scope
* @returns
*/
export async function evaluate(astNode: Stmt, scope: Scope) {
export default async function evaluate(astNode: Stmt, scope: Scope) {
switch (astNode.kind) {
case "Program":
return await (astNode as Program).execute(scope);
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
} from "./types";
import { RuntimeVal } from "./values";

/**
* Runtime scope with evaluation results.
*/
export default class Scope {
private parent?: Scope;
private variables: Map<string, RuntimeVal>;
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime/api/sysvars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Api } from "../../../src/api";
import { UnimplementedError } from "../../../src/errors";
import { GlobalIdentifier } from "../../../src/frontend/ast";
import { Position, Token, TokenType } from "../../../src/frontend/types";
import { evaluate } from "../../../src/runtime/interpreter";
import evaluate from "../../../src/runtime/interpreter";
import Scope from "../../../src/runtime/scope";
import { JbBool, JbNull, JbNumber, JbString } from "../../../src/runtime/types";

Expand Down
2 changes: 1 addition & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Parser from "../src/frontend/parser";
import Scope from "../src/runtime/scope";
import { evaluate } from "../src/runtime/interpreter";
import evaluate from "../src/runtime/interpreter";
import { RuntimeVal } from "../src/runtime/values";
import { JbDate, JbDictionary, JbNull, JbString } from "../src/runtime/types";
import { Expr, Program } from "../src/frontend/ast";
Expand Down

0 comments on commit f290532

Please sign in to comment.