index b43b539bd2beebe3747961b7bd2aa1acb037a02e..b1787397516a9f973992d5c622f678c85bc985c4 100644 (file)
(* symbol values *)
null = 0;
(* symbol values *)
null = 0;
- if = 1; then = 2; else = 3; elsif = 4; end = 5; new = 6;
- ident = 7; plus = 8; minus = 9;
- not = 10; and = 11; or = 12; rpar = 13; lpar = 14;
- endcom = 15; eof = 16;
-
- (* func numbers *)
- var = 0; defined = 1;
+ if = 1; then = 2; else = 3; elsif = 4; end = 5;
+ new = 6; error = 7; ident = 8; plus = 9; minus = 10;
+ not = 11; and = 12; or = 13; rpar = 14; lpar = 15; defined = 16;
+ endcom = 17; eof = 18;
TYPE
Context = POINTER TO RECORD
TYPE
Context = POINTER TO RECORD
Selector = POINTER TO RECORD
next: Selector;
name: DevCPT.Name;
Selector = POINTER TO RECORD
next: Selector;
name: DevCPT.Name;
- val: BOOLEAN;
- num: BYTE
+ val: BOOLEAN
END;
VAR
END;
VAR
- ch: CHAR; (* current character *)
+ ch-: CHAR; (* current character *)
name: DevCPT.Name; (* ident *)
VAR
name: DevCPT.Name; (* ident *)
VAR
IF ch = ">" THEN sym := endcom; DevCPM.Get(ch) END
| "+": sym := plus; DevCPM.Get(ch)
| "-": sym := minus; DevCPM.Get(ch)
IF ch = ">" THEN sym := endcom; DevCPM.Get(ch) END
| "+": sym := plus; DevCPM.Get(ch)
| "-": sym := minus; DevCPM.Get(ch)
+ | "D": Identifier(sym); IF name = "DEFINED" THEN sym := defined END
| "E": Identifier(sym);
IF name = "END" THEN sym := end
ELSIF name = "ELSE" THEN sym := else
ELSIF name = "ELSIF" THEN sym := elsif
| "E": Identifier(sym);
IF name = "END" THEN sym := end
ELSIF name = "ELSE" THEN sym := else
ELSIF name = "ELSIF" THEN sym := elsif
+ ELSIF name = "ERROR" THEN sym := error
END
| "I": Identifier(sym); IF name = "IF" THEN sym := if END
| "N": Identifier(sym); IF name = "NEW" THEN sym := new END
| "O": Identifier(sym); IF name = "OR" THEN sym := or END
| "T": Identifier(sym); IF name = "THEN" THEN sym := then END
END
| "I": Identifier(sym); IF name = "IF" THEN sym := if END
| "N": Identifier(sym); IF name = "NEW" THEN sym := new END
| "O": Identifier(sym); IF name = "OR" THEN sym := or END
| "T": Identifier(sym); IF name = "THEN" THEN sym := then END
- | "A".."D", "J".."M", "P".."S", "U".."Z", "a".."z", "_": Identifier(sym)
+ | "A".."C", "J".."M", "P".."S", "U".."Z", "a".."z", "_": Identifier(sym)
| "~": sym := not; DevCPM.Get(ch)
ELSE
IF Strings.IsIdent(ch) THEN Identifier(sym) ELSE sym := null; DevCPM.Get(ch) END
END
END Get;
| "~": sym := not; DevCPM.Get(ch)
ELSE
IF Strings.IsIdent(ch) THEN Identifier(sym) ELSE sym := null; DevCPM.Get(ch) END
END
END Get;
- PROCEDURE New (IN name: DevCPT.Name; val: BOOLEAN): Selector;
+ PROCEDURE New (IN name: DevCPT.Name): Selector;
VAR s: Selector;
BEGIN
s := scope;
WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END;
VAR s: Selector;
BEGIN
s := scope;
WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END;
- IF s.next = NIL THEN
- NEW(s.next); s.next.name := name$; s.next.num := var; s.next.val := val
+ IF s.next = NIL THEN NEW(s.next); s.next.name := name$; s.next.val := FALSE
ELSE err(1)
END;
RETURN s.next
ELSE err(1)
END;
RETURN s.next
s := scope;
WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END;
IF s.next = NIL THEN
s := scope;
WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END;
IF s.next = NIL THEN
- err(0); NEW(s.next); s.next.name := name$; s.next.num := var; s.next.val := FALSE
+ err(0); NEW(s.next); s.next.name := name$; s.next.val := FALSE
END;
RETURN s.next
END Old;
END;
RETURN s.next
END Old;
s := scope;
WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END;
IF s.next = NIL THEN NEW(s.next) END;
s := scope;
WHILE (s.next # NIL) & (s.next.name$ # name$) DO s := s.next END;
IF s.next = NIL THEN NEW(s.next) END;
- s.next.name := name$; s.next.num := var; s.next.val := val
+ s.next.name := name$; s.next.val := val
END Set;
PROCEDURE ^ Expression (VAR x: BOOLEAN);
PROCEDURE Factor (VAR x: BOOLEAN);
END Set;
PROCEDURE ^ Expression (VAR x: BOOLEAN);
PROCEDURE Factor (VAR x: BOOLEAN);
- VAR s: Selector;
- BEGIN x := FALSE;
+ BEGIN
IF sym = ident THEN
IF sym = ident THEN
- s := Old(name); Get(sym);
- IF s.num = var THEN
- x := s.val
- ELSIF sym = lpar THEN
+ x := Old(name).val; Get(sym);
+ ELSIF sym = defined THEN
+ Get(sym);
+ IF sym = lpar THEN
Get(sym);
Get(sym);
- ASSERT(s.num = defined);
IF sym = ident THEN
IF sym = ident THEN
- x := Find(name) # NIL; Get(sym)
+ x := Find(name) # NIL;
+ Get(sym)
ELSE err(48)
END;
IF sym # rpar THEN err(23)
ELSE Get(sym)
END
ELSE err(48)
END;
IF sym # rpar THEN err(23)
ELSE Get(sym)
END
- ELSE
- err(40)
- END
+ ELSE err(40)
+ END
ELSIF sym = lpar THEN
Get(sym); Expression(x);
IF sym # rpar THEN err(23)
ELSIF sym = lpar THEN
Get(sym); Expression(x);
IF sym # rpar THEN err(23)
ELSIF sym = not THEN
Get(sym); Factor(x); x := ~x
ELSE
ELSIF sym = not THEN
Get(sym); Factor(x); x := ~x
ELSE
+ x := FALSE;
err(13)
END
END Factor;
err(13)
END
END Factor;
IF top = NIL THEN err(51); fold := 0; If(TRUE) END
END End;
IF top = NIL THEN err(51); fold := 0; If(TRUE) END
END End;
+ PROCEDURE Printable* (): BOOLEAN;
+ VAR c: Context;
+ BEGIN
+ c := top;
+ WHILE (c # NIL) & c.val DO c := c.next END;
+ RETURN c = NIL
+ END Printable;
+
PROCEDURE Parse*;
VAR val: BOOLEAN; s: Selector;
BEGIN
PROCEDURE Parse*;
VAR val: BOOLEAN; s: Selector;
BEGIN
- Get(sym);
+ ch := " "; Get(sym);
IF sym = new THEN
Get(sym);
IF sym = new THEN
Get(sym);
- IF sym = ident THEN s := New(name, FALSE); Get(sym)
+ IF sym = ident THEN
+ s := New(name); Get(sym);
+ IF (sym = plus) OR (sym = minus) THEN
+ s.val := sym = plus; Get(sym)
+ END
ELSE err(48)
END
ELSIF sym = ident THEN
ELSE err(48)
END
ELSIF sym = ident THEN
- Get(sym);
- IF sym = plus THEN Old(name).val := TRUE; Get(sym)
- ELSIF sym = minus THEN Old(name).val := FALSE; Get(sym)
+ s := Old(name); Get(sym);
+ IF (sym = plus) OR (sym = minus) THEN
+ s.val := sym = plus; Get(sym)
ELSE err(41)
END
ELSE err(41)
END
+ ELSIF sym = error THEN
+ IF Printable() THEN err(501) END; Get(sym)
ELSIF sym = if THEN
Get(sym); Expression(val); If(val);
IF sym = then THEN Get(sym)
ELSIF sym = if THEN
Get(sym); Expression(val); If(val);
IF sym = then THEN Get(sym)
IF sym # endcom THEN err(5) ELSE DevCPM.errpos := DevCPM.curpos - 1 END
END Parse;
IF sym # endcom THEN err(5) ELSE DevCPM.errpos := DevCPM.curpos - 1 END
END Parse;
- PROCEDURE Printable* (): BOOLEAN;
- VAR c: Context;
- BEGIN
- c := top;
- WHILE (c # NIL) & c.val DO c := c.next END;
- RETURN c = NIL
- END Printable;
-
PROCEDURE Check*;
BEGIN
IF fold # 1 THEN err(14) END
PROCEDURE Check*;
BEGIN
IF fold # 1 THEN err(14) END
Close;
If(TRUE);
NEW(scope);
Close;
If(TRUE);
NEW(scope);
- s := New("TRUE", TRUE);
- s := New("FALSE", FALSE);
- s := New("DEFINED", FALSE); s.num := defined
+ Set("TRUE", TRUE);
+ Set("FALSE", FALSE)
END Init;
END DevCPR.
END Init;
END DevCPR.