diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index 6cdfd21..fa74696 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -33,7 +33,7 @@ function Commander (ronin) { this.run = (txt = this._input.value) => { if (txt.indexOf('$') > -1) { ronin.log('Present: $'); return } - const inter = new Lisp(txt, ronin.library, ronin.includes).run() + ronin.interpreter.run(txt) ronin.always === true && requestAnimationFrame(() => this.run(txt)) } diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index d383fb8..82fe8de 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -1,14 +1,15 @@ 'use strict' -function Lisp (input, lib, includes) { +function Lisp (lib = {}, includes = []) { + console.log(includes) const path = require('path') const fs = require('fs') const TYPES = { identifier: 0, number: 1, string: 2, bool: 3 } + const Context = function (scope, parent) { this.scope = scope this.parent = parent - this.get = function (identifier) { if (identifier in this.scope) { return this.scope[identifier] @@ -178,7 +179,7 @@ function Lisp (input, lib, includes) { return parenthesize(tokenize(input)) } - this.run = async function () { + this.run = async function (input) { return interpret(this.parse(`( ${this.inc()} ${input})`)) diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index a782a8b..fade53f 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -10,6 +10,8 @@ function Ronin () { b_low: '#aaa', b_inv: '#ffb545' } + + this.includes = ['prelude'] this.el = document.createElement('div') this.el.id = 'ronin' @@ -19,11 +21,11 @@ function Ronin () { this.commander = new Commander(this) this.surface = new Surface(this) this.library = new Library(this) + this.interpreter = new Lisp(this.library, this.includes) // Parameters this.always = false - this.includes = ['prelude'] this.install = function (host = document.body) { this._wrapper = document.createElement('div')