Moved the interpreter into ronin
This commit is contained in:
parent
0e7af66c16
commit
aaa77de890
@ -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))
|
||||
}
|
||||
|
||||
|
@ -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})`))
|
||||
|
@ -11,6 +11,8 @@ function Ronin () {
|
||||
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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user