[test] Added Coffeelint to list to of features.
This commit is contained in:
parent
8cf6e4fb5b
commit
de3aa61e22
3
Makefile
3
Makefile
|
@ -16,6 +16,9 @@ node_modules: package.json
|
|||
mkdir -p node_modules
|
||||
npm install
|
||||
|
||||
lint:
|
||||
coffeelint $(SOURCES)
|
||||
|
||||
test: clean node_modules
|
||||
@JUNIT_REPORT_PATH=test-reports.xml JUNIT_REPORT_STACK=1 ./node_modules/.bin/mocha \
|
||||
--reporter mocha-jenkins-reporter --compilers coffee:coffee-script/register || true
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
lookup = require './lookup'
|
||||
{car, cdr, cadr, caadr, cdadr} = require './lists'
|
||||
|
||||
lispeval = (element, scope) ->
|
||||
|
||||
switch (car element)
|
||||
when 'number' then parseInt (cadr element), 10
|
||||
when 'string' then (cadr element)
|
||||
when 'symbol' then lookup scope, (cadr element)
|
||||
when 'list'
|
||||
proc = lispeval (caadr element), scope
|
||||
args = cdadr element
|
||||
proc args, scope
|
||||
else throw new Error ("Unrecognized type in parse: #{(car element)}")
|
||||
|
||||
module.exports = lispeval
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
lispeval = require './eval'
|
||||
{cons, nil, nilp, car, cdr, listToVector} = require './lists'
|
||||
|
||||
module.exports =
|
||||
create_vm_expression_evaluator: (defining_scope, params, body) ->
|
||||
(cells, scope) ->
|
||||
args = (amap = (cells, accum) ->
|
||||
return accum if nilp cells
|
||||
amap((cdr cells), accum.concat(lispeval (car cells), scope)))(cells, [])
|
||||
body.apply null, args
|
||||
|
||||
create_lisp_expression_evaluator: (defining_scope, params, body) ->
|
||||
(cells, scope) ->
|
||||
|
||||
# Takes the current scope, which has been passed in during the
|
||||
# execution phase, and evaluate the contents of the parameters
|
||||
# in the context in which this call is made (i.e. when the
|
||||
# function is *called*, rather than defined.
|
||||
|
||||
new_scope = (cmap = (cells, params, nscope) ->
|
||||
return nscope if (nilp cells) or (nilp params)
|
||||
nscope[(car params)] = lispeval (car cells), scope
|
||||
cmap((cdr cells), (cdr params), nscope))(cells, params, {})
|
||||
|
||||
# Execute and evaluate the body, creating an inner scope that
|
||||
# consists of: (1) the bound variables (the parameters)
|
||||
# evaluated in the context of the function call, because that's
|
||||
# where they were encountered (2) the free variables evaluated
|
||||
# in the context of the defining scope, because that's where
|
||||
# *they* were encountered.
|
||||
#
|
||||
# While this inspiration comes from Coglan, the clearest
|
||||
# explanation is from Lisperator's 'make_lambda' paragraph at
|
||||
# http://lisperator.net/pltut/eval1/
|
||||
|
||||
inner_scope = cons(new_scope, defining_scope)
|
||||
(nval = (body, memo) ->
|
||||
return memo if nilp body
|
||||
nval((cdr body), lispeval((car body), inner_scope)))(body)
|
||||
|
||||
create_special_form_evaluator: (defining_scope, params, body) ->
|
||||
(cells, scope) -> body(cells, scope)
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
{listToString, listToVector, pairp, cons, car, cdr, caar, cddr, cdar, cadr, caadr, cadar, caddr, nilp, nil, setcdr, metacadr} = require "cons-lists/lists"
|
||||
|
||||
ntype = (node) -> car node
|
||||
nvalu = (node) -> cadr node
|
||||
|
||||
evlis = (exps, d) ->
|
||||
if (pairp exps) then evaluate((car exps), d) + " " + evlis((cdr exps), d) else ""
|
||||
|
||||
indent = (d) ->
|
||||
([0..d].map () -> " ").join('')
|
||||
|
||||
evaluate = (e, d = 0) ->
|
||||
[type, exp] = [(ntype e), (nvalu e)]
|
||||
if type == "symbol" then exp
|
||||
else if type in ["number", "boolean"] then exp
|
||||
else if type == "string" then '"' + exp + '"'
|
||||
else if type == "list" then "\n" + indent(d) + "(" + evlis(exp, d + 2) + ")"
|
||||
else throw "Don't recognize a #{type}"
|
||||
|
||||
module.exports = (c) -> evaluate c, 0
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
lispeval = require './eval'
|
||||
{cons, car, cdr, nilp, nil, cadar, cadr, caddr} = require './lists'
|
||||
{create_lisp_expression_evaluator, create_vm_expression_evaluator, create_special_form_evaluator} = require './fn'
|
||||
|
||||
scope = cons
|
||||
'+': create_vm_expression_evaluator scope, [], (a, b) -> a + b
|
||||
'-': create_vm_expression_evaluator scope, [], (a, b) -> a - b
|
||||
'*': create_vm_expression_evaluator scope, [], (a, b) -> a * b
|
||||
'/': create_vm_expression_evaluator scope, [], (a, b) -> a / b
|
||||
'==': create_vm_expression_evaluator scope, [], (a, b) -> a == b
|
||||
'#t': true
|
||||
'#f': false
|
||||
|
||||
'define': create_special_form_evaluator scope, [], (nodes, scope) ->
|
||||
current = (car scope)
|
||||
current[(cadar nodes)] = lispeval((cadr nodes), scope)
|
||||
|
||||
'lambda': create_special_form_evaluator scope, [], (nodes, scope) ->
|
||||
param_nodes = cadar nodes
|
||||
reducer = (l) ->
|
||||
if (nilp l) then nil else cons (cadar l), reducer(cdr l)
|
||||
param_names = reducer(param_nodes)
|
||||
create_lisp_expression_evaluator scope, param_names, (cdr nodes)
|
||||
|
||||
'if': create_special_form_evaluator scope, [], (nodes, scope) ->
|
||||
if lispeval (car nodes), scope
|
||||
lispeval (cadr nodes), scope
|
||||
else
|
||||
lispeval (caddr nodes), scope
|
||||
|
||||
module.exports = scope
|
|
@ -8,6 +8,7 @@
|
|||
"cons-lists": "git+https://github.com/elfsternberg/cons-lists.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffeelint": "~1.10.0",
|
||||
"chai": "^2.0.0",
|
||||
"mocha": "^2.1.0",
|
||||
"mocha-jenkins-reporter": "^0.1.7"
|
||||
|
|
Loading…
Reference in New Issue