![]() |
1
3
IokeIOKE允许重写文本,但不允许定义新的文本。它的工作方式是将文本简单地转换为消息发送,然后您可以像其他方法一样重写相应的方法。
例如,这是
对于名为
现在,
这个
文本文本被转换为发送
[Note: obviously, the way it is written here will lead to an infinite recursion. The truth is that the argument to
这只会给我们留下一个数字,你猜对了,它也是一个信息发送:
因为每件事都是一个消息发送,所以您可以通过实现相应的方法,随意定制文本的行为。这是一份来自
ConvergeConverge允许强大的编译时元编程,包括一个名为 DSL块 . DSL块是不使用聚合语法的代码块。DSL块如下所示:
其工作方式是
Factor因子允许定义 解析词 这些词会影响同一范围内其他词的解析方式。因素实际上有一个 XML library implementation 它使用解析词来获取与scala的XML文本非常相似的语法,但只是普通的因子代码:
[快速介绍因素:
普通LISP
Common Lisp Reader Macros
允许您钩住阅读阶段,即获取字符串并生成嵌套列表的阶段,然后将它们交给编译器/计算器。它们要求您选择唯一的一个或两个字符前缀,并且它们是全局的。第一个问题不算什么,因为我们可以简单地选择
Perl 6Perl6应该允许您在程序运行时更改语法。Perl6有一个动态可变语法,这意味着代码在执行时会被解析,并且可以更改语法,以便使用新语法解析文件中的其他代码。 奥美塔/可乐Alessandro Warth's OMeta language 在…之上运行 Ian Piumarta's COLA system allows for what they call "mood-specific languages". I.e. languages whose specification and implementation is so lightweight that you can use them for just one line in the middle of your program and then switch to a different syntax again. 它用于 Inventing Fundamental New Computing Technologies 在Alan Kay Viewpoint Research Institute . One example usage is the implementation of an entire TCP/IP networking stack in just 200 lines of code by designing a language whose syntax is identical to the ASCII art diagrams used in IETF RfCs and another language for writing networking protocol state machines. Then, the implementation of the networking stack simply consists of copy&pasting the ASCII diagrams from the RfCs and transiterating the English state machine descriptions from the RfCs into the state machine language. (Oh, in case you are wondering: the 200 lines is not just for the ASCII diagrams and the state machines. It also includes the parsers and compilers for the two languages.) Ï编程语言可能也很有趣。 |
![]() |
2
2
听起来像是用户定义的文字(_§2.14.8) C++ 0x (警告:大型PDF)非常接近(或可能正是)您正在寻找的内容。 |
![]() |
3
1
这个 D programming language 具有所需的构造, at compile time ,转换包含JSON的字符串文本 into the corresponding object/struct/arrays . 它甚至可以 load the string at compile time from a external file . 我不知道要写什么代码,但写起来并不难。 如果你在运行时想要同样的东西,D有 Associative arrays 和 dynamic arrays 以及标准的OO特性集,因此构建一个遗传JSONDOM模型并不难。 我不知道其他编码,但如果它们比JSON更麻烦的话,我会很惊讶的。 简短回答: D不支持它的本土化,但它不会很难让它工作。 |