[refactor] The great conversion continues.
This commit is contained in:
parent
501ac5fe72
commit
675577431d
|
@ -1,10 +1,12 @@
|
|||
{car, cdr, cons, listp, nilp, nil,
|
||||
list, pairp, listToString} = require 'cons-lists/lists'
|
||||
{astObject} = require './astAccessors'
|
||||
{Symbol} = require './reader_types'
|
||||
|
||||
# RICH_AST -> LISP_AST
|
||||
|
||||
normalizeForm = (form) ->
|
||||
console.log(form)
|
||||
|
||||
listToRecord1 = (l) ->
|
||||
o = Object.create(null)
|
||||
|
@ -25,9 +27,9 @@ normalizeForm = (form) ->
|
|||
'record': (atom) -> listToRecord1(atom)
|
||||
|
||||
# Basic native types. Meh.
|
||||
'symbol': id
|
||||
'symbol': new Symbol(id)
|
||||
'number': id
|
||||
'string': (atom) -> atom
|
||||
'string': id
|
||||
'nil': (atom) -> nil
|
||||
|
||||
# Values inherited from the VM.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{listToString, listToVector, pairp, cons, car, cdr, caar, cddr,
|
||||
cdar, cadr, caadr, cadar, caddr, nilp, nil, setcdr, metacadr} = require "cons-lists/lists"
|
||||
readline = require "readline"
|
||||
{Node} = require "./reader_types"
|
||||
|
||||
class LispInterpreterError extends Error
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
exports.Node = class
|
||||
constructor: (@type, @value, @line, @column) ->
|
||||
|
||||
exports.Symbol = class
|
||||
constructor: (@name) ->
|
||||
|
||||
exports.Comment = class
|
||||
constructor: (@text) ->
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{listToString, listToVector, pairp, cons, car, cdr, caar, cddr, cdar,
|
||||
cadr, caadr, cadar, caddr, nilp, nil, setcdr,
|
||||
metacadr, setcar} = require "cons-lists/lists"
|
||||
{normalizeForm} = require "../chapter1/astToList"
|
||||
{normalizeForms, normalizeForm} = require "../chapter1/astToList"
|
||||
{Node} = require '../chapter1/reader_types'
|
||||
|
||||
class LispInterpreterError extends Error
|
||||
|
@ -86,7 +86,7 @@ class VariableEnv extends FullEnv
|
|||
# quoted term uninterpreted.
|
||||
|
||||
evaluateQuote = (v, env, kont) ->
|
||||
kont.resume v
|
||||
kont.resume normalizeForms v
|
||||
|
||||
# Evaluates the conditional expression, creating a continuation with
|
||||
# the current environment that, when resumed, evaluates either the
|
||||
|
|
|
@ -25,7 +25,7 @@ describe "Core reader functions", ->
|
|||
['{}', {}]
|
||||
['[1 2 3]', [1, 2, 3]]
|
||||
# ['(1 2 3', 'error']
|
||||
['{foo "bar"}', {foo: "bar"}]
|
||||
['{"foo" "bar"}', {foo: "bar"}]
|
||||
]
|
||||
|
||||
for [t, v] in samples
|
||||
|
|
Loading…
Reference in New Issue