什么是嵌入宏处理器的良好、简单的脚本语言
我想写一个宏处理器。到目前为止,我已经对它的外观做了一个非常简单的草图,我得出的结论是,发明一种全新的语言不是一个好主意,但我应该重用现有的概念。到目前为止,我的草图是一种 irb,具有一些类似于 tex 的语法和功能,但我不确定应该使用什么作为 ruby 替代品。 语言应该简单但功能强大。我不想在其中编写操作系统,但它应该比 bc 或 forth 更“原始”。我根本不关心执行时间。嵌入不应该太难,如果语言本身稳定那就太好了。
到目前为止,我已经考虑过这些:
- Lua - 它应该轻松处理文本。 Lua 甚至没有
while(c=getchar()){}
。我对此表示怀疑。 - awk - 简单,文本处理很容易,但从未打算嵌入
- perl - 方式复杂,稳定,但似乎几乎死了。
- python - 重要的空格;它们不会妨碍内联函数定义吗?
- groovy/nice/java - 难以/不可能嵌入?也太重了。
- javascript - 真的很喜欢它(除了 DOM),但是有稳定/可嵌入的实现吗?当有新的 v8 版本时,我不想每两周就搞乱 api。正如我所说,我不关心执行时间。
我还没有真正发现
- io
- guile/scheme
- TCL
的任何优点/缺点更新:该语言应该具有函数定义、库加载或正则表达式等功能(循环将也很好)我不想使用传统的宏语言,例如 M4,因为我希望能够以更加过程化(或者可能是函数式)的风格进行编写。宏语言有其优点,但我需要一种全新的方式来思考问题,这对初学者来说尤其困难。我的目标是两全其美。
I want to write a macroprocessor. So far I've done a very simple sketch of how it should look and I came to the conclusion that inventing a completely new language would not be a good idea but I should reuse existing concepts. My sketch so far is a kind of irb with some tex-alike syntax and features, but I'm not sure what I should use as ruby-substitute.
The language should be simple, yet powerful. I don't want to write an OS in it, but it should be less "raw" than e.g. bc or forth. I don't care about execution time at all. Embedding should not be too hard and it'll be nice if the language itself was stable.
So far I've considered these:
- Lua - It should process text easily. Lua does not even have a
while(c=getchar()){}
. I'm skeptic. - awk - Simple, text processing is easy, but never intended for embedding
- perl - Way to complex, stable, but it seems almost dead.
- python - Significant whitespaces; won't they get in the way for inlined function-definitions?
- groovy/nice/java - Hard/impossible to embed? Also way to heavy.
- javascript - Really like it (besides DOM) but is there a stable/embeddable implementation? I don't want to mess around with the api every 2 weeks when there's a new v8 version. As I said, I don't care about execution time.
I have not really found any pros/cons for
- io
- guile/scheme
- TCL
Update: The language should have features such as function-definition, library-loading or regexps (loops would also be very nice) I don't want to use a traditional macro-language such as M4 because I want to able to write in a more procedural (or maybe functional) style. Macro languages have their pros, but I requires a completely new way of thinking about a problem which is hard especially for beginners. My Aim is to use the best of both worlds.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
鉴于 TCL 是关于字符串和数组处理的,并且旨在用于嵌入,这似乎是一个显而易见的选择。
Luatex 拥有一定的追随者。想必他们已经找到了一种使其适用于文本处理的方法,所以您可能想看看。
方案(包括 guile)对于脚本编写也非常有用;或者,您可能会考虑是否有一种方法可以嵌入 elisp 处理器(嵌入 xemacs?),毕竟这都是关于文本处理的。
Given that TCL is about string and array processing, and is intended for embedding, it would seem an obvious choice.
Luatex has a certain following. Presumably they have found a way to make it work for text processing, so you might like to look at that.
Scheme (including guile) is also very nice for scripting; alternatively you might look at whether there is a way you could embed an elisp processor (embed xemacs?), which after all is all about text processing.