Dragging in some modules when X86Compiler is used, so scripts can use them.
[trylon.git] / tests / interpreter
blob9b3adb70db576cb074eb39a1d9f51ee208403992
1 #!/usr/bin/env trylon-interpreter
3 # Declaration, expression.
4 message = "Hello world!"
5 print-line: message
7 # "if".
8 if 2 < 3
9         Standard print-line: "Yeh."
10 else
11         Standard print-line: "Nah."
13 # "loop"
14 i = 0
15 loop
16         Standard print-line: i string
17         if i >= 3
18                 break
19         i += 1
20 Standard print-line: "-----"
22 # "while"
23 i = 0
24 while i < 3
25         Standard print-line: i string
26         i += 1
27 Standard print-line: "-----"
29 # "for"
30 for char in "abc" characters
31         if char == `b`
32                 continue
33         Standard print-line: char char-string
34 Standard print-line: "-----"
35 print-line
37 # Files.
38 for file in ("interpreter", "tests/interpreter")
39         try
40                 contents = File contents-of: file
41                 line-number = 1
42                 for line in contents lines
43                         print: line-number string
44                         print: ": "
45                         print-line: line
46                         line-number += 1
47         else
48                 print-line: exception message
50 # We can get to the compiler.  But what could we do with it?
51 Compiler