blob: cceb0dfe94fde754830240faed732783600a3b9b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package moe.nea.lisp
import javax.script.ScriptEngine
import javax.script.ScriptEngineFactory
class LispScriptEngineFactory : ScriptEngineFactory {
override fun getEngineName(): String = "nealisp"
override fun getEngineVersion(): String = "1.0.0"
override fun getExtensions(): List<String> = listOf("lsp", "lisp", "nealisp")
override fun getMimeTypes(): List<String> = listOf("application/x-lisp", "application/x-nealisp")
override fun getNames(): List<String> = listOf("NeaLisp", "Lisp")
override fun getLanguageName(): String = "Lisp"
override fun getLanguageVersion(): String = "1.0.0"
override fun getParameter(key: String?): String? {
return when (key) {
ScriptEngine.NAME -> languageName
ScriptEngine.ENGINE_VERSION -> engineVersion
ScriptEngine.ENGINE -> engineName
ScriptEngine.LANGUAGE -> languageName
ScriptEngine.LANGUAGE_VERSION -> languageVersion
else -> null
}
}
override fun getMethodCallSyntax(obj: String?, m: String?, vararg args: String?): String {
return "($m $obj ${args.joinToString(" ")})"
}
override fun getOutputStatement(toDisplay: String?): String {
return "(print $toDisplay)"
}
override fun getProgram(vararg statements: String?): String {
return statements.joinToString("\n")
}
override fun getScriptEngine(): LispScriptEngine {
return LispScriptEngine(this)
}
}
|