-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-scanner.leaf
More file actions
201 lines (173 loc) · 3.88 KB
/
test-scanner.leaf
File metadata and controls
201 lines (173 loc) · 3.88 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
(* LEAF module example *)
MODULE Phonebook ["repo" : 'none']
IMPORT Errors, Log := ConsoleLog
CONST
One*
Two*
Three*
CONST
count* = 45
err = -1
real = 0.1
hello* = "Hello, world!"
hello2 = 'Hello, world!'
boolean = TRUE
trilean = NIL
char = 000AU
(* возможные кандидаты *)
hex = 031FH
non = 0ZW3N
tri = 0+-+-T
bin = 01010B
TYPE
hash POINTER TO MAP OF STRING, LIST 16 OF INTEGER;
Item* POINTER TO ItemDesc
ItemDesc* MAP
depth* INTEGER
name* STRING
phone* STRING
tags* SET OF ATOM WITH
One; Two; Three
END
type- ATOM
parent- List
Update- PROCEDURE
THIS item Item
END
END
List* POINTER TO LIST OF Item WITH
Contains- PROCEDURE
THIS list List
IN item Item
OUT contains BOOLEAN
PRE item # NIL
END
CreateAndAdd- PROCEDURE
THIS list List
OUT item Item
POST item # NIL
POST item.parent = list
END
END
Some POINTER TO MAP OF STRING, LIST OF INTEGER;
Some POINTER TO MAP OF STRING, POINTER TO LIST OF INTEGER;
Some SET OF INTEGER WITH
0, 1 .. 50, 88
END
VAR
dir- Directory
PROCEDURE Contains
THIS list List
IN item Item
OUT contains BOOLEAN
PRE item # NIL
VAR i INTEGER
BEGIN
i := 0
WHILE i<LEN(list) & ~contains DO
contains := list[i] = item
INC(i)
END
END Contains
PROCEDURE CreateAndAdd
THIS list List
OUT item Item
POST item # NIL
POST item.parent = list
VAR idx INTEGER
BEGIN
idx := LEN(list);
RESIZE(list, LEN(list)+1)
list[idx] := (NewItem list)
END CreateAndAdd
PROCEDURE Remove
THIS list List
IN item Item
PRE item#NIL
PRE item.parent = list
POST ~(list.Contains item) && item.parent = NIL
BEGIN
REMOVE(list, item)
item.parent = NIL
END Remove
PROCEDURE Update
THIS item Item
BEGIN
HALT(Errors.notImplemented)
END Update
PROCEDURE NewItem
IN parent List
OUT i Item
PRE parent # NIL
POST i # NIL & i.parent = parent
BEGIN
NEW(i)
i.parent = parent
i.Update = Update
END NewItem
PROCEDURE NewList
OUT l List
POST l#NIL
BEGIN
NEW(l)
l.Contains = Contains
l.CreateAndAdd = CreateAndAdd
l(MAP).SET(Delete, Remove)
END NewList
PROCEDURE Init
VAR l List; i Item
BEGIN
NewList(l)
l.CreateAndAdd(i)
i.name := "Moses"
i.phone := "223322"
i.tags := {One, Three}
i(MAP).SET(surname, "Go Down")
Log.String(i.name + " " + i.surname)
i.tags := i.tags + {Two}
i.Update;
END Init
PROCEDURE Some*
BEGIN
i
a[i]
t^.left^.right^.pos
t(Tree).node
Texts.Pos()
ok := (Exists item)
res := (a[i] Do b[j])
x := (cond Tern A B)
i := 0
x := i + 1
a := b | c
ret := "Hello" + ',' + 0020U + name
Do(this, count)
rec.Handle(msg)
IF (x # NIL) & (x.a = 0) THEN Do0
ELSIF (x # NIL) & (x.a < 0) THEN DoP
ELSIF (x # NIL) & (x.a > 0) THEN DoN
ELSE (* x = NIL *)
Od
END
MATCH
CASE a & b & c DO DoA
CASE ~a & b DO DoB
ELSE DoNothing END
WHILE a & b DO Do0
ELSIF a & ~b DO Do1
ELSIF ~a & ~b DO Do2
END
REPEAT Do0 UNTIL isFalse
MATCH (x)
CASE Node DO DoNode(x)
CASE Leaf DO DoLeaf(x)
CASE NIL DO NilPanic
ELSE DoElse(x) END
x:= a / b
x:= a//b
x:=a%b
END Some
BEGIN
DO(Init)
CLOSE
END Phonebook.