是否有“树结构编辑器”?对于 Lisp 来说?
我听说 S 表达式可以表示为树;例如 (f 1 (g 2) 3)
as
.
. . . .
f 1 . 3 [first level]
g 2 [second level]
有没有一个编辑器(最好是免费的)可以直接编辑这种结构?这将
- 避免“所有那些括号”
- 展现我一直理解的 lisp 的优雅。
I've heard that S-expressions can be represented as trees; for example (f 1 (g 2) 3)
as
.
. . . .
f 1 . 3 [first level]
g 2 [second level]
Is there an editor (preferably free) for editing this kind of structure directly? This would
- Avoid "all those parentheses"
- Exhibit the elegance I've been understanding of lisp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
S 表达式代表一棵树,而不是相反。您的示例,用换行符格式化:
它代表以下 cons 树:
这同时也是程序的实际抽象语法树 - 其他语言系列的编译器必须根据复杂的规则构建的东西。
对于编辑,括号是您和您的编辑器在树级别上操作所需的全部内容。在 Emacs 中,它是 paredit-mode,但我猜其他编辑器也有类似的实用程序或插件。
S-expressions represent a tree, not the other way around. Your example, formatted with newlines:
It represents the following cons tree:
This is at the same time the actual abstract syntax tree of the program—something that compilers for other language families have to construct from intricate rules.
For editing, the parentheses are all you and your editor need to operate on the tree level. In Emacs it is paredit-mode, but I guess that other editors have similar utilities or plugins.
据我所知(正如维基百科文章所证实的那样),结构编辑用于Interlisp-D。我不知道目前广泛使用的 Common Lisp 结构编辑器是什么,但也许有一些我不知道的事情。 Pascal J. Bourguignon 有一个 示例您可能想玩一下的网站。 (我没有仔细看)我确实这样做了,但是在 Oxygen 中使用了类似的 XML 内容不久前。
(另外,我不认为 Interlisp 使用它的原因与去掉括号有任何关系,例如,注释可能存在问题。)
As far as I know (and as the Wikipedia article confirms), structure editing was used in Interlisp-D. I am not aware of any structure editor for Common Lisp widely in use today, but maybe there is something I don't know about. There is an example on Pascal J. Bourguignon 's site you may want to play around with. (I didn't take a closer look at it) I did, however use something similar for XML in Oxygen some time ago.
(Also, I don't think the reason Interlisp used this had anything to do with getting rid of the parentheses, and there might be problems with comments, for example.)
emacs 的 ParEdit 模式本质上是一个结构化编辑器。
另外,在他们的论文 、 哥莫尔卡 & Humm 提到了一个为 Eclipse 扩展 CUSP 的研究原型,但我不知道可下载的实现。
The ParEdit mode for emacs is essentially a structured editor.
Also, in their paper, Gomolka & Humm mention a research prototype extending CUSP for Eclipse, but I don't know of a downloadable implementation.
我们正在努力让您用 Gingko 编写 Lisp(通用树结构编辑器)。
从树到源的转换是微不足道的,所以实际上唯一缺少的是更多的深度(Gingko 目前仅限于 3 个级别)。
[这仍然是非常实验性的,所以我很想得到反馈和反馈。 Lisp 专家的意见。]
We're working on letting you write Lisp with Gingko (a general tree structure editor).
The conversion from tree to source is trivial, so really the only thing missing is more depth (Gingko is currently limited to 3 levels).
[This is still very experimental, so I'd love feedback & input from Lisp experts.]