Skip to content

Commit

Permalink
Remove ark/index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rrthomas committed Dec 1, 2023
1 parent e1254e6 commit 74eb523
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
8 changes: 0 additions & 8 deletions src/ark/index.ts

This file was deleted.

7 changes: 4 additions & 3 deletions src/ursa/basics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
// Released under the MIT license.

import test from 'ava'

import assert from 'assert'

import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
debug,
ArkState, toJs,
} from '../ark/index.js'
ArkState,
} from '../ark/interpreter.js'
import {toJs} from '../ark/ffi.js'

import {compile, UrsaCompilerError} from './compiler.js'

Expand Down
24 changes: 18 additions & 6 deletions src/ursa/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import {ArgumentParser, RawDescriptionHelpFormatter} from 'argparse'
import assert from 'assert'

import {
debug, ArkState, toJs,
debug, ArkState,
ArkUndefined, ArkNull, ArkObject, ArkList, ArkValRef, ArkString, globals,
Environment, PartialCompiledArk, compile as arkCompile, serializeVal,
} from '../ark/index.js'
} from '../ark/interpreter.js'
import {
Environment, CompiledArk, PartialCompiledArk, compile as arkCompile,
} from '../ark/parser.js'
import {toJs} from '../ark/ffi.js'
import {serializeVal} from '../ark/serialize.js'

import programVersion from '../version.js'
import {runWithTraceback, compile as ursaCompile} from './compiler.js'
Expand Down Expand Up @@ -61,9 +65,17 @@ interface Args {
}
const args: Args = parser.parse_args() as Args

function compile(exp: string, env: Environment = new Environment(), startRule?: string) {
const compiler = args.syntax === 'json' ? arkCompile : ursaCompile
const compiled = compiler(exp, env, startRule)
function compile(
exp: string,
env: Environment = new Environment(),
startRule?: string,
): CompiledArk {
let compiled: CompiledArk
if (args.syntax === 'json') {
compiled = arkCompile(exp, env)
} else {
compiled = ursaCompile(exp, env, startRule)
}
if (process.env.DEBUG) {
console.log('Compiled Ark')
debug(compiled, null)
Expand Down
11 changes: 7 additions & 4 deletions src/ursa/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import grammar, {UrsaSemantics} from '../grammar/ursa.ohm-bundle.js'
import {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
debug,
ArkState, intrinsics, ArkRuntimeError, ArkCompilerError, FreeVars,
ArkVal, ArkExp, ArkNull, ArkBoolean, ArkNumber, ArkString,
ArkState, intrinsics, ArkRuntimeError,
ArkVal, ArkExp, ArkLiteral, ArkNull, ArkBoolean, ArkNumber, ArkString,
ArkSequence, ArkIf, ArkLoop, ArkAnd, ArkOr,
ArkObjectLiteral, ArkListLiteral, ArkMapLiteral,
ArkCall, ArkLet, ArkFn, ArkProperty, ArkGet, ArkSet,
CompiledArk, symRef, Environment, PartialCompiledArk, checkParamList, ArkLiteral,
} from '../ark/index.js'
} from '../ark/interpreter.js'
import {
ArkCompilerError, FreeVars,
CompiledArk, symRef, Environment, PartialCompiledArk, checkParamList,
} from '../ark/parser.js'

// Specify precise type so semantics can be precisely type-checked.
const semantics: UrsaSemantics = grammar.createSemantics()
Expand Down
6 changes: 3 additions & 3 deletions src/ursa/testutil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import test from 'ava'
import tmp from 'tmp'
import {execa} from 'execa'

import {
ArkState, debug, toJs, compile as arkCompile, CompiledArk,
} from '../ark/index.js'
import {ArkState, debug} from '../ark/interpreter.js'
import {compile as arkCompile, CompiledArk} from '../ark/parser.js'
import {toJs} from '../ark/ffi.js'

import {compile as ursaCompile} from './compiler.js'

Expand Down

0 comments on commit 74eb523

Please sign in to comment.