如何在 Ruby 中通过 S 表达式构建 AST?
我不知道如何构建 S-exp。 我想这样做,因为我需要为我的语言构建 AST。 一开始我使用RubyParser将其解析为sexp,然后代码gen。 但我认为它一定是 ruby 的子集。我无法定义我想要的语言。 现在我需要为我的语言实现解析器。
那么有人可以推荐任何为 S 表达式构建 AST 的 ruby 工具吗?
谢谢!
I have no idea how to build S-exp.
I want to do it, because I need to build AST for my langauge.
At the beginning I used RubyParser to parse it to sexp then code gen.
But it must be ruby's subset I think.I cant define the language what I want.
Now I need to implement parser for my language.
So anyone could recommend any ruby tool that building AST for S-expression ?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从你的问题中并不清楚你到底需要什么,但简单的谷歌搜索给出了一些有趣的链接来检查。也许在检查这些链接后,如果它们不是您问题的答案,您可以编辑问题并使其更加精确和具体。
http://thingsaaronmade.com/blog/writing-an -s-表达式-解析器-in-ruby.html
https://github.com/aarongough/sexpistol
It is not very clear from your question what exactly do you need, but simple Google search gives some interesting links to check. Maybe after checking these links, if they are not the answer to your question, you can edit question and make it more precise and concrete.
http://thingsaaronmade.com/blog/writing-an-s-expression-parser-in-ruby.html
https://github.com/aarongough/sexpistol
您可以在 http://github.com/bendiken/sxp-ruby。我将它用于 SPARQL S 表达式 (SSE) 以及管理 Ruby 中抽象语法树的类似方法。
You might try the sxp-ruby gem at http://github.com/bendiken/sxp-ruby. I use it for SPARQL S-Expressions (SSE) and similar methods for managing Abstract Syntax Trees in Ruby.
也许你可以看看这个名为 Astrapi 的 gem。
这只是一个实验:
我在此处放置了一份适度的文档。
Maybe you could have a look at this gem named Astrapi.
This is just an experiment :
I have put a modest documentation here.