forked from schierlm/Oberon2013Modifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LSPhServer.Mod.txt
55 lines (48 loc) · 1.6 KB
/
LSPhServer.Mod.txt
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
MODULE LSPhServer;
IMPORT SYSTEM, RS232, Files, Modules, Texts, Oberon, LSPhConstants, LSPhORS, LSPhORP;
VAR T: Oberon.Task;
W: Texts.Writer;
embedded: BOOLEAN;
PROCEDURE Rec(VAR x: BYTE);
VAR i: INTEGER;
BEGIN RS232.Rec(i); x := i
END Rec;
PROCEDURE Run*;
BEGIN Oberon.Install(T); LED(0F1H);
Texts.WriteString(W, "LSPhServer started");
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END Run;
PROCEDURE Stop*;
BEGIN Oberon.Remove(T);
Texts.WriteString(W, "LSPhServer stopped");
Texts.WriteLn(W); Texts.Append(Oberon.Log, W.buf)
END Stop;
PROCEDURE Task;
VAR code, x: BYTE; len, i: INTEGER;
F: Files.File;
R: Files.Rider;
BEGIN
WHILE embedded & ~RS232.Available() DO SYSTEM.PUT(-64, 7FFFFFFFH) END;
IF RS232.Available() THEN
Rec(code);
IF (code = LSPhConstants.GetModuleInfo) OR (code = LSPhConstants.AutoComplete) OR (code = LSPhConstants.ReFormat) THEN
F := Files.New("Tmp.Tmp");
Files.Set(R, F, 0);
RS232.RecInt(len);
FOR i := 0 TO len-1 DO Rec(x); Files.WriteByte(R, x) END;
IF code = LSPhConstants.AutoComplete THEN Files.Write(R, 3X) END;
Files.Register(F);
LSPhORS.SetMode(code);
LSPhORP.Analyze();
RS232.Send(LSPhConstants.OK)
ELSIF code = LSPhConstants.SwitchEmbeddedMode THEN
embedded := TRUE
ELSIF code = LSPhConstants.Exit THEN
Stop()
ELSE
RS232.Send(LSPhConstants.Invalid)
END
END; Oberon.Collect(0)
END Task;
BEGIN Texts.OpenWriter(W); T := Oberon.NewTask(Task, 0); embedded := FALSE
END LSPhServer.