Sfoglia il codice sorgente

Test user-defined AST nodes.

master
Ian Piumarta 1 anno fa
parent
commit
6ba66daa8b
1 ha cambiato i file con 15 aggiunte e 0 eliminazioni
  1. +15
    -0
      test.txt

+ 15
- 0
test.txt Vedi File

@ -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");

Caricamento…
Annulla
Salva