duangsuse::Echo
#recommended #ui https://github.com/vczh-libraries/GacUI
尝试测试了一下,很失败,貌似是 glib 的 pkgconfig 的问题出的错,为此实在感觉 CMake 作为一个构建工具,居然连自定义 build dir 都做不到...
#PL #code #guide #daily #scheme
关于 Lice lice-lang/lice 解释器的分析
我们只看解释器实现,不看测试和文档什么的,目标为理解官方 Lice 解释器实现和汲取精华、以及提出充分利用 Kotlin 特性的建议
我们可以看到,
LanguageVersion EngineVersion Extensions MimeTypes LanguageName Names EngineName
ScriptEngine()
OutputStatement(toDisplayString)
Program(statementsCode)
MethodCallSyntax(obj: String, mid: String, vararg args: String)
Parameter(paramString)
"javax.script.engine_version", "javax.script.language_version"
"javax.script.engine", "javax.script.language", "javax.script.name"
而
bindings: SymbolList
reader: Reader
writer: Writer
errorWriter: Writer
getAttribute(name: String)
getAttribute(name: String, scope: Int)
setAttribute(name: String, value: Any?)
setAttribute(name: String, value: Any?, scope: Int)
removeAttribute(name: String) = bindings.removeVariable(name)
removeAttribute(name: String, scope: Int)
getScopes(): MutableList<Int>
getAttributesScope(name: String?): Int
getBindings(scope: Int)
setBindings(bindings: Bindings, scope: Int)
然后是
variables: MutableMap<String, Any?>
provideFunctionWithMeta(name: String, node: ProvidedFuncWithMeta)
provideFunction
defineFunction
getVariable
defineVariable
isVariableDefined
removeVariable
containsValue
clear
putAll(from: Map<out String, Any>)
containsKey
get
put
isEmpty
remove
var size = fun ...
entries: MutableSet<LiceEntry>
keys
values
关于 Lice lice-lang/lice 解释器的分析
我们只看解释器实现,不看测试和文档什么的,目标为理解官方 Lice 解释器实现和汲取精华、以及提出充分利用 Kotlin 特性的建议
org/lice/api/scripting/*
javax.script 的 API 接口我们可以看到,
LiceScriptEngineFactory 类提供以下信息LanguageVersion EngineVersion Extensions MimeTypes LanguageName Names EngineName
ScriptEngine()
OutputStatement(toDisplayString)
Program(statementsCode)
MethodCallSyntax(obj: String, mid: String, vararg args: String)
Parameter(paramString)
"javax.script.engine_version", "javax.script.language_version"
"javax.script.engine", "javax.script.language", "javax.script.name"
而
LiceScriptEngine 做这些class LiceScriptEngine : JavaxScriptEngine并且 LiceContext 做这些
private var context: LiceContext = LiceContext()
getContext()
setContext(context)
setContextIfIsLiceContext()
getFactory()
eval(scriptString, context) = eval(script, context.bindings)
eval(script: String) = eval(script, context.bindings)
eval(reader: Reader) = eval(reader.readText(), context.bindings)
eval(reader: Reader, n: Bindings) = eval(reader.readText(), n)
eval(reader: Reader, context: ScriptContext)
eval(script: String, n: Bindings)
get(key: String?): Any? = context.bindings[key]
put(key: String, value: Any?)
createBindings() = SymbolList()
getBindings(scope: Int) = context.bindings
setBindings(bindings: Bindings?, scope: Int)
bindings: SymbolList
reader: Reader
writer: Writer
errorWriter: Writer
getAttribute(name: String)
getAttribute(name: String, scope: Int)
setAttribute(name: String, value: Any?)
setAttribute(name: String, value: Any?, scope: Int)
removeAttribute(name: String) = bindings.removeVariable(name)
removeAttribute(name: String, scope: Int)
getScopes(): MutableList<Int>
getAttributesScope(name: String?): Int
getBindings(scope: Int)
setBindings(bindings: Bindings, scope: Int)
然后是
org/lice/core/*
AbstractBindingsvariables: MutableMap<String, Any?>
provideFunctionWithMeta(name: String, node: ProvidedFuncWithMeta)
provideFunction
defineFunction
getVariable
defineVariable
isVariableDefined
removeVariable
containsValue
clear
putAll(from: Map<out String, Any>)
containsKey
get
put
isEmpty
remove
var size = fun ...
entries: MutableSet<LiceEntry>
keys
values
duangsuse::Echo
#PL #code #guide #daily #scheme 关于 Lice lice-lang/lice 解释器的分析 我们只看解释器实现,不看测试和文档什么的,目标为理解官方 Lice 解释器实现和汲取精华、以及提出充分利用 Kotlin 特性的建议 org/lice/api/scripting/* javax.script 的 API 接口 我们可以看到,LiceScriptEngineFactory 类提供以下信息 LanguageVersion EngineVersion Extensions…
... 说得太详细了实在是脑洞啊
简要说一下每个类的功能(看了一点后我还是觉得 Lice 的设计有点大了... 不知道为什么)
简要说一下每个类的功能(看了一点后我还是觉得 Lice 的设计有点大了... 不知道为什么)
duangsuse::Echo
... 说得太详细了实在是脑洞啊 简要说一下每个类的功能(看了一点后我还是觉得 Lice 的设计有点大了... 不知道为什么)
我大概看了一遍,已经找到分词、解析器、数值类型自动提升运算工具、内部函数位置、辅助扩展函数、AST 求值逻辑位置
目前依然需要确定的可能是内部函数分派逻辑
刚才去迂腐的编译原理裙里看看,冰封不在所以为啥要给 Kotlin 的内部 handler 加 mangle 我就没问到
目前依然需要确定的可能是内部函数分派逻辑
刚才去迂腐的编译原理裙里看看,冰封不在所以为啥要给 Kotlin 的内部 handler 加 mangle 我就没问到
然后我怂了... 因为我感觉 InScript + JNI Bison + Flex Lexer 会更好玩一些,之前没玩过,都是自写的分词器,然后递归下降 Recursive descent method 解析器不会写... 二元运算优先级和左优先级右优先级不了解... 所以都不知道如何整理 BinaryNode
不过我还是乐意出一个支持最新基本词法语法定义的 Lime 去和 Lice 比速度
不过我还是乐意出一个支持最新基本词法语法定义的 Lime 去和 Lice 比速度
平时指令式 imperative 写多了声明式 declarative 写少了的 duangsuse 不会看满屏括号(
至少不知 C++ template 元编程 metaprogramming 为何物
至少不知 C++ template 元编程 metaprogramming 为何物
duangsuse::Echo
https://gist.github.com/duangsuse/7dba2f4b41e45c3533158226091438e3 我准备翻译一下这篇文档,然后用这种模式写一个解释器...
然后惊喜的发现 MinVM、LiteVM 的设计与 Kent 大佬的有相似之处
https://github.com/kenpratt/rusty_scheme
https://github.com/picrin-scheme/libpicrin/ Tracing GC
https://github.com/cslarsen/mickey-scheme R7RS 的这个比较大了 500 提交
https://github.com/uhmanoa-transpiler-project/shaka-scheme 推荐,使用 C++,简洁明了
https://github.com/ignorabimus/minischeme 推荐,使用复制 GC,单文件实现
https://github.com/boynton/scheme 推荐,字节码解释
https://github.com/ltoddy/scheme.c/blob/master/scheme/object.h 简单的 C 实现
https://github.com/picrin-scheme/libpicrin/ Tracing GC
https://github.com/cslarsen/mickey-scheme R7RS 的这个比较大了 500 提交
https://github.com/uhmanoa-transpiler-project/shaka-scheme 推荐,使用 C++,简洁明了
https://github.com/ignorabimus/minischeme 推荐,使用复制 GC,单文件实现
https://github.com/boynton/scheme 推荐,字节码解释
https://github.com/ltoddy/scheme.c/blob/master/scheme/object.h 简单的 C 实现
GitHub
kenpratt/rusty_scheme
A Scheme interpreter written in Rust. Contribute to kenpratt/rusty_scheme development by creating an account on GitHub.
duangsuse::Echo
https://github.com/kenpratt/rusty_scheme https://github.com/picrin-scheme/libpicrin/ Tracing GC https://github.com/cslarsen/mickey-scheme R7RS 的这个比较大了 500 提交 https://github.com/uhmanoa-transpiler-project/shaka-scheme 推荐,使用 C++,简洁明了 https://github.com/igno…
BiwaScheme 更上层一些,不需要考虑 GC 什么的,光靠分析它的虚拟机就可以了解现代的 R6RS 解释器实现还挺值