From: mike lowis Date: Mon, 12 Apr 2021 02:15:55 +0000 (-0400) Subject: updated documentation X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=561507d6d84d9bad9bcd82396964e57e34049754;p=proto%2Fobnc.git updated documentation --- diff --git a/Oberon.html b/Oberon.html index 074807f..db7db86 100644 --- a/Oberon.html +++ b/Oberon.html @@ -280,7 +280,7 @@ digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9". / - # + != case mod type @@ -430,7 +430,7 @@ type = qualident | ArrayType | RecordType | PointerType | ProcedureType.
Tree = POINTER TO Node
 
-
Node = RECORD key: INTEGER;
+        
Node = RECORD key: Int;
     left, right: Tree
 END
 
@@ -441,7 +441,7 @@ END END
-
Function = PROCEDURE (x: INTEGER): INTEGER
+        
Function = PROCEDURE (x: Int): Int
 

6.1. Basic types

@@ -450,27 +450,24 @@ END
-
BOOLEAN
-
the truth values TRUE and FALSE
+
Bool
+
the truth values true and false
-
CHAR
+
Char
the characters of a standard character set
-
INTEGER
+
Int
the integers
-
REAL
+
Real
real numbers
-
BYTE
+
Byte
the integers between 0 and 255
- -
SET
-
the sets of integers between 0 and an implementation-dependent limit
-

The type BYTE is compatible with the type INTEGER, and vice-versa.

+

The type Byte is compatible with the type Int, and vice-versa.

6.2. Array types

@@ -495,7 +492,7 @@ length = ConstExpression.

Examples of array types:

-
ARRAY N OF INTEGER
+        
ARRAY N OF Int
 
ARRAY 10, 20 OF REAL
@@ -520,13 +517,13 @@ IdentList = identdef {"," identdef}.
 
         

Examples of record types:

-
RECORD day, month, year: INTEGER
+        
RECORD day, month, year: Int
 END
 
RECORD
     name, firstname: ARRAY 32 OF CHAR;
-    age: INTEGER;
+    age: Int;
     salary: REAL
 END
 
@@ -558,7 +555,7 @@ END

Variables whose identifiers appear in the same list are all of the same type. Examples of variable declarations (refer to examples in Ch. 6):

-
i, j, k: INTEGER
+        
i, j, k: Int
 
x, y: REAL
@@ -577,7 +574,7 @@ END
 
         
w: ARRAY 16 OF
     RECORD ch: CHAR;
-        count: INTEGER
+        count: Int
     END
 
@@ -592,7 +589,7 @@ END

With the exception of sets and literal constants, i.e. numbers and strings, operands are denoted by designators. A designator consists of an identifier referring to the constant, variable, or procedure to be designated. This identifier may possibly be qualified by module identifiers (see Ch. 4 and 11), and it may be followed by selectors, if the designated object is an element of a structure.

-

If A designates an array, then A[E] denotes that element of A whose index is the current value of the expression E. The type of E must be of type INTEGER. A designator of the form A[E1, E2, ... , En] stands for A[E1][E2] ... [En]. If p designates a pointer variable, p^ denotes the variable which is referenced by p. If r designates a record, then r.f denotes the field f of r. If p designates a pointer, p.f denotes the field f of the record p^, i.e. the dot implies dereferencing and p.f stands for p^.f.

+

If A designates an array, then A[E] denotes that element of A whose index is the current value of the expression E. The type of E must be of type Int. A designator of the form A[E1, E2, ... , En] stands for A[E1][E2] ... [En]. If p designates a pointer variable, p^ denotes the variable which is referenced by p. If r designates a record, then r.f denotes the field f of r. If p designates a pointer, p.f denotes the field f of the record p^, i.e. the dot implies dereferencing and p.f stands for p^.f.

The typeguard v(T0) asserts that v is of type T0 , i.e. it aborts program execution, if it is not of type T0 . The guard is applicable, if

@@ -614,7 +611,7 @@ ExpList = expression {"," expression}. - + @@ -626,7 +623,7 @@ ExpList = expression {"," expression}. - + @@ -643,20 +640,16 @@ ExpList = expression {"," expression}.

The syntax of expressions distinguishes between four classes of operators with different precedences (binding strengths). The operator ~ has the highest precedence, followed by multiplication operators, addition operators, and relations. Operators of the same precedence associate from left to right. For example, x − y − z stands for (x − y) − z.

expression = SimpleExpression [relation SimpleExpression].
-relation = "=" | "#" | "<" | "<=" | ">" | ">=" | IN | IS.
+relation = "=" | "!=" | "<" | "<=" | ">" | ">=" | IS.
 SimpleExpression = ["+"|"-"] term {AddOperator term}.
 AddOperator = "+" | "-" | OR.
 term = factor {MulOperator factor}.
 MulOperator = "*" | "/" | DIV | MOD | "&" .
 factor = number | string | NIL | TRUE | FALSE |
-    set | designator [ActualParameters] | "(" expression ")" | "~" factor.
-set = "{" [element {"," element}] "}".
-element = expression [".." expression].
+    designator [ActualParameters] | "(" expression ")" | "~" factor.
 ActualParameters = "(" [ExpList] ")" .
 
-

The set {m .. n} denotes {m, m+1, … , n-1, n}, and if m > n, the empty set. The available operators are listed in the following tables. In some instances, several different operations are designated by the same operator symbol. In these cases, the actual operation is identified by the type of the operands.

-

8.2.1. Logical operators

@@ -744,35 +737,6 @@ ActualParameters = "(" [ExpList] ")" .
x = q*y + r       0 <= r < y
 
-

8.2.3. Set operators

- -
-
i(INTEGER)(Int)
a[i]
t.key(INTEGER)(Int)
t.left.right
- - - - - - - - - - - - - - - - - - - - -
symbolresult
+union
−difference
*intersection
/ symmetric set difference
- - -

When used with a single operand of type SET, the minus sign denotes the set complement.

-

8.2.4. Relations

@@ -786,7 +750,7 @@ ActualParameters = "(" [ExpList] ")" . equal - # + != unequal @@ -805,10 +769,6 @@ ActualParameters = "(" [ExpList] ")" . >= greater or equal - - IN - set membership - IS type test @@ -818,8 +778,6 @@ ActualParameters = "(" [ExpList] ")" .

Relations are Boolean. The ordering relations <, <=, >, >= apply to the numeric types, CHAR, and character arrays. The relations = and # also apply to the types BOOLEAN, SET, and to pointer and procedure types.

-

x IN s stands for “x is an element of s”. x must be of type INTEGER, and s of type SET.

-

v IS T stands for “v is of type T” and is called a type test. It is applicable, if

    @@ -835,11 +793,11 @@ ActualParameters = "(" [ExpList] ")" . - + - + @@ -847,11 +805,7 @@ ActualParameters = "(" [ExpList] ")" . - - - - - + @@ -865,10 +819,6 @@ ActualParameters = "(" [ExpList] ")" . - - - - @@ -952,10 +902,6 @@ ActualParameters = "(" [ExpList] ")" . - - - -
    1987(INTEGER)(Int)
    i DIV 3(INTEGER)(Int)
    ~p OR q
    (i+j) * (i-j)(INTEGER)
    s - {8, 9, 13}(SET)(Int)
    a[i+j] * a[i-j]t.key = 0 (BOOLEAN)
    k IN {i .. j-1}(BOOLEAN)
    t IS CenterNode (BOOLEAN)WriteInt(2*j + 1, 6)
    INC(w[k].count)
@@ -986,7 +932,7 @@ END

9.5. Case statements

-

Case statements specify the selection and execution of a statement sequence according to the value of an expression. First the case expression is evaluated, then the statement sequence is executed whose case label list contains the obtained value. If the case expression is of type INTEGER or CHAR, all labels must be integers or single-character strings, respectively.

+

Case statements specify the selection and execution of a statement sequence according to the value of an expression. First the case expression is evaluated, then the statement sequence is executed whose case label list contains the obtained value. If the case expression is of type Int or CHAR, all labels must be integers or single-character strings, respectively.

CaseStatement = CASE expression OF case {"|" case} END.
 case = [CaseLabelList ":" StatementSequence].
@@ -1010,8 +956,8 @@ case labels must be extensions of T, and in the statements SiExample:

-
TYPE R = RECORD a: INTEGER END;
-    R0 = RECORD (R) b: INTEGER END;
+        
TYPE R = RECORD a: Int END;
+    R0 = RECORD (R) b: Int END;
     R1 = RECORD (R) b: REAL END;
     R2 = RECORD (R) b: SET END;
     P = POINTER TO R;
@@ -1086,7 +1032,7 @@ WHILE v <= end DO S; v := v + inc END
 WHILE v >= end DO S; v := v + inc END
 
-

The types of v, beg and end must be INTEGER, and inc must be an integer (constant expression). If the step is not specified, it is assumed to be 1.

+

The types of v, beg and end must be Int, and inc must be an integer (constant expression). If the step is not specified, it is assumed to be 1.

10. Procedure declarations

@@ -1139,8 +1085,8 @@ FormalType = {ARRAY OF} qualident.

Examples of procedure declarations:

-
PROCEDURE ReadInt(VAR x: INTEGER);
-    VAR i: INTEGER; ch: CHAR;
+        
PROCEDURE ReadInt(VAR x: Int);
+    VAR i: Int; ch: CHAR;
 BEGIN i := 0; Read(ch);
     WHILE ("0" <= ch) & (ch <= "9") DO
         i := 10*i + (ORD(ch) - ORD("0")); Read(ch)
@@ -1149,17 +1095,17 @@ BEGIN i := 0; Read(ch);
 END ReadInt
 
-
PROCEDURE WriteInt(x: INTEGER); (* 0 <= x < 10^5 *)
-    VAR i: INTEGER;
-    buf: ARRAY 5 OF INTEGER;
+        
PROCEDURE WriteInt(x: Int); (* 0 <= x < 10^5 *)
+    VAR i: Int;
+    buf: ARRAY 5 OF Int;
 BEGIN i := 0;
     REPEAT buf[i] := x MOD 10; x := x DIV 10; INC(i) UNTIL x = 0;
     REPEAT DEC(i); Write(CHR(buf[i] + ORD("0"))) UNTIL i = 0
 END WriteInt
 
-
PROCEDURE log2(x: INTEGER): INTEGER;
-    VAR y: INTEGER; (*assume x>0*)
+        
PROCEDURE log2(x: Int): Int;
+    VAR y: Int; (*assume x>0*)
 BEGIN y := 0;
     WHILE x > 1 DO x := x DIV 2; INC(y) END;
     RETURN y
@@ -1181,41 +1127,17 @@ END log2
                     Function
                 
                 
-                    ABS(x)
+                    Abs(x)
                     x: numeric type
                     type of x
                     absolute value
                 
                 
-                    ODD(x)
-                    x: INTEGER
-                    BOOLEAN
-                    x MOD 2 = 1
-                
-                
-                    LEN(v)
+                    Length(v)
                      v: array
-                    INTEGER
+                    Int
                     the length of v
                 
-                
-                    LSL(x, n)
-                    x, n: INTEGER
-                    INTEGER
-                    logical shift left, x * 2n
-                
-                
-                    ASR(x, n)
-                    x, n: INTEGER
-                    INTEGER
-                    signed shift right, x DIV 2n
-                
-                
-                    ROR(x, n)
-                    x, n: INTEGER
-                    INTEGER
-                    x rotated right by n bits
-                
             
         
 
@@ -1243,7 +1165,7 @@ END log2
                 
                 
                     AsInt(x)
-                    Char, Bool, Set
+                    Char, Bool
                     Int
                     ordinal number of x
                 
@@ -1285,16 +1207,6 @@ END log2
                     Int
                     v := v - n
                 
-                
-                    Include(v, x)
-                    v: Set; x: Int
-                    v := v + {x}
-                
-                
-                    Exclude(v, x)
-                    v: Set; x: Int
-                    v := v - {x}
-                
                 
                     New(v)
                     pointer type
@@ -1339,8 +1251,8 @@ Import = ident [":=" ident].
     BEGIN Texts.Write(W, ch)
     END;
 
-    PROCEDURE WriteInt*(x, n: INTEGER);
-        VAR i: INTEGER; a: ARRAY 16 OF CHAR;
+    PROCEDURE WriteInt*(x, n: Int);
+        VAR i: Int; a: ARRAY 16 OF CHAR;
     BEGIN i := 0;
         IF x < 0 THEN Texts.Write(W, "-"); x := -x END ;
         REPEAT a[i] := CHR(x MOD 10 + ORD("0")); x := x DIV 10; INC(i) UNTIL x = 0;
@@ -1398,17 +1310,15 @@ ProcedureType = PROCEDURE [FormalParameters].
 
expression = SimpleExpression [relation SimpleExpression].
-relation = "=" | "#" | "<" | "<=" | ">" | ">=" | IN | IS.
+relation = "=" | "!=" | "<" | "<=" | ">" | ">=" | IS.
 SimpleExpression = ["+" | "-"] term {AddOperator term}.
 AddOperator = "+" | "-" | OR.
 term = factor {MulOperator factor}.
 MulOperator = "*" | "/" | DIV | MOD | "&".
 factor = number | string | NIL | TRUE | FALSE |
-    set | designator [ActualParameters] | "(" expression ")" | "~" factor.
+    designator [ActualParameters] | "(" expression ")" | "~" factor.
 designator = qualident {selector}.
 selector = "." ident | "[" ExpList "]" | "^" | "(" qualident ")".
-set = "{" [element {"," element}] "}".
-element = expression [".." expression].
 ExpList = expression {"," expression}.
 ActualParameters = "(" [ExpList] ")" .