mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 06:22:25 +00:00
Deduplicate common constants into OPM and do some source format tidying.
This commit is contained in:
parent
b1dc7d77e8
commit
480c2e02eb
7 changed files with 3401 additions and 3633 deletions
1272
src/compiler/OPB.Mod
1272
src/compiler/OPB.Mod
File diff suppressed because it is too large
Load diff
2707
src/compiler/OPC.Mod
2707
src/compiler/OPC.Mod
File diff suppressed because it is too large
Load diff
|
|
@ -79,6 +79,127 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
||||||
HFext = ".h"; (* header file extension *)
|
HFext = ".h"; (* header file extension *)
|
||||||
SFtag = 0F7X; (* symbol file tag *)
|
SFtag = 0F7X; (* symbol file tag *)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(***** Symbols *****)
|
||||||
|
|
||||||
|
|
||||||
|
(* Symbols values (also used as op values):
|
||||||
|
| 0 1 2 3 4
|
||||||
|
---|--------------------------------------------------------
|
||||||
|
0 | null * / DIV MOD
|
||||||
|
5 | & + - OR =
|
||||||
|
10 | # < <= > >=
|
||||||
|
15 | IN IS ^ . ,
|
||||||
|
20 | : .. ) ] }
|
||||||
|
25 | OF THEN DO TO BY
|
||||||
|
30 | ( [ { ~ :=
|
||||||
|
35 | number NIL string OPM.ident ;
|
||||||
|
40 | | END ELSE ELSIF UNTIL
|
||||||
|
45 | IF CASE WHILE REPEAT FOR
|
||||||
|
50 | LOOP WITH EXIT RETURN ARRAY
|
||||||
|
55 | RECORD POINTER BEGIN CONST TYPE
|
||||||
|
60 | VAR PROCEDURE IMPORT MODULE eof
|
||||||
|
*)
|
||||||
|
|
||||||
|
null* = 0; times* = 1; slash* = 2; div* = 3; mod* = 4;
|
||||||
|
and* = 5; plus* = 6; minus* = 7; or* = 8; eql* = 9;
|
||||||
|
neq* = 10; lss* = 11; leq* = 12; gtr* = 13; geq* = 14;
|
||||||
|
in* = 15; is* = 16; arrow* = 17; period* = 18; comma* = 19;
|
||||||
|
colon* = 20; upto* = 21; rparen* = 22; rbrak* = 23; rbrace* = 24;
|
||||||
|
of* = 25; then* = 26; do* = 27; to* = 28; by* = 29;
|
||||||
|
lparen* = 30; lbrak* = 31; lbrace* = 32; not* = 33; becomes* = 34;
|
||||||
|
number* = 35; nil* = 36; string* = 37; ident* = 38; semicolon* = 39;
|
||||||
|
bar* = 40; end* = 41; else* = 42; elsif* = 43; until* = 44;
|
||||||
|
if* = 45; case* = 46; while* = 47; repeat* = 48; for* = 49;
|
||||||
|
loop* = 50; with* = 51; exit* = 52; return* = 53; array* = 54;
|
||||||
|
record* = 55; pointer* = 56; begin* = 57; const* = 58; type* = 59;
|
||||||
|
var* = 60; procedure* = 61; import* = 62; module* = 63; eof* = 64;
|
||||||
|
|
||||||
|
(* Symbol numtyp values *)
|
||||||
|
char* = 1; integer* = 2; real* = 3; longreal* = 4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(***** Objects *****)
|
||||||
|
|
||||||
|
|
||||||
|
(* Object.mode values *)
|
||||||
|
Var* = 1; VarPar* = 2; Con* = 3; Fld* = 4; Typ* = 5; LProc* = 6; XProc* = 7;
|
||||||
|
SProc* = 8; CProc* = 9; IProc* = 10; Mod* = 11; Head* = 12; TProc* = 13;
|
||||||
|
|
||||||
|
(* Object.vis - module visibility of objects *)
|
||||||
|
internal* = 0; external* = 1; externalR* = 2;
|
||||||
|
|
||||||
|
(* Object.history - History of imported objects *)
|
||||||
|
inserted* = 0; same* = 1; pbmodified* = 2; pvmodified* = 3; removed* = 4; inconsistent* = 5;
|
||||||
|
|
||||||
|
(* Object.adr Function numbers *)
|
||||||
|
haltfn* = 0; newfn* = 1; absfn* = 2; capfn* = 3; ordfn* = 4;
|
||||||
|
entierfn* = 5; oddfn* = 6; minfn* = 7; maxfn* = 8; chrfn* = 9;
|
||||||
|
shortfn* = 10; longfn* = 11; sizefn* = 12; incfn* = 13; decfn* = 14;
|
||||||
|
inclfn* = 15; exclfn* = 16; lenfn* = 17; copyfn* = 18; ashfn* = 19;
|
||||||
|
adrfn* = 20; ccfn* = 21; lshfn* = 22; rotfn* = 23; getfn* = 24; (* SYSTEM *)
|
||||||
|
putfn* = 25; getrfn* = 26; putrfn* = 27; bitfn* = 28; valfn* = 29; (* SYSTEM *)
|
||||||
|
sysnewfn* = 30; movefn* = 31; (* SYSTEM *)
|
||||||
|
assertfn* = 32;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(***** Structures *****)
|
||||||
|
|
||||||
|
|
||||||
|
(* Struct.form values *)
|
||||||
|
Undef* = 0; Byte* = 1; Bool* = 2; Char* = 3;
|
||||||
|
SInt* = 4; Int* = 5; LInt* = 6;
|
||||||
|
Real* = 7; LReal* = 8; Set* = 9; String* = 10;
|
||||||
|
NilTyp* = 11; NoTyp* = 12; Pointer* = 13; ProcTyp* = 14;
|
||||||
|
Comp* = 15;
|
||||||
|
|
||||||
|
intSet* = {SInt..LInt(*, Int8..Int64*)}; realSet* = {Real, LReal};
|
||||||
|
|
||||||
|
(* Struct.comp - Composite structure forms *)
|
||||||
|
Basic* = 1; Array* = 2; DynArr* = 3; Record* = 4;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(***** Nodes *****)
|
||||||
|
|
||||||
|
|
||||||
|
(* Node.class values *)
|
||||||
|
Nvar* = 0; Nvarpar* = 1; Nfield* = 2; Nderef* = 3; Nindex* = 4; Nguard* = 5; Neguard* = 6;
|
||||||
|
Nconst* = 7; Ntype* = 8; Nproc* = 9; Nupto* = 10; Nmop* = 11; Ndop* = 12; Ncall* = 13;
|
||||||
|
Ninittd* = 14; Nif* = 15; Ncaselse* = 16; Ncasedo* = 17; Nenter* = 18; Nassign* = 19;
|
||||||
|
Nifelse* = 20; Ncase* = 21; Nwhile* = 22; Nrepeat* = 23; Nloop* = 24; Nexit* = 25;
|
||||||
|
Nreturn* = 26; Nwith* = 27; Ntrap* = 28;
|
||||||
|
|
||||||
|
|
||||||
|
(* Node.subcl values - general *)
|
||||||
|
assign* = 0; (* Pseudo function number for assignment *)
|
||||||
|
super* = 1;
|
||||||
|
|
||||||
|
(* Node.subcl values - functions *)
|
||||||
|
ash* = 17; msk* = 18; len* = 19;
|
||||||
|
conv* = 20; abs* = 21; cap* = 22; odd* = 23;
|
||||||
|
|
||||||
|
(* Node.subcl values - SYSTEM functions *)
|
||||||
|
adr* = 24; cc* = 25; bit* = 26; lsh* = 27; rot* = 28; val* = 29;
|
||||||
|
|
||||||
|
(* Note: some object.adr function numbers and some symbol types are
|
||||||
|
also are used as Node.subcl function ids *)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(* conval^.setval procedure flags *)
|
||||||
|
hasBody* = 1; isRedef* = 2; slNeeded* = 3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TYPE
|
TYPE
|
||||||
FileName = ARRAY 32 OF CHAR;
|
FileName = ARRAY 32 OF CHAR;
|
||||||
|
|
||||||
|
|
@ -142,27 +263,30 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
||||||
i := 1; (* skip - *)
|
i := 1; (* skip - *)
|
||||||
WHILE s[i] # 0X DO
|
WHILE s[i] # 0X DO
|
||||||
CASE s[i] OF
|
CASE s[i] OF
|
||||||
| "e": opt := opt / {extsf}
|
|
||||||
| "s": opt := opt / {newsf}
|
|
||||||
| "m": opt := opt / {mainprog}
|
|
||||||
| "x": opt := opt / {inxchk}
|
|
||||||
| "r": opt := opt / {ranchk}
|
|
||||||
| "t": opt := opt / {typchk}
|
|
||||||
| "a": opt := opt / {assert}
|
| "a": opt := opt / {assert}
|
||||||
| "k": opt := opt / {ansi} (* undocumented *)
|
|
||||||
| "p": opt := opt / {ptrinit}
|
|
||||||
| "S": opt := opt / {dontasm}
|
|
||||||
| "c": opt := opt / {dontlink}
|
| "c": opt := opt / {dontlink}
|
||||||
| "M": opt := opt / {mainlinkstat}
|
| "e": opt := opt / {extsf}
|
||||||
| "f": opt := opt / {notcoloroutput}
|
| "f": opt := opt / {notcoloroutput}
|
||||||
| "F": opt := opt / {forcenewsym}
|
| "k": opt := opt / {ansi} (* undocumented *)
|
||||||
| "V": opt := opt / {verbose}
|
| "m": opt := opt / {mainprog}
|
||||||
|
| "p": opt := opt / {ptrinit}
|
||||||
|
| "r": opt := opt / {ranchk}
|
||||||
|
| "s": opt := opt / {newsf}
|
||||||
|
| "t": opt := opt / {typchk}
|
||||||
|
| "x": opt := opt / {inxchk}
|
||||||
|
|
||||||
| "B": IF s[i+1] # 0X THEN INC(i); IntSize := ORD(s[i]) - ORD('0') END;
|
| "B": IF s[i+1] # 0X THEN INC(i); IntSize := ORD(s[i]) - ORD('0') END;
|
||||||
IF s[i+1] # 0X THEN INC(i); PointerSize := ORD(s[i]) - ORD('0') END;
|
IF s[i+1] # 0X THEN INC(i); PointerSize := ORD(s[i]) - ORD('0') END;
|
||||||
IF s[i+1] # 0X THEN INC(i); Alignment := ORD(s[i]) - ORD('0') END;
|
IF s[i+1] # 0X THEN INC(i); Alignment := ORD(s[i]) - ORD('0') END;
|
||||||
ASSERT((IntSize = 2) OR (IntSize = 4));
|
ASSERT((IntSize = 2) OR (IntSize = 4));
|
||||||
ASSERT((PointerSize = 4) OR (PointerSize = 8));
|
ASSERT((PointerSize = 4) OR (PointerSize = 8));
|
||||||
ASSERT((Alignment = 4) OR (Alignment = 8))
|
ASSERT((Alignment = 4) OR (Alignment = 8));
|
||||||
|
Files.SetSearchPath("")
|
||||||
|
| "F": opt := opt / {forcenewsym}
|
||||||
|
| "M": opt := opt / {mainlinkstat}
|
||||||
|
| "S": opt := opt / {dontasm}
|
||||||
|
| "V": opt := opt / {verbose}
|
||||||
ELSE
|
ELSE
|
||||||
LogWStr(" warning: option ");
|
LogWStr(" warning: option ");
|
||||||
LogW(OptionChar);
|
LogW(OptionChar);
|
||||||
|
|
@ -484,10 +608,10 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
||||||
END GetProperty;
|
END GetProperty;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE minus(i: LONGINT): LONGINT;
|
PROCEDURE minusop(i: LONGINT): LONGINT;
|
||||||
BEGIN
|
BEGIN
|
||||||
RETURN -i;
|
RETURN -i;
|
||||||
END minus;
|
END minusop;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE power0(i, j : LONGINT) : LONGINT; (* we would like to calculate exact Min Max values in GetProperties, not hardcode em, noch *)
|
PROCEDURE power0(i, j : LONGINT) : LONGINT; (* we would like to calculate exact Min Max values in GetProperties, not hardcode em, noch *)
|
||||||
|
|
@ -529,9 +653,20 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
||||||
END VerboseListSizes;
|
END VerboseListSizes;
|
||||||
|
|
||||||
|
|
||||||
PROCEDURE Min(a,b: INTEGER): INTEGER;
|
PROCEDURE AlignSize*(size: LONGINT): INTEGER;
|
||||||
BEGIN IF a<b THEN RETURN a ELSE RETURN b END
|
VAR align: INTEGER;
|
||||||
END Min;
|
BEGIN
|
||||||
|
IF size < Alignment THEN
|
||||||
|
IF size > 8 THEN align := 16
|
||||||
|
ELSIF size > 4 THEN align := 8
|
||||||
|
ELSIF size > 2 THEN align := 4
|
||||||
|
ELSE align := SHORT(size)
|
||||||
|
END
|
||||||
|
ELSE
|
||||||
|
align := Alignment
|
||||||
|
END;
|
||||||
|
RETURN align
|
||||||
|
END AlignSize;
|
||||||
|
|
||||||
PROCEDURE GetProperties();
|
PROCEDURE GetProperties();
|
||||||
VAR
|
VAR
|
||||||
|
|
@ -547,28 +682,28 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
|
||||||
SetSize := LIntSize;
|
SetSize := LIntSize;
|
||||||
|
|
||||||
(* Calculate all type alignments *)
|
(* Calculate all type alignments *)
|
||||||
CharAlign := Min(Alignment, CharSize);
|
CharAlign := AlignSize(CharSize);
|
||||||
BoolAlign := Min(Alignment, BoolSize);
|
BoolAlign := AlignSize(BoolSize);
|
||||||
SIntAlign := Min(Alignment, SIntSize);
|
SIntAlign := AlignSize(SIntSize);
|
||||||
RecAlign := Min(Alignment, RecSize);
|
RecAlign := AlignSize(RecSize);
|
||||||
RealAlign := Min(Alignment, RealSize);
|
RealAlign := AlignSize(RealSize);
|
||||||
LRealAlign := Min(Alignment, LRealSize);
|
LRealAlign := AlignSize(LRealSize);
|
||||||
PointerAlign := Min(Alignment, PointerSize);
|
PointerAlign := AlignSize(PointerSize);
|
||||||
ProcAlign := Min(Alignment, ProcSize);
|
ProcAlign := AlignSize(ProcSize);
|
||||||
IntAlign := Min(Alignment, IntSize);
|
IntAlign := AlignSize(IntSize);
|
||||||
LIntAlign := Min(Alignment, LIntSize);
|
LIntAlign := AlignSize(LIntSize);
|
||||||
SetAlign := Min(Alignment, SetSize);
|
SetAlign := AlignSize(SetSize);
|
||||||
|
|
||||||
(* and I'd like to calculate it, not hardcode constants *)
|
(* and I'd like to calculate it, not hardcode constants *)
|
||||||
base := -2;
|
base := -2;
|
||||||
MinSInt := ASH(base, SIntSize*8-2);
|
MinSInt := ASH(base, SIntSize*8-2);
|
||||||
MaxSInt := minus(MinSInt + 1);
|
MaxSInt := minusop(MinSInt + 1);
|
||||||
|
|
||||||
MinInt := ASH(base, IntSize*8-2);
|
MinInt := ASH(base, IntSize*8-2);
|
||||||
MaxInt := minus(MinInt + 1);
|
MaxInt := minusop(MinInt + 1);
|
||||||
|
|
||||||
MinLInt := ASH(base, LIntSize*8-2);
|
MinLInt := ASH(base, LIntSize*8-2);
|
||||||
MaxLInt := minus(MinLInt +1);
|
MaxLInt := minusop(MinLInt +1);
|
||||||
|
|
||||||
IF RealSize = 4 THEN MaxReal := 3.40282346D38
|
IF RealSize = 4 THEN MaxReal := 3.40282346D38
|
||||||
ELSIF RealSize = 8 THEN MaxReal := 1.7976931348623157D307 * 9.999999
|
ELSIF RealSize = 8 THEN MaxReal := 1.7976931348623157D307 * 9.999999
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -10,9 +10,8 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
Name* = ARRAY MaxIdLen OF CHAR;
|
Name* = ARRAY MaxIdLen OF CHAR;
|
||||||
String* = ARRAY MaxStrLen OF CHAR;
|
String* = ARRAY MaxStrLen OF CHAR;
|
||||||
|
|
||||||
(* name, str, numtyp, intval, realval, lrlval are implicit results of Get *)
|
|
||||||
|
|
||||||
VAR
|
VAR
|
||||||
|
(* name, str, numtyp, intval, realval, lrlval are implicit results of Get *)
|
||||||
name*: Name;
|
name*: Name;
|
||||||
str*: String;
|
str*: String;
|
||||||
numtyp*: INTEGER; (* 1 = char, 2 = integer, 3 = real, 4 = longreal *)
|
numtyp*: INTEGER; (* 1 = char, 2 = integer, 3 = real, 4 = longreal *)
|
||||||
|
|
@ -20,43 +19,6 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
realval*: REAL;
|
realval*: REAL;
|
||||||
lrlval*: LONGREAL;
|
lrlval*: LONGREAL;
|
||||||
|
|
||||||
(*symbols:
|
|
||||||
| 0 1 2 3 4
|
|
||||||
---|--------------------------------------------------------
|
|
||||||
0 | null * / DIV MOD
|
|
||||||
5 | & + - OR =
|
|
||||||
10 | # < <= > >=
|
|
||||||
15 | IN IS ^ . ,
|
|
||||||
20 | : .. ) ] }
|
|
||||||
25 | OF THEN DO TO BY
|
|
||||||
30 | ( [ { ~ :=
|
|
||||||
35 | number NIL string ident ;
|
|
||||||
40 | | END ELSE ELSIF UNTIL
|
|
||||||
45 | IF CASE WHILE REPEAT FOR
|
|
||||||
50 | LOOP WITH EXIT RETURN ARRAY
|
|
||||||
55 | RECORD POINTER BEGIN CONST TYPE
|
|
||||||
60 | VAR PROCEDURE IMPORT MODULE eof *)
|
|
||||||
|
|
||||||
CONST
|
|
||||||
(* numtyp values *)
|
|
||||||
char = 1; integer = 2; real = 3; longreal = 4;
|
|
||||||
|
|
||||||
(*symbol values*)
|
|
||||||
null = 0; times = 1; slash = 2; div = 3; mod = 4;
|
|
||||||
and = 5; plus = 6; minus = 7; or = 8; eql = 9;
|
|
||||||
neq = 10; lss = 11; leq = 12; gtr = 13; geq = 14;
|
|
||||||
in = 15; is = 16; arrow = 17; period = 18; comma = 19;
|
|
||||||
colon = 20; upto = 21; rparen = 22; rbrak = 23; rbrace = 24;
|
|
||||||
of = 25; then = 26; do = 27; to = 28; by = 29;
|
|
||||||
lparen = 30; lbrak = 31; lbrace = 32; not = 33; becomes = 34;
|
|
||||||
number = 35; nil = 36; string = 37; ident = 38; semicolon = 39;
|
|
||||||
bar = 40; end = 41; else = 42; elsif = 43; until = 44;
|
|
||||||
if = 45; case = 46; while = 47; repeat = 48; for = 49;
|
|
||||||
loop = 50; with = 51; exit = 52; return = 53; array = 54;
|
|
||||||
record = 55; pointer = 56; begin = 57; const = 58; type = 59;
|
|
||||||
var = 60; procedure = 61; import = 62; module = 63; eof = 64;
|
|
||||||
|
|
||||||
VAR
|
|
||||||
ch: CHAR; (*current character*)
|
ch: CHAR; (*current character*)
|
||||||
|
|
||||||
PROCEDURE err(n: INTEGER);
|
PROCEDURE err(n: INTEGER);
|
||||||
|
|
@ -74,8 +36,8 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
END ;
|
END ;
|
||||||
OPM.Get(ch); str[i] := 0X; intval := i + 1;
|
OPM.Get(ch); str[i] := 0X; intval := i + 1;
|
||||||
IF intval = 2 THEN
|
IF intval = 2 THEN
|
||||||
sym := number; numtyp := 1; intval := ORD(str[0])
|
sym := OPM.number; numtyp := 1; intval := ORD(str[0])
|
||||||
ELSE sym := string
|
ELSE sym := OPM.string
|
||||||
END
|
END
|
||||||
END Str;
|
END Str;
|
||||||
|
|
||||||
|
|
@ -86,7 +48,7 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
name[i] := ch; INC(i); OPM.Get(ch)
|
name[i] := ch; INC(i); OPM.Get(ch)
|
||||||
UNTIL (ch < "0") OR ("9" < ch) & (CAP(ch) < "A") OR ("Z" < CAP(ch)) OR (i = MaxIdLen);
|
UNTIL (ch < "0") OR ("9" < ch) & (CAP(ch) < "A") OR ("Z" < CAP(ch)) OR (i = MaxIdLen);
|
||||||
IF i = MaxIdLen THEN err(240); DEC(i) END ;
|
IF i = MaxIdLen THEN err(240); DEC(i) END ;
|
||||||
name[i] := 0X; sym := ident
|
name[i] := 0X; sym := OPM.ident
|
||||||
END Identifier;
|
END Identifier;
|
||||||
|
|
||||||
PROCEDURE Number;
|
PROCEDURE Number;
|
||||||
|
|
@ -128,21 +90,21 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
ELSE EXIT
|
ELSE EXIT
|
||||||
END
|
END
|
||||||
END; (* 0 <= n <= m <= i, 0 <= d <= i *)
|
END; (* 0 <= n <= m <= i, 0 <= d <= i *)
|
||||||
IF d = 0 THEN (* integer *)
|
IF d = 0 THEN (* OPM.integer *)
|
||||||
IF n = m THEN intval := 0; i := 0;
|
IF n = m THEN intval := 0; i := 0;
|
||||||
IF ch = "X" THEN (* character *) OPM.Get(ch); numtyp := char;
|
IF ch = "X" THEN (* character *) OPM.Get(ch); numtyp := OPM.char;
|
||||||
IF n <= 2 THEN
|
IF n <= 2 THEN
|
||||||
WHILE i < n DO intval := intval*10H + Ord(dig[i], TRUE); INC(i) END
|
WHILE i < n DO intval := intval*10H + Ord(dig[i], TRUE); INC(i) END
|
||||||
ELSE err(203)
|
ELSE err(203)
|
||||||
END
|
END
|
||||||
ELSIF ch = "H" THEN (* hexadecimal *) OPM.Get(ch); numtyp := integer;
|
ELSIF ch = "H" THEN (* hexadecimal *) OPM.Get(ch); numtyp := OPM.integer;
|
||||||
IF MAX(LONGINT) > 2147483647 THEN maxHdig := 16 ELSE maxHdig := 8 END;
|
IF MAX(LONGINT) > 2147483647 THEN maxHdig := 16 ELSE maxHdig := 8 END;
|
||||||
IF n <= maxHdig THEN
|
IF n <= maxHdig THEN
|
||||||
IF (n = maxHdig) & (dig[0] > "7") THEN (* prevent overflow *) intval := -1 END;
|
IF (n = maxHdig) & (dig[0] > "7") THEN (* prevent overflow *) intval := -1 END;
|
||||||
WHILE i < n DO intval := intval*10H + Ord(dig[i], TRUE); INC(i) END
|
WHILE i < n DO intval := intval*10H + Ord(dig[i], TRUE); INC(i) END
|
||||||
ELSE err(203)
|
ELSE err(203)
|
||||||
END
|
END
|
||||||
ELSE (* decimal *) numtyp := integer;
|
ELSE (* decimal *) numtyp := OPM.integer;
|
||||||
WHILE i < n DO d := Ord(dig[i], FALSE); INC(i);
|
WHILE i < n DO d := Ord(dig[i], FALSE); INC(i);
|
||||||
IF intval <= (MAX(LONGINT) - d) DIV 10 THEN intval := intval*10 + d
|
IF intval <= (MAX(LONGINT) - d) DIV 10 THEN intval := intval*10 + d
|
||||||
ELSE err(203)
|
ELSE err(203)
|
||||||
|
|
@ -169,14 +131,14 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
END
|
END
|
||||||
END;
|
END;
|
||||||
DEC(e, i-d-m); (* decimal point shift *)
|
DEC(e, i-d-m); (* decimal point shift *)
|
||||||
IF expCh = "E" THEN numtyp := real;
|
IF expCh = "E" THEN numtyp := OPM.real;
|
||||||
IF (1-OPM.MaxRExp < e) & (e <= OPM.MaxRExp) THEN
|
IF (1-OPM.MaxRExp < e) & (e <= OPM.MaxRExp) THEN
|
||||||
IF e < 0 THEN realval := SHORT(f / Ten(-e))
|
IF e < 0 THEN realval := SHORT(f / Ten(-e))
|
||||||
ELSE realval := SHORT(f * Ten(e))
|
ELSE realval := SHORT(f * Ten(e))
|
||||||
END
|
END
|
||||||
ELSE err(203)
|
ELSE err(203)
|
||||||
END
|
END
|
||||||
ELSE numtyp := longreal;
|
ELSE numtyp := OPM.longreal;
|
||||||
IF (1-OPM.MaxLExp < e) & (e <= OPM.MaxLExp) THEN
|
IF (1-OPM.MaxLExp < e) & (e <= OPM.MaxLExp) THEN
|
||||||
IF e < 0 THEN lrlval := f / Ten(-e)
|
IF e < 0 THEN lrlval := f / Ten(-e)
|
||||||
ELSE lrlval := f * Ten(e)
|
ELSE lrlval := f * Ten(e)
|
||||||
|
|
@ -209,102 +171,100 @@ MODULE OPS; (* NW, RC 6.3.89 / 18.10.92 *) (* object model 3.6.92 *)
|
||||||
BEGIN
|
BEGIN
|
||||||
OPM.errpos := OPM.curpos-1;
|
OPM.errpos := OPM.curpos-1;
|
||||||
WHILE ch <= " " DO (*ignore control characters*)
|
WHILE ch <= " " DO (*ignore control characters*)
|
||||||
IF ch = OPM.Eot THEN sym := eof; RETURN
|
IF ch = OPM.Eot THEN sym := OPM.eof; RETURN
|
||||||
ELSE OPM.Get(ch)
|
ELSE OPM.Get(ch)
|
||||||
END
|
END
|
||||||
END ;
|
END ;
|
||||||
CASE ch OF (* ch > " " *)
|
CASE ch OF (* ch > " " *)
|
||||||
| 22X, 27X : Str(s)
|
| 22X, 27X : Str(s)
|
||||||
| "#" : s := neq; OPM.Get(ch)
|
| "#" : s := OPM.neq; OPM.Get(ch)
|
||||||
| "&" : s := and; OPM.Get(ch)
|
| "&" : s := OPM.and; OPM.Get(ch)
|
||||||
| "(" : OPM.Get(ch);
|
| "(" : OPM.Get(ch);
|
||||||
IF ch = "*" THEN Comment; Get(s)
|
IF ch = "*" THEN Comment; Get(s) ELSE s := OPM.lparen END
|
||||||
ELSE s := lparen
|
| ")" : s := OPM.rparen; OPM.Get(ch)
|
||||||
END
|
| "*" : s := OPM.times; OPM.Get(ch)
|
||||||
| ")" : s := rparen; OPM.Get(ch)
|
| "+" : s := OPM.plus; OPM.Get(ch)
|
||||||
| "*" : s := times; OPM.Get(ch)
|
| "," : s := OPM.comma; OPM.Get(ch)
|
||||||
| "+" : s := plus; OPM.Get(ch)
|
| "-" : s := OPM.minus; OPM.Get(ch)
|
||||||
| "," : s := comma; OPM.Get(ch)
|
|
||||||
| "-" : s := minus; OPM.Get(ch)
|
|
||||||
| "." : OPM.Get(ch);
|
| "." : OPM.Get(ch);
|
||||||
IF ch = "." THEN OPM.Get(ch); s := upto ELSE s := period END
|
IF ch = "." THEN OPM.Get(ch); s := OPM.upto ELSE s := OPM.period END
|
||||||
| "/" : s := slash; OPM.Get(ch)
|
| "/" : s := OPM.slash; OPM.Get(ch)
|
||||||
| "0".."9": Number; s := number
|
| "0".."9": Number; s := OPM.number
|
||||||
| ":" : OPM.Get(ch);
|
| ":" : OPM.Get(ch);
|
||||||
IF ch = "=" THEN OPM.Get(ch); s := becomes ELSE s := colon END
|
IF ch = "=" THEN OPM.Get(ch); s := OPM.becomes ELSE s := OPM.colon END
|
||||||
| ";" : s := semicolon; OPM.Get(ch)
|
| ";" : s := OPM.semicolon; OPM.Get(ch)
|
||||||
| "<" : OPM.Get(ch);
|
| "<" : OPM.Get(ch);
|
||||||
IF ch = "=" THEN OPM.Get(ch); s := leq ELSE s := lss END
|
IF ch = "=" THEN OPM.Get(ch); s := OPM.leq ELSE s := OPM.lss END
|
||||||
| "=" : s := eql; OPM.Get(ch)
|
| "=" : s := OPM.eql; OPM.Get(ch)
|
||||||
| ">" : OPM.Get(ch);
|
| ">" : OPM.Get(ch);
|
||||||
IF ch = "=" THEN OPM.Get(ch); s := geq ELSE s := gtr END
|
IF ch = "=" THEN OPM.Get(ch); s := OPM.geq ELSE s := OPM.gtr END
|
||||||
| "A": Identifier(s); IF name = "ARRAY" THEN s := array END
|
| "A": Identifier(s); IF name = "ARRAY" THEN s := OPM.array END
|
||||||
| "B": Identifier(s);
|
| "B": Identifier(s);
|
||||||
IF name = "BEGIN" THEN s := begin
|
IF name = "BEGIN" THEN s := OPM.begin
|
||||||
ELSIF name = "BY" THEN s := by
|
ELSIF name = "BY" THEN s := OPM.by
|
||||||
END
|
END
|
||||||
| "C": Identifier(s);
|
| "C": Identifier(s);
|
||||||
IF name = "CASE" THEN s := case
|
IF name = "CASE" THEN s := OPM.case
|
||||||
ELSIF name = "CONST" THEN s := const
|
ELSIF name = "CONST" THEN s := OPM.const
|
||||||
END
|
END
|
||||||
| "D": Identifier(s);
|
| "D": Identifier(s);
|
||||||
IF name = "DO" THEN s := do
|
IF name = "DO" THEN s := OPM.do
|
||||||
ELSIF name = "DIV" THEN s := div
|
ELSIF name = "DIV" THEN s := OPM.div
|
||||||
END
|
END
|
||||||
| "E": Identifier(s);
|
| "E": Identifier(s);
|
||||||
IF name = "END" THEN s := end
|
IF name = "END" THEN s := OPM.end
|
||||||
ELSIF name = "ELSE" THEN s := else
|
ELSIF name = "ELSE" THEN s := OPM.else
|
||||||
ELSIF name = "ELSIF" THEN s := elsif
|
ELSIF name = "ELSIF" THEN s := OPM.elsif
|
||||||
ELSIF name = "EXIT" THEN s := exit
|
ELSIF name = "EXIT" THEN s := OPM.exit
|
||||||
END
|
END
|
||||||
| "F": Identifier(s); IF name = "FOR" THEN s := for END
|
| "F": Identifier(s); IF name = "FOR" THEN s := OPM.for END
|
||||||
| "I": Identifier(s);
|
| "I": Identifier(s);
|
||||||
IF name = "IF" THEN s := if
|
IF name = "IF" THEN s := OPM.if
|
||||||
ELSIF name = "IN" THEN s := in
|
ELSIF name = "IN" THEN s := OPM.in
|
||||||
ELSIF name = "IS" THEN s := is
|
ELSIF name = "IS" THEN s := OPM.is
|
||||||
ELSIF name = "IMPORT" THEN s := import
|
ELSIF name = "IMPORT" THEN s := OPM.import
|
||||||
END
|
END
|
||||||
| "L": Identifier(s); IF name = "LOOP" THEN s := loop END
|
| "L": Identifier(s); IF name = "LOOP" THEN s := OPM.loop END
|
||||||
| "M": Identifier(s);
|
| "M": Identifier(s);
|
||||||
IF name = "MOD" THEN s := mod
|
IF name = "MOD" THEN s := OPM.mod
|
||||||
ELSIF name = "MODULE" THEN s := module
|
ELSIF name = "MODULE" THEN s := OPM.module
|
||||||
END
|
END
|
||||||
| "N": Identifier(s); IF name = "NIL" THEN s := nil END
|
| "N": Identifier(s); IF name = "NIL" THEN s := OPM.nil END
|
||||||
| "O": Identifier(s);
|
| "O": Identifier(s);
|
||||||
IF name = "OR" THEN s := or
|
IF name = "OR" THEN s := OPM.or
|
||||||
ELSIF name = "OF" THEN s := of
|
ELSIF name = "OF" THEN s := OPM.of
|
||||||
END
|
END
|
||||||
| "P": Identifier(s);
|
| "P": Identifier(s);
|
||||||
IF name = "PROCEDURE" THEN s := procedure
|
IF name = "PROCEDURE" THEN s := OPM.procedure
|
||||||
ELSIF name = "POINTER" THEN s := pointer
|
ELSIF name = "POINTER" THEN s := OPM.pointer
|
||||||
END
|
END
|
||||||
| "R": Identifier(s);
|
| "R": Identifier(s);
|
||||||
IF name = "RECORD" THEN s := record
|
IF name = "RECORD" THEN s := OPM.record
|
||||||
ELSIF name = "REPEAT" THEN s := repeat
|
ELSIF name = "REPEAT" THEN s := OPM.repeat
|
||||||
ELSIF name = "RETURN" THEN s := return
|
ELSIF name = "RETURN" THEN s := OPM.return
|
||||||
END
|
END
|
||||||
| "T": Identifier(s);
|
| "T": Identifier(s);
|
||||||
IF name = "THEN" THEN s := then
|
IF name = "THEN" THEN s := OPM.then
|
||||||
ELSIF name = "TO" THEN s := to
|
ELSIF name = "TO" THEN s := OPM.to
|
||||||
ELSIF name = "TYPE" THEN s := type
|
ELSIF name = "TYPE" THEN s := OPM.type
|
||||||
END
|
END
|
||||||
| "U": Identifier(s); IF name = "UNTIL" THEN s := until END
|
| "U": Identifier(s); IF name = "UNTIL" THEN s := OPM.until END
|
||||||
| "V": Identifier(s); IF name = "VAR" THEN s := var END
|
| "V": Identifier(s); IF name = "VAR" THEN s := OPM.var END
|
||||||
| "W": Identifier(s);
|
| "W": Identifier(s);
|
||||||
IF name = "WHILE" THEN s := while
|
IF name = "WHILE" THEN s := OPM.while
|
||||||
ELSIF name = "WITH" THEN s := with
|
ELSIF name = "WITH" THEN s := OPM.with
|
||||||
END
|
END
|
||||||
| "G".."H", "J", "K", "Q", "S", "X".."Z": Identifier(s)
|
| "G".."H", "J", "K", "Q", "S", "X".."Z": Identifier(s)
|
||||||
| "[" : s := lbrak; OPM.Get(ch)
|
| "[" : s := OPM.lbrak; OPM.Get(ch)
|
||||||
| "]" : s := rbrak; OPM.Get(ch)
|
| "]" : s := OPM.rbrak; OPM.Get(ch)
|
||||||
| "^" : s := arrow; OPM.Get(ch)
|
| "^" : s := OPM.arrow; OPM.Get(ch)
|
||||||
| "a".."z": Identifier(s)
|
| "a".."z": Identifier(s)
|
||||||
| "{" : s := lbrace; OPM.Get(ch)
|
| "{" : s := OPM.lbrace; OPM.Get(ch)
|
||||||
| "|" : s := bar; OPM.Get(ch)
|
| "|" : s := OPM.bar; OPM.Get(ch)
|
||||||
| "}" : s := rbrace; OPM.Get(ch)
|
| "}" : s := OPM.rbrace; OPM.Get(ch)
|
||||||
| "~" : s := not; OPM.Get(ch)
|
| "~" : s := OPM.not; OPM.Get(ch)
|
||||||
| 7FX : s := upto; OPM.Get(ch)
|
| 7FX : s := OPM.upto; OPM.Get(ch)
|
||||||
ELSE s := null; OPM.Get(ch)
|
ELSE s := OPM.null; OPM.Get(ch)
|
||||||
END ;
|
END ;
|
||||||
sym := s
|
sym := s
|
||||||
END Get;
|
END Get;
|
||||||
|
|
|
||||||
1451
src/compiler/OPT.Mod
1451
src/compiler/OPT.Mod
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue