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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# tests for the interpreter
proc loops(a: var int) =
nil
#var
# b: int
#b = glob
#while b != 0:
# b = b + 1
#a = b
proc mymax(a, b: int): int =
#loops(result)
result = a
if b > a: result = b
proc test(a, b: int) =
var
x, y: int
x = 0
y = 7
if x == a + b * 3 - 7 or
x == 8 or
x == y and y > -56 and y < 699:
y = 0
elif y == 78 and x == 0:
y = 1
elif y == 0 and x == 0:
y = 2
else:
y = 3
type
TTokType = enum
tkNil, tkType, tkConst, tkVar, tkSymbol, tkIf,
tkWhile, tkFor, tkLoop, tkCase, tkLabel, tkGoto
proc testCase(t: TTokType): int =
case t
of tkNil, tkType, tkConst: result = 0
of tkVar: result = 1
of tkSymbol: result = 2
of tkIf..tkFor: result = 3
of tkLoop: result = 56
else: result = -1
test(0, 9) # test the call
proc TestLoops() =
var
i, j: int
while i >= 0:
if i mod 3 == 0:
break
i = i + 1
while j == 13:
j = 13
break
break
while True:
break
var
glob: int
a: array [0..5, int]
proc main() =
#glob = 0
#loops( glob )
var
res: int
s: string
#write(stdout, mymax(23, 45))
write(stdout, "Hallo! Wie hei�t du? ")
s = readLine(stdin)
# test the case statement
case s
of "Andreas": write(stdout, "Du bist mein Meister!\n")
of "Rumpf": write(stdout, "Du bist in der Familie meines Meisters!\n")
else: write(stdout, "ich kenne dich nicht!\n")
write(stdout, "Du heisst " & s & "\n")
main()
|