在 Rubinius VM 上创建语言
我想尝试使用 Rubinius VM 来创建一种语言,但只是阅读文档,我仍然对如何开始感到困惑。即使查看项目,我似乎仍然无法弄清楚解析和使用虚拟机的位置地方。有人有这方面的资源吗?
I'm looking to play around with the Rubinius VM to create a langauage, but just reading the documentation, I'm still quite lost on how to get started. Even looking at the projects, I still can't seem to figure out where the parsing and using the vm comes into place. Does anyone have any resources for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嘿,我是在 rubinius 上运行的 Fancy 语言的贡献者。如果您对解析感兴趣,请查看 boot/rbx-compiler ,您会发现一个解析器(用 KPEG 实现),它基本上构建了 AST 节点树,每个节点都有一个生成 rubinius vm 的字节码方法一切正常工作的说明。 Fancy 与 ruby 共享很多语义,所以我想如果您已经熟悉 ruby,那么开始会很容易。当您继续探索编译器时,您只需要检查示例/目录即可对语言有一个感觉,然后检查 kpeg 解析器、ast 节点、加载器。如今,Fancy 已被引导(这意味着编译器是用 fancy 本身编写的 - 在 lib/compiler 中),但 rbx-compiler 是该过程的第一步。
希望探索 Fancy 的源代码能够对您有所帮助。
Hey I'm a contributor to the Fancy language that runs on rubinius. If you're interested in parsing take a look at boot/rbx-compiler there you'll find a Parser (implemented with KPEG) that basically constructs a tree of AST nodes, each of those nodes has a bytecode method that produces the rubinius vm instructions for everything to work. Fancy share a lot of semantics with ruby, so I guess starting with it would be easy if you're already familiar with ruby. You'll just need to checkout the examples/ dir to geet a feeling on the language and then the kpeg parser, ast nodes, loader, as you progress exploring the compiler. These days Fancy is bootstrapped (that means that the compiler has been written in fancy itself - at lib/compiler) but rbx-compiler is the first step in that process.
Hope exploring Fancy's source code can be of help to you.
如果您还没有看过,请查看 Evan 的 2011 LA Ruby Conf 主题演讲。他展示了如何构建一种简单的语言,这可能会有所帮助。
In case you hadn't seen it, check out Evan's keynote from 2011 LA Ruby Conf. He shows how to build a simple language, which might be helpful.