-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.tiny
43 lines (34 loc) · 1000 Bytes
/
sample.tiny
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# This program is an example of the interpreted Tiny language
# Assignments update the symbol table
# All identifiers are global
# There are only floats and strings in the language
# The language is case-sensitive
A = 12
aFloat = -45.6
B = "test"
# The symbol table now contains
# A numeric 12
# aFloat numeric -45.6
# B string "test"
# All expressions are in postfix notation
expr1 = 12 13 +
expr2 = A expr1 -
# The symbol table now contains
# A numeric 12
# aFloat numeric -45.6
# B string "test"
# expr1 numeric 25
# expr2 numeric -13
# print and println take one argument
print expr
println "Hello World"
# Error message since the identifier is not in symbol table
print expr3
# Error message since the identifier is not in symbol table
print expr3
# The language has a simple postfix conditional if statement
if (expr1 expr2 ==) (A 12 <) &&
endif
# The language has a simple postfix conditional while loop
while (expr1 expr2 ==)
endwhile