diff --git a/desktop/sources/index.html b/desktop/sources/index.html index 955ce4b..ce810ca 100644 --- a/desktop/sources/index.html +++ b/desktop/sources/index.html @@ -18,10 +18,10 @@ diff --git a/desktop/sources/scripts/commander.js b/desktop/sources/scripts/commander.js index f42d1d1..6cdfd21 100644 --- a/desktop/sources/scripts/commander.js +++ b/desktop/sources/scripts/commander.js @@ -33,8 +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) - inter.toPixels() + const inter = new Lisp(txt, ronin.library, ronin.includes).run() ronin.always === true && requestAnimationFrame(() => this.run(txt)) } diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index d2a9541..d383fb8 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -1,6 +1,6 @@ 'use strict' -function Lisp (input, lib) { +function Lisp (input, lib, includes) { const path = require('path') const fs = require('fs') @@ -20,7 +20,7 @@ function Lisp (input, lib) { const special = { include: (input, context) => { - if (!input[1].value || !fs.existsSync(input[1].value)) { console.warn('Source', input[1].value); return [] } + if (!input[1].value || !fs.existsSync(input[1].value)) { console.warn('Lisp', 'No file: ' + input[1].value); return [] } const file = fs.readFileSync(input[1].value, { encoding: 'utf-8' }) return interpret(this.parse(`(${file})`), context) }, @@ -69,7 +69,7 @@ function Lisp (input, lib) { __fn: function (input, context) { return async function () { const lambdaArguments = arguments - const keys = [...new Set(input.slice(2).flat(100).filter(i => + const keys = [...new Set(input.slice(2).flat(100).filter(i => i.type === TYPES.identifier && i.value[0] === '%' ).map(x => x.value).sort())] @@ -82,8 +82,8 @@ function Lisp (input, lib) { }, __obj: async function (input, context) { const obj = {} - for (let i = 1 ; i { + const p = path.join(__dirname, `lisp/${item}.lisp`) + if (!fs.existsSync(p)) { console.warn('Lisp', `Missing include: ${p}`); return acc } + return `${acc}(include "${p}") ` + }, '') } this.parse = function (input) { return parenthesize(tokenize(input)) } - this.toPixels = async function () { + this.run = async function () { return interpret(this.parse(`( - (include "./sources/lisp/prelude.lisp") - ${input})`)) + ${this.inc()} + ${input})`)) } } diff --git a/desktop/sources/scripts/ronin.js b/desktop/sources/scripts/ronin.js index 1e229c7..a782a8b 100644 --- a/desktop/sources/scripts/ronin.js +++ b/desktop/sources/scripts/ronin.js @@ -23,6 +23,7 @@ function Ronin () { // Parameters this.always = false + this.includes = ['prelude'] this.install = function (host = document.body) { this._wrapper = document.createElement('div') diff --git a/desktop/sources/scripts/source.js b/desktop/sources/scripts/source.js index d0abb44..8ceec2e 100644 --- a/desktop/sources/scripts/source.js +++ b/desktop/sources/scripts/source.js @@ -126,12 +126,6 @@ function Source (ronin) { return `${str}` } - this.locate = function (name) { - if (!this.path) { return } - const loc = path.join(this.folder(), name) - return fs.existsSync(loc) ? loc : null - } - // Etc this.name = function () {