-
Notifications
You must be signed in to change notification settings - Fork 2
/
In.cp
95 lines (84 loc) · 1.79 KB
/
In.cp
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
MODULE In;
(**
project = "BlackBox"
organization = "www.oberon.ch"
contributors = "Oberon microsystems"
version = "System/Rsrc/About"
copyright = "System/Rsrc/About"
license = "Docu/BB-License"
changes = ""
issues = ""
**)
IMPORT TextMappers, TextControllers;
VAR
Done-: BOOLEAN;
s: TextMappers.Scanner;
PROCEDURE Open*;
VAR c: TextControllers.Controller; beg, end: INTEGER;
BEGIN
c := TextControllers.Focus();
IF c # NIL THEN
IF c.HasSelection() THEN c.GetSelection(beg, end) ELSE beg := 0 END;
s.ConnectTo(c.text); s.SetPos(beg); s.rider.Read; Done := TRUE
ELSE
s.ConnectTo(NIL); Done := FALSE
END
END Open;
PROCEDURE Char* (OUT ch: CHAR);
BEGIN
IF Done THEN
IF s.rider.eot THEN Done := FALSE
ELSE ch := s.rider.char; s.rider.Read
END
END
END Char;
PROCEDURE Int* (OUT i: INTEGER);
BEGIN
IF Done THEN
s.Scan;
IF (s.type = TextMappers.int) THEN
i := s.int
ELSE Done := FALSE
END
END
END Int;
PROCEDURE LongInt* (OUT l: LONGINT);
BEGIN
IF Done THEN
s.Scan;
IF (s.type = TextMappers.lint) OR (s.type = TextMappers.int) THEN
l := s.lint
ELSE Done := FALSE
END
END
END LongInt;
PROCEDURE Real* (OUT x: REAL);
BEGIN
IF Done THEN
s.Scan;
IF s.type = TextMappers.real THEN
x := SHORT(s.real)
ELSIF s.type = TextMappers.int THEN
x := s.int
ELSE Done := FALSE
END
END
END Real;
PROCEDURE Name* (OUT name: ARRAY OF CHAR);
BEGIN
IF Done THEN
s.Scan;
TextMappers.ScanQualIdent(s, name, Done)
END
END Name;
PROCEDURE String* (OUT str: ARRAY OF CHAR);
BEGIN
IF Done THEN
s.Scan;
IF s.type = TextMappers.string THEN
str := s.string$
ELSE Done := FALSE
END
END
END String;
END In.