diff options
-rw-r--r-- | TestOutput.xml | 4 | ||||
-rw-r--r-- | src/CoreBindings.kt | 2 | ||||
-rw-r--r-- | src/LispData.kt | 2 | ||||
-rw-r--r-- | src/LispExecutionContext.kt | 1 | ||||
-rw-r--r-- | test/res/scratch.lisp | 11 |
5 files changed, 14 insertions, 6 deletions
diff --git a/TestOutput.xml b/TestOutput.xml index 87243da..cf84e29 100644 --- a/TestOutput.xml +++ b/TestOutput.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" ?><testsuites><testsuite name="Test" tests="0" skipped="0" failures="0" errors="0" timestamp="2023-08-21T07:24:22"><properties></properties><system-out><![CDATA[Hello, World, here is an atom: :iamanatom +<?xml version="1.0" ?><testsuites><testsuite name="Test" tests="0" skipped="0" failures="0" errors="0" timestamp="2023-08-21T07:40:43"><properties></properties><system-out><![CDATA[Hello, World, here is an atom: :iamanatom :myfunworks :atom a :test @@ -14,7 +14,7 @@ truthy value left evaluated falsey value ============ -Error: Could not resolve variable sc at /home/nea/src/nealisp/build/resources/test/scratch.lisp:21:30 until 21:32 +Error: Could not resolve variable sc at /home/nea/src/nealisp/build/resources/test/scratch.lisp:28:30 until 28:32 This should fail nil This should work 42.0 ============ diff --git a/src/CoreBindings.kt b/src/CoreBindings.kt index b90072e..2208b8c 100644 --- a/src/CoreBindings.kt +++ b/src/CoreBindings.kt @@ -118,6 +118,7 @@ object CoreBindings { is LispData.LispString -> thing.string is LispData.LispHash -> thing.map.asIterable().joinToString(", ", "{", "}") { it.key + ": " + it.value } is LispData.LispNumber -> thing.value.toString() + is LispData.ForeignObject<*> -> "<foreign ${thing.obj}>" is LispData.LispInterpretedCallable -> "<function ${thing.name ?: "<anonymous>"} ${thing.argNames} ${thing.body.toSource()}>" } } @@ -225,6 +226,7 @@ object CoreBindings { LispData.LispNil -> LispData.Atom("nil") is LispData.LispHash -> LispData.Atom("hash") is LispData.LispNode -> LispData.Atom("ast") + is LispData.ForeignObject<*> -> LispData.Atom("foreign") is LispData.LispNumber -> LispData.Atom("number") is LispData.LispString -> LispData.Atom("string") } diff --git a/src/LispData.kt b/src/LispData.kt index ea3af32..61c2b76 100644 --- a/src/LispData.kt +++ b/src/LispData.kt @@ -8,6 +8,7 @@ sealed class LispData { data class LispNumber(val value: Double) : LispData() data class LispNode(val node: LispAst.LispNode) : LispData() data class LispHash(val map: Map<String, LispData>) : LispData() + data class ForeignObject<T : Any?>(val obj: T) : LispData() class LispList(val elements: List<LispData>) : LispData() sealed class LispExecutable() : LispData() { abstract fun execute( @@ -56,7 +57,6 @@ sealed class LispData { } } - companion object { fun externalRawCall( name: String, diff --git a/src/LispExecutionContext.kt b/src/LispExecutionContext.kt index 306e111..0a1dc41 100644 --- a/src/LispExecutionContext.kt +++ b/src/LispExecutionContext.kt @@ -36,7 +36,6 @@ class LispExecutionContext() { return testSuite } - fun registerModule(moduleName: String, program: LispAst.Program) { if (moduleName in unloadedModules || moduleName in modules) { error("Cannot register already registered module $moduleName") diff --git a/test/res/scratch.lisp b/test/res/scratch.lisp index 3fc6ed7..95595b7 100644 --- a/test/res/scratch.lisp +++ b/test/res/scratch.lisp @@ -6,14 +6,21 @@ (debuglog "a" a) (debuglog "..." ...))) (testlog :test :work :whatever) -(def helloworld (pure "hello world")) +(def helloworld + (pure "hello world")) (debuglog helloworld (helloworld)) (debuglog "+" (+ 1.2 15)) (debuglog "-" (- 1 3)) (debuglog "*" (* 10 10)) (debuglog "/" (/ 1 3 2)) (debuglog "============") -(defun testsomething (c) (debuglog (if! c (seq (debuglog "left evaluated") (return "truthy value")) "falsey value"))) +(defun testsomething (c) + (debuglog + (if! c + (seq + (debuglog "left evaluated") + (return "truthy value")) + "falsey value"))) (testsomething true) (testsomething false) (noop) |