Modifying AST and generating source code
还没有人认领这个 Issue。
评估
调研方向
从 issue 中描述的 Prism.parse(text) 入口点和 Prism::Visitor 用法开始。检查 Prism 是否记录了可变 AST 遍历或源代码重新生成,并找出现有的涵盖这些 API 的示例或测试。只有在支持的转换和 unparse 行为得到定义并完成文档记录或实现后,范围才算完成。
由索引模型根据 Issue 内容生成。
描述
Forgive my ignorance but I'm trying to use Prism to modify Ruby source (add nodes) and then regenerate the source to be interpreted. I'm using Prism.parse(text) and then implementing a Prism::Visitor to potentially modify the nodes as they are visited. I assume this is possible but I haven't really seen any examples of it. Finally I would like to 'unparse' the AST back into source code.
The Python equivalent is indeed unparse which is where I'm taking many of the ideas. They also have a NodeTransformer which is allowed to modify the nodes in the visit pattern. I don't see equivalents in Prism but perhaps you're always allowed to modify the nodes ... this is Ruby afterall.
Thanks for any help pointing me in the right direction!
- 主要语言
- C
- 星标
- 1k
- 派生
- 194
- 平均合并
- 2 天 6 小时
- 30 天内合并 PR
- 15
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ruby/prism 的其他 Issue
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
-
Revisit comments 未关闭enhancement
难度 5/5 一周以上 新手友好度 30/100
-
java
难度 5/5 一周以上 新手友好度 25/100
-
java
难度 5/5 一周以上 新手友好度 25/100
-
java
难度 5/5 一周以上 新手友好度 25/100
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
bradcypert/plum#53 ·
-
Component: GLib
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
Status: Opened
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
nextbsd/nextbsd-userland#285 ·