浏览代码

Test user-defined AST nodes.

master
Ian Piumarta 1年前
父节点
当前提交
6ba66daa8b
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. +15
    -0
      test.txt

+ 15
- 0
test.txt 查看文件

@ -320,6 +320,21 @@ print("call testfun\n");
testfun();
// used-defined AST nodes are evaluated the same way as built-in types
MakeSeven = Object.subtype(#MakeSeven);
MakeSeven.__eval__(exp, env) {
print("MakeSeven.__eval__ invoked\n");
7;
}
myNode = MakeSeven.new();
ast = (`6 * @myNode;); // user-defined node in AST
print("AST eval => ", eval(ast), "\n");
for (i from 0 to 10) print(i, " "); print("\n");
for (i from 10 to 0) print(i, " "); print("\n");
for (i in 10) print(i, " "); print("\n");

正在加载...
取消
保存