summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9adab54)
raw | patch | inline | side by side (parent: 9adab54)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 14 Dec 2019 18:58:46 +0000 (21:58 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 14 Dec 2019 18:58:46 +0000 (21:58 +0300) |
src/generic/Dev/Mod/CPR.cp | patch | blob | history |
index 851d82e8b6000813164542de76d1b619d3e42194..aaf4c8afb54ce95487c4b72639b82485e631594f 100644 (file)
null = 0;
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;
- endcom = 16; eof = 17;
-
- (* func numbers *)
- var = 0; defined = 1;
+ not = 11; and = 12; or = 13; rpar = 14; lpar = 15; defined = 16;
+ endcom = 17; eof = 18;
TYPE
Context = POINTER TO RECORD
Selector = POINTER TO RECORD
next: Selector;
name: DevCPT.Name;
- val: BOOLEAN;
- num: BYTE
+ val: BOOLEAN
END;
VAR
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
| "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;
- PROCEDURE New (IN name: DevCPT.Name; val: BOOLEAN): Selector;
+ PROCEDURE New (IN name: DevCPT.Name; val: BOOLEAN);
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 := val
ELSE err(1)
- END;
- RETURN s.next
+ END
END New;
PROCEDURE Old (IN name: DevCPT.Name): Selector;
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;
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);
- VAR s: Selector;
- BEGIN x := FALSE;
+ BEGIN
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);
- ASSERT(s.num = defined);
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(40)
- END
+ ELSE err(40)
+ END
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
+ x := FALSE;
err(13)
END
END Factor;
END Printable;
PROCEDURE Parse*;
- VAR val: BOOLEAN; s: Selector;
+ VAR val: BOOLEAN;
BEGIN
Get(sym);
IF sym = new THEN
Get(sym);
- IF sym = ident THEN s := New(name, FALSE); Get(sym)
+ IF sym = ident THEN New(name, FALSE); Get(sym)
ELSE err(48)
END
ELSIF sym = error THEN
Close;
If(TRUE);
NEW(scope);
- s := New("TRUE", TRUE);
- s := New("FALSE", FALSE);
- s := New("DEFINED", FALSE); s.num := defined
+ New("TRUE", TRUE);
+ New("FALSE", FALSE)
END Init;
END DevCPR.