summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 47136c2)
raw | patch | inline | side by side (parent: 47136c2)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 14 Dec 2019 15:11:25 +0000 (18:11 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 14 Dec 2019 15:11:25 +0000 (18:11 +0300) |
src/generic/Dev/Mod/CPR.cp | patch | blob | history |
index 233b12166f49d168784e965a08de086fcda5069f..b43b539bd2beebe3747961b7bd2aa1acb037a02e 100644 (file)
not = 10; and = 11; or = 12; rpar = 13; lpar = 14;
endcom = 15; eof = 16;
+ (* func numbers *)
+ var = 0; defined = 1;
+
TYPE
Context = POINTER TO RECORD
next: Context; (* upper level block *)
Selector = POINTER TO RECORD
next: Selector;
name: DevCPT.Name;
- val: BOOLEAN
+ val: BOOLEAN;
+ num: BYTE
END;
VAR
END
END Get;
- PROCEDURE New (IN name: DevCPT.Name; val: BOOLEAN);
+ PROCEDURE New (IN name: DevCPT.Name; val: BOOLEAN): Selector;
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.val := val
+ IF s.next = NIL THEN
+ NEW(s.next); s.next.name := name$; s.next.num := var; s.next.val := val
ELSE err(1)
- END
+ END;
+ RETURN s.next
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.val := FALSE
+ err(0); NEW(s.next); s.next.name := name$; s.next.num := var; s.next.val := FALSE
END;
RETURN s.next
END Old;
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.val := val END
+ IF s.next = NIL THEN NEW(s.next) END;
+ s.next.name := name$; s.next.num := var; s.next.val := val
END Set;
PROCEDURE ^ Expression (VAR x: BOOLEAN);
PROCEDURE Factor (VAR x: BOOLEAN);
+ VAR s: Selector;
BEGIN x := FALSE;
IF sym = ident THEN
- x := Old(name).val; Get(sym)
+ s := Old(name); Get(sym);
+ IF s.num = var THEN
+ x := s.val
+ ELSIF sym = lpar THEN
+ Get(sym);
+ ASSERT(s.num = defined);
+ IF sym = ident THEN
+ x := Find(name) # NIL; Get(sym)
+ ELSE err(48)
+ END;
+ IF sym # rpar THEN err(23)
+ ELSE Get(sym)
+ END
+ ELSE
+ err(40)
+ END
ELSIF sym = lpar THEN
Get(sym); Expression(x);
IF sym # rpar THEN err(23)
END End;
PROCEDURE Parse*;
- VAR val: BOOLEAN;
+ VAR val: BOOLEAN; s: Selector;
BEGIN
Get(sym);
IF sym = new THEN
Get(sym);
- IF sym = ident THEN New(name, FALSE); Get(sym)
+ IF sym = ident THEN s := New(name, FALSE); Get(sym)
ELSE err(48)
END
ELSIF sym = ident THEN
END Close;
PROCEDURE Init*;
+ VAR s: Selector;
BEGIN
Close;
If(TRUE);
NEW(scope);
- New("TRUE", TRUE);
- New("FALSE", FALSE)
+ s := New("TRUE", TRUE);
+ s := New("FALSE", FALSE);
+ s := New("DEFINED", FALSE); s.num := defined
END Init;
END DevCPR.