-
Notifications
You must be signed in to change notification settings - Fork 3
/
Scanner.Mod
62 lines (50 loc) · 1.55 KB
/
Scanner.Mod
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
MODULE Scanner;
CONST
(* ERROR in scan, e.g. string start found without end string, position in scan not updated *)
ERROR* = 0;
(* OK scan successful, not at end of text, position in scan updated *)
OK* = 1;
(* EOS, end of scan, scan successful but at end of text, position in scan not updated *)
EOS* = 2;
(* Common String Delimiters *)
EOT* = 0X; (* end of text *)
TAB* = 9X; (* tab *)
LF* = 10X; (* line feed *)
FF* = 11X; (* form feed *)
CR* = 13X; (* charriage return *)
SPACE* = 32X; (* space *)
DQUOTE* = 34X; (* double quote *)
SQUOTE* = 39X; (* single quote *)
SLASH* = 47X; (* slash or div symbol *)
BSLASH* = 92X; (* backslash *)
(** Character constants *)
DASH* = "-"; (* dash *)
LODASH* = "_"; (* underscore or low dash *)
CARET* = "^"; (* caret *)
TILDE* = "~"; (* tilde *)
TYPE
Scanner* = POINTER TO ScannerDesc;
ScannerDesc* = RECORD
delimiter: CHAR;
startString: CHAR;
endString: CHAR;
inString: BOOLEAN;
escape: CHAR;
Pos*: INTEGER
END;
PROCEDURE Init*(VAR scanner: Scanner; delimiter: CHAR; startString: CHAR; endString: CHAR; Escape: CHAR);
BEGIN
scanner.delimiter := delimiter;
scanner.startString := startString;
scanner.endString := endString;
scanner.escape := Escape;
scanner.inString := FALSE;
scanner.Pos := 0;
END Init;
PROCEDURE ScanChars*(VAR scanner: Scanner; src : ARRAY OF CHAR; VAR value: ARRAY OF CHAR; VAR OK: BOOLEAN);
BEGIN
END ScanChars;
END Scanner.
Scanner
=======
Scanner models a simple text scanner like that needed to process Oberon language files or Pascal.