开发者

What is a good, simple scripting language to embed into a macro-processor

开发者 https://www.devze.com 2023-03-17 09:52 出处:网络
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 shou

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 开发者_JAVA百科for beginners. My Aim is to use the best of both worlds.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消