Repository: source-academy/js-slang
Pull request #426 (2020-03-03 14:24:18)

Refactor folders

coveralls: ## Pull Request Test Coverage Report for [Build 2025](https://coveralls.io/builds/29099866)

* **85** of **87**   **(97.7%)**  changed or added relevant lines in **38** files are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.02%**) to **88.448%**

---

|  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
| :-----|--------------|--------|---: |
| [src/errors/runtimeSourceError.ts](https://coveralls.io/builds/29099866/source?filename=src%2Ferrors%2FruntimeSourceError.ts#L15) | 6 | 8 | 75.0%
<!-- | **Total:** | **85** | **87** | **97.7%** | -->


|  Totals | [![Coverage Status](https://coveralls.io/builds/29099866/badge)](https://coveralls.io/builds/29099866) |
| :-- | --: |
| Change from base [Build 2009](https://coveralls.io/builds/29098243): |  0.02% |
| Covered Lines: | 2177 |
| Relevant Lines: | 2388 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/src/createContext.ts b/src/createContext.ts
index 50a01247..0e44bd7d 100644
--- a/src/createContext.ts
+++ b/src/createContext.ts
@@ -1,7 +1,6 @@
 // Variable determining chapter of Source is contained in this file.
 
 import { GLOBAL, GLOBAL_KEY_TO_ACCESS_NATIVE_STORAGE } from './constants'
-import { stringify } from './interop'
 import { AsyncScheduler } from './schedulers'
 import * as list from './stdlib/list'
 import { list_to_vector } from './stdlib/list'
@@ -12,6 +11,7 @@ import * as stream from './stdlib/stream'
 import { streamPrelude } from './stdlib/stream.prelude'
 import { Context, CustomBuiltIns, Value } from './types'
 import * as operators from './utils/operators'
+import { stringify } from './utils/stringify'
 
 const createEmptyRuntime = () => ({
   break: false,
diff --git a/src/interpreter-errors.ts b/src/errors/errors.ts
similarity index 92%
rename from src/interpreter-errors.ts
rename to src/errors/errors.ts
index da9b24c5..32ed89b4 100644
--- a/src/interpreter-errors.ts
+++ b/src/errors/errors.ts
@@ -2,28 +2,9 @@
 /* tslint:disable:max-line-length */
 import { baseGenerator, generate } from 'astring'
 import * as es from 'estree'
-
-import { UNKNOWN_LOCATION } from './constants'
-import { stringify } from './interop'
-import { ErrorSeverity, ErrorType, SourceError, Value } from './types'
-
-export class RuntimeSourceError implements SourceError {
-  public type = ErrorType.RUNTIME
-  public severity = ErrorSeverity.ERROR
-  public location: es.SourceLocation
-
-  constructor(node?: es.Node) {
-    this.location = node ? node.loc! : UNKNOWN_LOCATION
-  }
-
-  public explain() {
-    return ''
-  }
-
-  public elaborate() {
-    return this.explain()
-  }
-}
+import { ErrorSeverity, ErrorType, SourceError, Value } from '../types'
+import { stringify } from '../utils/stringify'
+import { RuntimeSourceError } from './runtimeSourceError'
 
 export class InterruptedError extends RuntimeSourceError {
   constructor(node: es.Node) {
diff --git a/src/errors/runtimeSourceError.ts b/src/errors/runtimeSourceError.ts
new file mode 100644
index 00000000..d863caa4
--- /dev/null
+++ b/src/errors/runtimeSourceError.ts
@@ -0,0 +1,21 @@
+import * as es from 'estree'
+import { UNKNOWN_LOCATION } from '../constants'
+import { ErrorSeverity, ErrorType, SourceError } from '../types'
+
+export class RuntimeSourceError implements SourceError {
+  public type = ErrorType.RUNTIME
+  public severity = ErrorSeverity.ERROR
+  public location: es.SourceLocation
+
+  constructor(node?: es.Node) {
+    this.location = node ? node.loc! : UNKNOWN_LOCATION
+  }
+
+  public explain() {
+    return ''
+  }
+
+  public elaborate() {
+    return this.explain()
+  }
+}
diff --git a/src/native-errors.ts b/src/errors/timeoutErrors.ts
similarity index 85%
rename from src/native-errors.ts
rename to src/errors/timeoutErrors.ts
index 1a588a88..5212004c 100644
--- a/src/native-errors.ts
+++ b/src/errors/timeoutErrors.ts
@@ -1,11 +1,11 @@
 /* tslint:disable:max-classes-per-file */
 import * as es from 'estree'
-import { JSSLANG_PROPERTIES } from './constants'
-import { stringify } from './interop'
+import { JSSLANG_PROPERTIES } from '../constants'
+import { stringify } from '../utils/stringify'
 
-import { RuntimeSourceError } from './interpreter-errors'
-import { ErrorSeverity, ErrorType } from './types'
-import { stripIndent } from './utils/formatters'
+import { ErrorSeverity, ErrorType } from '../types'
+import { stripIndent } from '../utils/formatters'
+import { RuntimeSourceError } from './runtimeSourceError'
 
 function getWarningMessage() {
   const from = JSSLANG_PROPERTIES.maxExecTime / 1000
diff --git a/src/index.ts b/src/index.ts
index 1e72ab6e..ff668cb6 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,19 +3,20 @@ import { DebuggerStatement, Literal, Program } from 'estree'
 import { RawSourceMap, SourceMapConsumer } from 'source-map'
 import { JSSLANG_PROPERTIES, UNKNOWN_LOCATION } from './constants'
 import createContext from './createContext'
-import { evaluate } from './interpreter'
 import {
   ConstAssignment,
   ExceptionError,
   InterruptedError,
-  RuntimeSourceError,
   UndefinedVariable
-} from './interpreter-errors'
-import { parse, parseAt } from './parser'
+} from './errors/errors'
+import { RuntimeSourceError } from './errors/runtimeSourceError'
+import { evaluate } from './interpreter/interpreter'
+import { parse, parseAt } from './parser/parser'
 import { AsyncScheduler, PreemptiveScheduler } from './schedulers'
 import { areBreakpointsSet, setBreakpointAtLine } from './stdlib/inspector'
-import { codify, getEvaluationSteps } from './substituter'
-import { transpile } from './transpiler'
+import { codify, getEvaluationSteps } from './stepper/stepper'
+import { sandboxedEval } from './transpiler/evalContainer'
+import { transpile } from './transpiler/transpiler'
 import {
   Context,
   Error as ResultError,
@@ -26,7 +27,6 @@ import {
   SourceError
 } from './types'
 import { locationDummyNode } from './utils/astCreator'
-import { sandboxedEval } from './utils/evalContainer'
 
 export interface IOptions {
   scheduler: 'preemptive' | 'async'
diff --git a/src/closure.ts b/src/interpreter/closure.ts
similarity index 94%
rename from src/closure.ts
rename to src/interpreter/closure.ts
index f84fe0df..5f0f2d20 100644
--- a/src/closure.ts
+++ b/src/interpreter/closure.ts
@@ -2,9 +2,14 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
+import { Context, Environment, Value } from '../types'
+import {
+  blockArrowFunction,
+  callExpression,
+  identifier,
+  returnStatement
+} from '../utils/astCreator'
 import { apply } from './interpreter'
-import { Context, Environment, Value } from './types'
-import { blockArrowFunction, callExpression, identifier, returnStatement } from './utils/astCreator'
 
 const closureToJS = (value: Closure, context: Context, klass: string) => {
   function DummyClass(this: Closure) {
diff --git a/src/interpreter.ts b/src/interpreter/interpreter.ts
similarity index 97%
rename from src/interpreter.ts
rename to src/interpreter/interpreter.ts
index 57bc6fbc..9cefb9a3 100644
--- a/src/interpreter.ts
+++ b/src/interpreter/interpreter.ts
@@ -1,13 +1,14 @@
 /* tslint:disable:max-classes-per-file */
 import * as es from 'estree'
+import * as constants from '../constants'
+import * as errors from '../errors/errors'
+import { RuntimeSourceError } from '../errors/runtimeSourceError'
+import { checkEditorBreakpoints } from '../stdlib/inspector'
+import { Context, Environment, Frame, Value } from '../types'
+import { conditionalExpression, literal, primitive } from '../utils/astCreator'
+import { evaluateBinaryExpression, evaluateUnaryExpression } from '../utils/operators'
+import * as rttc from '../utils/rttc'
 import Closure from './closure'
-import * as constants from './constants'
-import * as errors from './interpreter-errors'
-import { checkEditorBreakpoints } from './stdlib/inspector'
-import { Context, Environment, Frame, Value } from './types'
-import { conditionalExpression, literal, primitive } from './utils/astCreator'
-import { evaluateBinaryExpression, evaluateUnaryExpression } from './utils/operators'
-import * as rttc from './utils/rttc'
 
 class BreakValue {}
 
@@ -57,7 +58,7 @@ const createBlockEnvironment = (
   }
 }
 
-const handleRuntimeError = (context: Context, error: errors.RuntimeSourceError): never => {
+const handleRuntimeError = (context: Context, error: RuntimeSourceError): never => {
   context.errors.push(error)
   context.runtime.environments = context.runtime.environments.slice(
     -context.numberOfOuterEnvironments
@@ -619,7 +620,7 @@ export function* apply(
         )
 
         const loc = node ? node.loc! : constants.UNKNOWN_LOCATION
-        if (!(e instanceof errors.RuntimeSourceError || e instanceof errors.ExceptionError)) {
+        if (!(e instanceof RuntimeSourceError || e instanceof errors.ExceptionError)) {
           // The error could've arisen when the builtin called a source function which errored.
           // If the cause was a source error, we don't want to include the error.
           // However if the error came from the builtin itself, we need to handle it.
diff --git a/src/mocks/context.ts b/src/mocks/context.ts
index 41d4d320..e64758e7 100644
--- a/src/mocks/context.ts
+++ b/src/mocks/context.ts
@@ -1,7 +1,7 @@
 import * as es from 'estree'
 
-import Closure from '../closure'
 import createContext from '../createContext'
+import Closure from '../interpreter/closure'
 import { Context, Environment } from '../types'
 
 export function mockContext(chapter = 1): Context {
diff --git a/src/parser.ts b/src/parser/parser.ts
similarity index 98%
rename from src/parser.ts
rename to src/parser/parser.ts
index 686744e2..094457f2 100644
--- a/src/parser.ts
+++ b/src/parser/parser.ts
@@ -7,10 +7,10 @@ import {
 } from 'acorn'
 import { ancestor, AncestorWalker } from 'acorn-walk/dist/walk'
 import * as es from 'estree'
+import { Context, ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { stripIndent } from '../utils/formatters'
 import rules from './rules'
 import syntaxBlacklist from './syntaxBlacklist'
-import { Context, ErrorSeverity, ErrorType, Rule, SourceError } from './types'
-import { stripIndent } from './utils/formatters'
 
 export class DisallowedConstructError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/bracesAroundFor.ts b/src/parser/rules/bracesAroundFor.ts
similarity index 99%
rename from src/rules/bracesAroundFor.ts
rename to src/parser/rules/bracesAroundFor.ts
index bf94b18a..4bddc07e 100644
--- a/src/rules/bracesAroundFor.ts
+++ b/src/parser/rules/bracesAroundFor.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class BracesAroundForError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/bracesAroundIfElse.ts b/src/parser/rules/bracesAroundIfElse.ts
similarity index 97%
rename from src/rules/bracesAroundIfElse.ts
rename to src/parser/rules/bracesAroundIfElse.ts
index 0f53915a..ffed50cf 100644
--- a/src/rules/bracesAroundIfElse.ts
+++ b/src/parser/rules/bracesAroundIfElse.ts
@@ -1,8 +1,8 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
-import { stripIndent } from '../utils/formatters'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
+import { stripIndent } from '../../utils/formatters'
 
 export class BracesAroundIfElseError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/bracesAroundWhile.ts b/src/parser/rules/bracesAroundWhile.ts
similarity index 99%
rename from src/rules/bracesAroundWhile.ts
rename to src/parser/rules/bracesAroundWhile.ts
index 65842215..73228f73 100644
--- a/src/rules/bracesAroundWhile.ts
+++ b/src/parser/rules/bracesAroundWhile.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class BracesAroundWhileError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/forStatementMustHaveAllParts.ts b/src/parser/rules/forStatementMustHaveAllParts.ts
similarity index 94%
rename from src/rules/forStatementMustHaveAllParts.ts
rename to src/parser/rules/forStatementMustHaveAllParts.ts
index d30ac744..ce79d0c0 100644
--- a/src/rules/forStatementMustHaveAllParts.ts
+++ b/src/parser/rules/forStatementMustHaveAllParts.ts
@@ -1,7 +1,7 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
-import { stripIndent } from '../utils/formatters'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
+import { stripIndent } from '../../utils/formatters'
 
 export class ForStatmentMustHaveAllParts implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/index.ts b/src/parser/rules/index.ts
similarity index 97%
rename from src/rules/index.ts
rename to src/parser/rules/index.ts
index bc699eb9..89b2dc6a 100644
--- a/src/rules/index.ts
+++ b/src/parser/rules/index.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { Rule } from '../types'
+import { Rule } from '../../types'
 
 import bracesAroundFor from './bracesAroundFor'
 import bracesAroundIfElse from './bracesAroundIfElse'
diff --git a/src/rules/noAssignmentExpression.ts b/src/parser/rules/noAssignmentExpression.ts
similarity index 99%
rename from src/rules/noAssignmentExpression.ts
rename to src/parser/rules/noAssignmentExpression.ts
index 85ecf91a..af4af130 100644
--- a/src/rules/noAssignmentExpression.ts
+++ b/src/parser/rules/noAssignmentExpression.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoAssignmentExpression implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noDeclareMutable.ts b/src/parser/rules/noDeclareMutable.ts
similarity index 99%
rename from src/rules/noDeclareMutable.ts
rename to src/parser/rules/noDeclareMutable.ts
index f6181a94..6ed8262d 100644
--- a/src/rules/noDeclareMutable.ts
+++ b/src/parser/rules/noDeclareMutable.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 const mutableDeclarators = ['let', 'var']
 
diff --git a/src/rules/noDotAbbreviation.ts b/src/parser/rules/noDotAbbreviation.ts
similarity index 98%
rename from src/rules/noDotAbbreviation.ts
rename to src/parser/rules/noDotAbbreviation.ts
index 23f6fc8d..c95394c5 100644
--- a/src/rules/noDotAbbreviation.ts
+++ b/src/parser/rules/noDotAbbreviation.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoDotAbbreviationError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noEval.ts b/src/parser/rules/noEval.ts
similarity index 98%
rename from src/rules/noEval.ts
rename to src/parser/rules/noEval.ts
index 1cde9b82..e88b29ff 100644
--- a/src/rules/noEval.ts
+++ b/src/parser/rules/noEval.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoEval implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noIfWithoutElse.ts b/src/parser/rules/noIfWithoutElse.ts
similarity index 94%
rename from src/rules/noIfWithoutElse.ts
rename to src/parser/rules/noIfWithoutElse.ts
index 5e80a541..d4575512 100644
--- a/src/rules/noIfWithoutElse.ts
+++ b/src/parser/rules/noIfWithoutElse.ts
@@ -1,8 +1,8 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
-import { stripIndent } from '../utils/formatters'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
+import { stripIndent } from '../../utils/formatters'
 
 export class NoIfWithoutElseError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noImplicitDeclareUndefined.ts b/src/parser/rules/noImplicitDeclareUndefined.ts
similarity index 94%
rename from src/rules/noImplicitDeclareUndefined.ts
rename to src/parser/rules/noImplicitDeclareUndefined.ts
index 6b0d7b03..6348665a 100644
--- a/src/rules/noImplicitDeclareUndefined.ts
+++ b/src/parser/rules/noImplicitDeclareUndefined.ts
@@ -1,7 +1,7 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
-import { stripIndent } from '../utils/formatters'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
+import { stripIndent } from '../../utils/formatters'
 
 export class NoImplicitDeclareUndefinedError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noImplicitReturnUndefined.ts b/src/parser/rules/noImplicitReturnUndefined.ts
similarity index 93%
rename from src/rules/noImplicitReturnUndefined.ts
rename to src/parser/rules/noImplicitReturnUndefined.ts
index 2f2ebe5a..26233365 100644
--- a/src/rules/noImplicitReturnUndefined.ts
+++ b/src/parser/rules/noImplicitReturnUndefined.ts
@@ -1,7 +1,7 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
-import { stripIndent } from '../utils/formatters'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
+import { stripIndent } from '../../utils/formatters'
 
 export class NoImplicitReturnUndefinedError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noNull.ts b/src/parser/rules/noNull.ts
similarity index 98%
rename from src/rules/noNull.ts
rename to src/parser/rules/noNull.ts
index eb51748c..49419434 100644
--- a/src/rules/noNull.ts
+++ b/src/parser/rules/noNull.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoNullError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noUnspecifiedLiteral.ts b/src/parser/rules/noUnspecifiedLiteral.ts
similarity index 99%
rename from src/rules/noUnspecifiedLiteral.ts
rename to src/parser/rules/noUnspecifiedLiteral.ts
index da1c9ff9..aecdac6e 100644
--- a/src/rules/noUnspecifiedLiteral.ts
+++ b/src/parser/rules/noUnspecifiedLiteral.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 const specifiedLiterals = ['boolean', 'string', 'number']
 
diff --git a/src/rules/noUnspecifiedOperator.ts b/src/parser/rules/noUnspecifiedOperator.ts
similarity index 99%
rename from src/rules/noUnspecifiedOperator.ts
rename to src/parser/rules/noUnspecifiedOperator.ts
index e76b4bcd..df8977d5 100644
--- a/src/rules/noUnspecifiedOperator.ts
+++ b/src/parser/rules/noUnspecifiedOperator.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoUnspecifiedOperatorError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noUpdateAssignment.ts b/src/parser/rules/noUpdateAssignment.ts
similarity index 99%
rename from src/rules/noUpdateAssignment.ts
rename to src/parser/rules/noUpdateAssignment.ts
index dac77366..856246a1 100644
--- a/src/rules/noUpdateAssignment.ts
+++ b/src/parser/rules/noUpdateAssignment.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoUpdateAssignment implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/noVar.ts b/src/parser/rules/noVar.ts
similarity index 99%
rename from src/rules/noVar.ts
rename to src/parser/rules/noVar.ts
index 16c7539c..fcbff2cc 100644
--- a/src/rules/noVar.ts
+++ b/src/parser/rules/noVar.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class NoVarError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/singleVariableDeclaration.ts b/src/parser/rules/singleVariableDeclaration.ts
similarity index 99%
rename from src/rules/singleVariableDeclaration.ts
rename to src/parser/rules/singleVariableDeclaration.ts
index 8579eccf..71d5e051 100644
--- a/src/rules/singleVariableDeclaration.ts
+++ b/src/parser/rules/singleVariableDeclaration.ts
@@ -1,7 +1,7 @@
 import { generate } from 'astring'
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class MultipleDeclarationsError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/rules/strictEquality.ts b/src/parser/rules/strictEquality.ts
similarity index 98%
rename from src/rules/strictEquality.ts
rename to src/parser/rules/strictEquality.ts
index 1b26035a..147f6203 100644
--- a/src/rules/strictEquality.ts
+++ b/src/parser/rules/strictEquality.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 
-import { ErrorSeverity, ErrorType, Rule, SourceError } from '../types'
+import { ErrorSeverity, ErrorType, Rule, SourceError } from '../../types'
 
 export class StrictEqualityError implements SourceError {
   public type = ErrorType.SYNTAX
diff --git a/src/syntaxBlacklist.ts b/src/parser/syntaxBlacklist.ts
similarity index 100%
rename from src/syntaxBlacklist.ts
rename to src/parser/syntaxBlacklist.ts
diff --git a/src/schedulers.ts b/src/schedulers.ts
index b3eef770..5c5fad15 100644
--- a/src/schedulers.ts
+++ b/src/schedulers.ts
@@ -1,5 +1,5 @@
 /* tslint:disable:max-classes-per-file */
-import { MaximumStackLimitExceeded } from './interpreter-errors'
+import { MaximumStackLimitExceeded } from './errors/errors'
 import { saveState } from './stdlib/inspector'
 import { Context, Result, Scheduler, Value } from './types'
 
diff --git a/src/stdlib/list.ts b/src/stdlib/list.ts
index 2030c7b9..d2a596f3 100644
--- a/src/stdlib/list.ts
+++ b/src/stdlib/list.ts
@@ -1,4 +1,4 @@
-import { stringify } from '../interop'
+import { stringify } from '../utils/stringify'
 
 // list.ts: Supporting lists in the Scheme style, using pairs made
 //          up of two-element JavaScript array (vector)
diff --git a/src/stdlib/misc.ts b/src/stdlib/misc.ts
index f2526070..b5bc3181 100644
--- a/src/stdlib/misc.ts
+++ b/src/stdlib/misc.ts
@@ -1,5 +1,5 @@
-import { stringify } from '../interop'
 import { Context, Value } from '../types'
+import { stringify } from '../utils/stringify'
 
 /**
  * A function that displays to console.log by default (for a REPL).
diff --git a/src/stdlib/parser.ts b/src/stdlib/parser.ts
index c171236c..b7a57f82 100644
--- a/src/stdlib/parser.ts
+++ b/src/stdlib/parser.ts
@@ -1,7 +1,7 @@
 import * as es from 'estree'
 
-import { parse as sourceParse } from '../parser'
-import { libraryParserLanguage } from '../syntaxBlacklist'
+import { parse as sourceParse } from '../parser/parser'
+import { libraryParserLanguage } from '../parser/syntaxBlacklist'
 import { Context, Value } from '../types'
 import { oneLine } from '../utils/formatters'
 import { vector_to_list } from './list'
diff --git a/src/utils/converter.ts b/src/stepper/converter.ts
similarity index 84%
rename from src/utils/converter.ts
rename to src/stepper/converter.ts
index 65e48e5d..2101828e 100644
--- a/src/utils/converter.ts
+++ b/src/stepper/converter.ts
@@ -1,10 +1,10 @@
 import * as es from 'estree'
 import { mockContext } from '../mocks/context'
-import { parse } from '../parser'
-import { codify } from '../substituter'
+import { parse } from '../parser/parser'
 import { Context, substituterNodes } from '../types'
-import * as util from './substituter'
-import * as builtin from './substStdLib'
+import * as builtin from './lib'
+import { codify } from './stepper'
+import * as util from './util'
 
 // the value in the parameter is not an ast node, but a underlying javascript value
 // return by evaluateBinaryExpression and evaluateUnaryExpression.
diff --git a/src/utils/substStdLib.ts b/src/stepper/lib.ts
similarity index 96%
rename from src/utils/substStdLib.ts
rename to src/stepper/lib.ts
index 7c3887de..becfed40 100644
--- a/src/utils/substStdLib.ts
+++ b/src/stepper/lib.ts
@@ -1,10 +1,10 @@
 import * as es from 'estree'
 import * as misc from '../stdlib/misc'
-import { codify } from '../substituter'
 import { substituterNodes } from '../types'
-import * as ast from './astCreator'
+import * as ast from '../utils/astCreator'
 import { nodeToValue, valueToExpression } from './converter'
-import { isBuiltinFunction, isNumber } from './substituter'
+import { codify } from './stepper'
+import { isBuiltinFunction, isNumber } from './util'
 
 // define builtins that takes in AST, and return AST
 //
@@ -71,7 +71,8 @@ export function parse_int(str: substituterNodes, radix: substituterNodes): es.Ex
   if (
     str.type === 'Literal' &&
     typeof str.value === 'string' &&
-    (radix.type === 'Literal' && typeof radix.value === 'number') &&
+    radix.type === 'Literal' &&
+    typeof radix.value === 'number' &&
     Number.isInteger(radix.value) &&
     2 <= radix.value &&
     radix.value <= 36
diff --git a/src/substituter.ts b/src/stepper/stepper.ts
similarity index 98%
rename from src/substituter.ts
rename to src/stepper/stepper.ts
index 23db3aa1..5e833879 100644
--- a/src/substituter.ts
+++ b/src/stepper/stepper.ts
@@ -1,10 +1,9 @@
 import { generate } from 'astring'
 import * as es from 'estree'
-import * as errors from './interpreter-errors'
-import { parse } from './parser'
-import { BlockExpression, Context, FunctionDeclarationExpression, substituterNodes } from './types'
-import * as ast from './utils/astCreator'
-import { nodeToValue, valueToExpression } from './utils/converter'
+import * as errors from '../errors/errors'
+import { parse } from '../parser/parser'
+import { BlockExpression, Context, FunctionDeclarationExpression, substituterNodes } from '../types'
+import * as ast from '../utils/astCreator'
 import {
   dummyBlockExpression,
   dummyBlockStatement,
@@ -12,16 +11,12 @@ import {
   dummyProgram,
   dummyStatement,
   dummyVariableDeclarator
-} from './utils/dummyAstCreator'
-import { evaluateBinaryExpression, evaluateUnaryExpression } from './utils/operators'
-import * as rttc from './utils/rttc'
-import {
-  getDeclaredNames,
-  isAllowedLiterals,
-  isBuiltinFunction,
-  isNegNumber
-} from './utils/substituter'
-import * as builtin from './utils/substStdLib'
+} from '../utils/dummyAstCreator'
+import { evaluateBinaryExpression, evaluateUnaryExpression } from '../utils/operators'
+import * as rttc from '../utils/rttc'
+import { nodeToValue, valueToExpression } from './converter'
+import * as builtin from './lib'
+import { getDeclaredNames, isAllowedLiterals, isBuiltinFunction, isNegNumber } from './util'
 
 const irreducibleTypes = new Set<string>([
   'Literal',
diff --git a/src/utils/substituter.ts b/src/stepper/util.ts
similarity index 97%
rename from src/utils/substituter.ts
rename to src/stepper/util.ts
index cc7612f2..8995a58c 100644
--- a/src/utils/substituter.ts
+++ b/src/stepper/util.ts
@@ -1,6 +1,6 @@
 import * as es from 'estree'
 import { BlockExpression, substituterNodes } from '../types'
-import * as builtin from './substStdLib'
+import * as builtin from './lib'
 
 export function isBuiltinFunction(node: substituterNodes): boolean {
   return (
diff --git a/src/utils/evalContainer.ts b/src/transpiler/evalContainer.ts
similarity index 100%
rename from src/utils/evalContainer.ts
rename to src/transpiler/evalContainer.ts
diff --git a/src/transpiler.ts b/src/transpiler/transpiler.ts
similarity index 99%
rename from src/transpiler.ts
rename to src/transpiler/transpiler.ts
index b99d5357..47fce39a 100644
--- a/src/transpiler.ts
+++ b/src/transpiler/transpiler.ts
@@ -4,10 +4,10 @@ import { ancestor, simple } from 'acorn-walk/dist/walk'
 import { generate } from 'astring'
 import * as es from 'estree'
 import { RawSourceMap, SourceMapGenerator } from 'source-map'
-import { GLOBAL, GLOBAL_KEY_TO_ACCESS_NATIVE_STORAGE } from './constants'
-import { AllowedDeclarations, Value } from './types'
-import * as create from './utils/astCreator'
-import { ConstAssignment, UndefinedVariable } from './interpreter-errors'
+import { GLOBAL, GLOBAL_KEY_TO_ACCESS_NATIVE_STORAGE } from '../constants'
+import { AllowedDeclarations, Value } from '../types'
+import * as create from '../utils/astCreator'
+import { ConstAssignment, UndefinedVariable } from '../errors/errors'
 
 /**
  * This whole transpiler includes many many many many hacks to get stuff working.
diff --git a/src/utils/operators.ts b/src/utils/operators.ts
index 6bc24bda..b20b8535 100644
--- a/src/utils/operators.ts
+++ b/src/utils/operators.ts
@@ -4,10 +4,13 @@ import {
   CallingNonFunctionValue,
   ExceptionError,
   GetInheritedPropertyError,
-  InvalidNumberOfArguments,
-  RuntimeSourceError
-} from '../interpreter-errors'
-import { PotentialInfiniteLoopError, PotentialInfiniteRecursionError } from '../native-errors'
+  InvalidNumberOfArguments
+} from '../errors/errors'
+import { RuntimeSourceError } from '../errors/runtimeSourceError'
+import {
+  PotentialInfiniteLoopError,
+  PotentialInfiniteRecursionError
+} from '../errors/timeoutErrors'
 import { callExpression, locationDummyNode } from './astCreator'
 import * as create from './astCreator'
 import * as rttc from './rttc'
diff --git a/src/utils/rttc.ts b/src/utils/rttc.ts
index 7dd775ed..391a8ca8 100644
--- a/src/utils/rttc.ts
+++ b/src/utils/rttc.ts
@@ -1,5 +1,5 @@
 import * as es from 'estree'
-import { RuntimeSourceError } from '../interpreter-errors'
+import { RuntimeSourceError } from '../errors/runtimeSourceError'
 import { ErrorSeverity, ErrorType, Value } from '../types'
 
 const LHS = ' on left hand side of operation'
diff --git a/src/interop.ts b/src/utils/stringify.ts
similarity index 96%
rename from src/interop.ts
rename to src/utils/stringify.ts
index 02ff53af..923ef1c6 100644
--- a/src/interop.ts
+++ b/src/utils/stringify.ts
@@ -1,6 +1,6 @@
-import Closure from './closure'
-import { MAX_LIST_DISPLAY_LENGTH } from './constants'
-import { Value } from './types'
+import { MAX_LIST_DISPLAY_LENGTH } from '../constants'
+import Closure from '../interpreter/closure'
+import { Value } from '../types'
 
 function makeIndent(indent: number | string): string {
   if (typeof indent === 'number') {


Test patch:
diff --git a/src/__tests__/environment.ts b/src/__tests__/environment.ts
index d0cffd8d..606e074d 100644
--- a/src/__tests__/environment.ts
+++ b/src/__tests__/environment.ts
@@ -1,7 +1,7 @@
 import { Program } from 'estree'
-import { evaluate } from '../interpreter'
+import { evaluate } from '../interpreter/interpreter'
 import { mockContext } from '../mocks/context'
-import { parse } from '../parser'
+import { parse } from '../parser/parser'
 import { stripIndent } from '../utils/formatters'
 
 test('Function params and body identifiers are in the same environment', () => {
diff --git a/src/__tests__/__snapshots__/interpreter-errors.ts.snap b/src/interpreter/__tests__/__snapshots__/interpreter-errors.ts.snap
similarity index 100%
rename from src/__tests__/__snapshots__/interpreter-errors.ts.snap
rename to src/interpreter/__tests__/__snapshots__/interpreter-errors.ts.snap
diff --git a/src/__tests__/interpreter-errors.ts b/src/interpreter/__tests__/interpreter-errors.ts
similarity index 99%
rename from src/__tests__/interpreter-errors.ts
rename to src/interpreter/__tests__/interpreter-errors.ts
index bd6b8b2b..59f9ac1f 100644
--- a/src/__tests__/interpreter-errors.ts
+++ b/src/interpreter/__tests__/interpreter-errors.ts
@@ -1,11 +1,11 @@
 /* tslint:disable:max-line-length */
-import { stripIndent } from '../utils/formatters'
+import { stripIndent } from '../../utils/formatters'
 import {
   expectDifferentParsedErrors,
   expectParsedError,
   expectParsedErrorNoSnapshot,
   expectResult
-} from '../utils/testing'
+} from '../../utils/testing'
 
 const undefinedVariable = stripIndent`
 im_undefined;
diff --git a/src/__tests__/__snapshots__/allowed-syntax.ts.snap b/src/parser/__tests__/__snapshots__/allowed-syntax.ts.snap
similarity index 100%
rename from src/__tests__/__snapshots__/allowed-syntax.ts.snap
rename to src/parser/__tests__/__snapshots__/allowed-syntax.ts.snap
diff --git a/src/__tests__/__snapshots__/disallowed-syntax.ts.snap b/src/parser/__tests__/__snapshots__/disallowed-syntax.ts.snap
similarity index 100%
rename from src/__tests__/__snapshots__/disallowed-syntax.ts.snap
rename to src/parser/__tests__/__snapshots__/disallowed-syntax.ts.snap
diff --git a/src/__tests__/allowed-syntax.ts b/src/parser/__tests__/allowed-syntax.ts
similarity index 95%
rename from src/__tests__/allowed-syntax.ts
rename to src/parser/__tests__/allowed-syntax.ts
index 87afb154..f5490078 100644
--- a/src/__tests__/allowed-syntax.ts
+++ b/src/parser/__tests__/allowed-syntax.ts
@@ -1,5 +1,5 @@
-import { stripIndent } from '../utils/formatters'
-import { snapshotFailure, snapshotSuccess } from '../utils/testing'
+import { stripIndent } from '../../utils/formatters'
+import { snapshotFailure, snapshotSuccess } from '../../utils/testing'
 
 test.each([
   [
diff --git a/src/__tests__/disallowed-syntax.ts b/src/parser/__tests__/disallowed-syntax.ts
similarity index 99%
rename from src/__tests__/disallowed-syntax.ts
rename to src/parser/__tests__/disallowed-syntax.ts
index f0bd7a15..3bc0673c 100644
--- a/src/__tests__/disallowed-syntax.ts
+++ b/src/parser/__tests__/disallowed-syntax.ts
@@ -1,5 +1,5 @@
-import { stripIndent } from '../utils/formatters'
-import { expectParsedError, expectWarning } from '../utils/testing'
+import { stripIndent } from '../../utils/formatters'
+import { expectParsedError, expectWarning } from '../../utils/testing'
 
 test('Cannot leave blank init in for loop', () => {
   return expectParsedError(
diff --git a/src/__tests__/__snapshots__/substituter.ts.snap b/src/stepper/__tests__/__snapshots__/stepper.ts.snap
similarity index 100%
rename from src/__tests__/__snapshots__/substituter.ts.snap
rename to src/stepper/__tests__/__snapshots__/stepper.ts.snap
diff --git a/src/__tests__/substituter.ts b/src/stepper/__tests__/stepper.ts
similarity index 98%
rename from src/__tests__/substituter.ts
rename to src/stepper/__tests__/stepper.ts
index d4ce0315..5b49abc9 100644
--- a/src/__tests__/substituter.ts
+++ b/src/stepper/__tests__/stepper.ts
@@ -1,7 +1,7 @@
-import { mockContext } from '../mocks/context'
-import { parse } from '../parser'
-import { codify, getEvaluationSteps } from '../substituter'
-import { substituterNodes } from '../types'
+import { mockContext } from '../../mocks/context'
+import { parse } from '../../parser/parser'
+import { substituterNodes } from '../../types'
+import { codify, getEvaluationSteps } from '../stepper'
 
 function getLastStepAsString(steps: substituterNodes[]): string {
   return codify(steps[steps.length - 1]).trim()
diff --git a/src/__tests__/__snapshots__/transpiled-code.ts.snap b/src/transpiler/__tests__/__snapshots__/transpiled-code.ts.snap
similarity index 100%
rename from src/__tests__/__snapshots__/transpiled-code.ts.snap
rename to src/transpiler/__tests__/__snapshots__/transpiled-code.ts.snap
diff --git a/src/__tests__/native.ts b/src/transpiler/__tests__/native.ts
similarity index 92%
rename from src/__tests__/native.ts
rename to src/transpiler/__tests__/native.ts
index abbc462c..c395be23 100644
--- a/src/__tests__/native.ts
+++ b/src/transpiler/__tests__/native.ts
@@ -1,8 +1,8 @@
-import { runInContext } from '../index'
-import { mockContext } from '../mocks/context'
-import { Finished } from '../types'
-import { stripIndent } from '../utils/formatters'
-import { expectNativeToTimeoutAndError } from '../utils/testing'
+import { runInContext } from '../../index'
+import { mockContext } from '../../mocks/context'
+import { Finished } from '../../types'
+import { stripIndent } from '../../utils/formatters'
+import { expectNativeToTimeoutAndError } from '../../utils/testing'
 
 test('Proper stringify-ing of arguments during potentially infinite iterative function calls', async () => {
   const code = stripIndent`
diff --git a/src/__tests__/transpiled-code.ts b/src/transpiler/__tests__/transpiled-code.ts
similarity index 91%
rename from src/__tests__/transpiled-code.ts
rename to src/transpiler/__tests__/transpiled-code.ts
index b7947c49..c5ea2032 100644
--- a/src/__tests__/transpiled-code.ts
+++ b/src/transpiler/__tests__/transpiled-code.ts
@@ -1,7 +1,7 @@
-import { mockContext } from '../mocks/context'
-import { parse } from '../parser'
+import { mockContext } from '../../mocks/context'
+import { parse } from '../../parser/parser'
+import { stripIndent } from '../../utils/formatters'
 import { transpile } from '../transpiler'
-import { stripIndent } from '../utils/formatters'
 
 /*  DO NOT HAVE 'native[<digit>]' AS A SUBSTRING IN CODE STRINGS ANYWHERE IN THIS FILE!
  *  Some code here have a redundant '1;' as the last statement to prevent the
diff --git a/src/utils/testing.ts b/src/utils/testing.ts
index 725990d5..55b65379 100644
--- a/src/utils/testing.ts
+++ b/src/utils/testing.ts
@@ -1,10 +1,10 @@
 import { default as createContext, defineBuiltin } from '../createContext'
 import { parseError, Result, runInContext } from '../index'
-import { stringify } from '../interop'
 import { mockContext } from '../mocks/context'
-import { parse } from '../parser'
-import { transpile } from '../transpiler'
+import { parse } from '../parser/parser'
+import { transpile } from '../transpiler/transpiler'
 import { Context, CustomBuiltIns, SourceError, Value } from '../types'
+import { stringify } from './stringify'
 
 export interface TestContext extends Context {
   displayResult: string[]