]> git.mdlowis.com Git - proto/obnc.git/commitdiff
updated documentation
authormike lowis <mike@mdlowis.com>
Mon, 12 Apr 2021 02:15:55 +0000 (22:15 -0400)
committermike lowis <mike@mdlowis.com>
Mon, 12 Apr 2021 02:15:55 +0000 (22:15 -0400)
Oberon.html

index 074807fe9c475bf2b085efc84313d43c7cf304c5..db7db8640bb39e61fd013273264a9df80217d1ad 100644 (file)
@@ -280,7 +280,7 @@ digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9".
                 </tr>
                 <tr>
                     <td class="first">/</td>
-                    <td>#</td>
+                    <td>!=</td>
                     <td>case</td>
                     <td>mod</td>
                     <td class="last">type</td>
@@ -430,7 +430,7 @@ type = qualident | ArrayType | RecordType | PointerType | ProcedureType.
         <pre>Tree = POINTER TO Node
 </pre>
 
-        <pre>Node = RECORD key: INTEGER;
+        <pre>Node = RECORD key: Int;
     left, right: Tree
 END
 </pre>
@@ -441,7 +441,7 @@ END
 END
 </pre>
 
-        <pre>Function = PROCEDURE (x: INTEGER): INTEGER
+        <pre>Function = PROCEDURE (x: Int): Int
 </pre>
 
         <h3><a name="sec6.1">6.1. Basic types</a></h3>
@@ -450,27 +450,24 @@ END
 
         <div class="dl">
             <dl>
-                <dt>BOOLEAN</dt>
-                <dd>the truth values TRUE and FALSE</dd>
+                <dt>Bool</dt>
+                <dd>the truth values true and false</dd>
 
-                <dt>CHAR</dt>
+                <dt>Char</dt>
                 <dd>the characters of a standard character set</dd>
 
-                <dt>INTEGER</dt>
+                <dt>Int</dt>
                 <dd>the integers</dd>
 
-                <dt>REAL</dt>
+                <dt>Real</dt>
                 <dd>real numbers</dd>
 
-                <dt>BYTE</dt>
+                <dt>Byte</dt>
                 <dd>the integers between 0 and 255</dd>
-
-                <dt>SET</dt>
-                <dd>the sets of integers between 0 and an implementation-dependent limit</dd>
             </dl>
         </div>
 
-        <p>The type BYTE is compatible with the type INTEGER, and vice-versa.</p>
+        <p>The type Byte is compatible with the type Int, and vice-versa.</p>
 
         <h3><a name="sec6.2">6.2. Array types</a></h3>
 
@@ -495,7 +492,7 @@ length = ConstExpression.
 
         <p>Examples of array types:</p>
 
-        <pre>ARRAY N OF INTEGER
+        <pre>ARRAY N OF Int
 </pre>
 
         <pre>ARRAY 10, 20 OF REAL
@@ -520,13 +517,13 @@ IdentList = identdef {"," identdef}.
 
         <p>Examples of record types:</p>
 
-        <pre>RECORD day, month, year: INTEGER
+        <pre>RECORD day, month, year: Int
 END
 </pre>
 
         <pre>RECORD
     name, firstname: ARRAY 32 OF CHAR;
-    age: INTEGER;
+    age: Int;
     salary: REAL
 END
 </pre>
@@ -558,7 +555,7 @@ END
 
         <p>Variables whose identifiers appear in the same list are all of the same type. Examples of variable declarations (refer to examples in <a href="https://miasap.se/obnc/oberon-report.html#sec6">Ch. 6</a>):</p>
 
-        <pre>i, j, k: INTEGER
+        <pre>i, j, k: Int
 </pre>
 
         <pre>x, y: REAL
@@ -577,7 +574,7 @@ END
 
         <pre>w: ARRAY 16 OF
     RECORD ch: CHAR;
-        count: INTEGER
+        count: Int
     END
 </pre>
 
@@ -592,7 +589,7 @@ END
 
         <p>With the exception of sets and literal constants, i.e. numbers and strings, operands are denoted by <dfn>designators</dfn>. 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 <a href="https://miasap.se/obnc/oberon-report.html#sec4">Ch. 4</a> and <a href="https://miasap.se/obnc/oberon-report.html#sec11">11</a>), and it may be followed by selectors, if the designated object is an element of a structure.</p>
 
-        <p>If <var>A</var> designates an array, then <var>A</var>[<var>E</var>] denotes that element of <var>A</var> whose index is the current value of the expression <var>E</var>. The type of <var>E</var> must be of type INTEGER. A designator of the form <var>A</var>[<var>E1</var>, <var>E2</var>, ... , <var>En</var>] stands for <var>A</var>[<var>E1</var>][<var>E2</var>] ... [<var>En</var>]. If <var>p</var> designates a pointer variable, <var>p</var>^ denotes the variable which is referenced by <var>p</var>. If <var>r</var> designates a record, then <var>r</var>.<var>f</var> denotes the field <var>f</var> of <var>r</var>. If <var>p</var> designates a pointer, <var>p</var>.<var>f</var> denotes the field <var>f</var> of the record <var>p</var>^, i.e. the dot implies dereferencing and <var>p</var>.<var>f</var> stands for <var>p</var>^.<var>f</var>.</p>
+        <p>If <var>A</var> designates an array, then <var>A</var>[<var>E</var>] denotes that element of <var>A</var> whose index is the current value of the expression <var>E</var>. The type of <var>E</var> must be of type Int. A designator of the form <var>A</var>[<var>E1</var>, <var>E2</var>, ... , <var>En</var>] stands for <var>A</var>[<var>E1</var>][<var>E2</var>] ... [<var>En</var>]. If <var>p</var> designates a pointer variable, <var>p</var>^ denotes the variable which is referenced by <var>p</var>. If <var>r</var> designates a record, then <var>r</var>.<var>f</var> denotes the field <var>f</var> of <var>r</var>. If <var>p</var> designates a pointer, <var>p</var>.<var>f</var> denotes the field <var>f</var> of the record <var>p</var>^, i.e. the dot implies dereferencing and <var>p</var>.<var>f</var> stands for <var>p</var>^.<var>f</var>.</p>
 
         <p>The <dfn>typeguard</dfn> <var>v</var>(<var>T0</var>) asserts that <var>v</var> is of type <var>T0</var> , i.e. it aborts program execution, if it is not of type <var>T0</var> . The guard is applicable, if</p>
 
@@ -614,7 +611,7 @@ ExpList = expression {"," expression}.
             <table>
                 <tbody><tr>
                     <td class="first">i</td>
-                    <td class="last">(INTEGER)</td>
+                    <td class="last">(Int)</td>
                 </tr>
                 <tr>
                     <td class="first">a[i]</td>
@@ -626,7 +623,7 @@ ExpList = expression {"," expression}.
                 </tr>
                 <tr>
                     <td class="first">t.key</td>
-                    <td class="last">(INTEGER)</td>
+                    <td class="last">(Int)</td>
                 </tr>
                 <tr>
                     <td class="first">t.left.right</td>
@@ -643,20 +640,16 @@ ExpList = expression {"," expression}.
 
         <p>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, <var>x</var> − <var>y</var> − <var>z</var> stands for (<var>x</var> − <var>y</var>) − <var>z</var>.</p>
         <pre>expression = SimpleExpression [relation SimpleExpression].
-relation = "=" | "#" | "&lt;" | "&lt;=" | "&gt;" | "&gt;=" | IN | IS.
+relation = "=" | "!=" | "&lt;" | "&lt;=" | "&gt;" | "&gt;=" | IS.
 SimpleExpression = ["+"|"-"] term {AddOperator term}.
 AddOperator = "+" | "-" | OR.
 term = factor {MulOperator factor}.
 MulOperator = "*" | "/" | DIV | MOD | "&amp;" .
 factor = number | string | NIL | TRUE | FALSE |
-    set | designator [ActualParameters] | "(" expression ")" | "~" factor.
-set = "{" [element {"," element}] "}".
-element = expression [".." expression].
+    designator [ActualParameters] | "(" expression ")" | "~" factor.
 ActualParameters = "(" [ExpList] ")" .
 </pre>
 
-        <p>The set {<var>m</var> .. <var>n</var>} denotes {<var>m</var>, <var>m</var>+1, … , <var>n</var>-1, <var>n</var>}, and if <var>m</var> &gt; <var>n</var>, 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.</p>
-
         <h4><a name="sec8.2.1">8.2.1. Logical operators</a></h4>
 
         <div class="table">
@@ -744,35 +737,6 @@ ActualParameters = "(" [ExpList] ")" .
         <pre><var>x</var> = <var>q</var>*<var>y</var> + <var>r</var>       0 &lt;= <var>r</var> &lt; <var>y</var>
 </pre>
 
-        <h4><a name="sec8.2.3">8.2.3. Set operators</a></h4>
-
-        <div class="table">
-            <table class="header">
-                <tbody><tr>
-                    <th class="first">symbol</th>
-                    <th class="last">result</th>
-                </tr>
-                <tr class="second">
-                    <td class="first">+</td>
-                    <td class="last">union</td>
-                </tr>
-                <tr>
-                    <td class="first">−</td>
-                    <td class="last">difference</td>
-                </tr>
-                <tr>
-                    <td class="first">*</td>
-                    <td class="last">intersection</td>
-                </tr>
-                <tr>
-                    <td class="first">/</td>
-                    <td class="last"> symmetric set difference</td>
-                </tr>
-            </tbody></table>
-        </div>
-
-        <p>When used with a single operand of type SET, the minus sign denotes the set complement.</p>
-
         <h4><a name="sec8.2.4">8.2.4. Relations</a></h4>
 
         <div class="table">
@@ -786,7 +750,7 @@ ActualParameters = "(" [ExpList] ")" .
                     <td class="last">equal</td>
                 </tr>
                 <tr>
-                    <td class="first">#</td>
+                    <td class="first">!=</td>
                     <td class="last">unequal</td>
                 </tr>
                 <tr>
@@ -805,10 +769,6 @@ ActualParameters = "(" [ExpList] ")" .
                     <td class="first">&gt;=</td>
                     <td class="last">greater or equal</td>
                 </tr>
-                <tr>
-                    <td class="first">IN</td>
-                    <td class="last">set membership</td>
-                </tr>
                 <tr>
                     <td class="first">IS</td>
                     <td class="last">type test</td>
@@ -818,8 +778,6 @@ ActualParameters = "(" [ExpList] ")" .
 
         <p>Relations are Boolean. The ordering relations &lt;, &lt;=, &gt;, &gt;= 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.</p>
 
-        <p><var>x</var> IN <var>s</var> stands for “<var>x</var> is an element of <var>s</var>”. <var>x</var> must be of type INTEGER, and <var>s</var> of type SET.</p>
-
         <p><var>v</var> IS <var>T</var> stands for “<var>v</var> is of type <var>T</var>” and is called a <dfn>type test</dfn>. It is applicable, if</p>
 
         <ol>
@@ -835,11 +793,11 @@ ActualParameters = "(" [ExpList] ")" .
             <table>
                 <tbody><tr>
                     <td class="first">1987</td>
-                    <td class="last">(INTEGER)</td>
+                    <td class="last">(Int)</td>
                 </tr>
                 <tr>
                     <td class="first">i DIV 3</td>
-                    <td class="last">(INTEGER)</td>
+                    <td class="last">(Int)</td>
                 </tr>
                 <tr>
                     <td class="first">~p OR q</td>
@@ -847,11 +805,7 @@ ActualParameters = "(" [ExpList] ")" .
                 </tr>
                 <tr>
                     <td class="first">(i+j) * (i-j)</td>
-                    <td class="last">(INTEGER)</td>
-                </tr>
-                <tr>
-                    <td class="first">s - {8, 9, 13}</td>
-                    <td class="last">(SET)</td>
+                    <td class="last">(Int)</td>
                 </tr>
                 <tr>
                     <td class="first">a[i+j] * a[i-j]</td>
@@ -865,10 +819,6 @@ ActualParameters = "(" [ExpList] ")" .
                     <td class="first">t.key = 0</td>
                     <td class="last">(BOOLEAN)</td>
                 </tr>
-                <tr>
-                    <td class="first">k IN {i .. j-1}</td>
-                    <td class="last">(BOOLEAN)</td>
-                </tr>
                 <tr>
                     <td class="first">t IS CenterNode</td>
                     <td class="last">(BOOLEAN)</td>
@@ -952,10 +902,6 @@ ActualParameters = "(" [ExpList] ")" .
                     <td class="first">WriteInt(2*j + 1, 6)</td>
                     <td class="last"></td>
                 </tr>
-                <tr>
-                    <td class="first">INC(w[k].count)</td>
-                    <td class="last"></td>
-                </tr>
             </tbody></table>
         </div>
 
@@ -986,7 +932,7 @@ END
 
         <h3><a name="sec9.5">9.5. Case statements</a></h3>
 
-        <p>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.</p>
+        <p>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.</p>
 
         <pre>CaseStatement = CASE expression OF case {"|" case} END.
 case = [CaseLabelList ":" StatementSequence].
@@ -1010,8 +956,8 @@ case labels must be extensions of <var>T</var>, and in the statements <var>Si</v
 
         <p>Example:</p>
 
-        <pre>TYPE R = RECORD a: INTEGER END;
-    R0 = RECORD (R) b: INTEGER END;
+        <pre>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 &lt;= end DO S; v := v + inc END
 WHILE v &gt;= end DO S; v := v + inc END
 </pre>
 
-        <p>The types of <var>v</var>, <var>beg</var> and <var>end</var> must be INTEGER, and <var>inc</var> must be an integer (constant expression). If the step is not specified, it is assumed to be 1.</p>
+        <p>The types of <var>v</var>, <var>beg</var> and <var>end</var> must be Int, and <var>inc</var> must be an integer (constant expression). If the step is not specified, it is assumed to be 1.</p>
 
         <h2><a name="sec10">10. Procedure declarations</a></h2>
 
@@ -1139,8 +1085,8 @@ FormalType = {ARRAY OF} qualident.
 
         <p>Examples of procedure declarations:</p>
 
-        <pre>PROCEDURE ReadInt(VAR x: INTEGER);
-    VAR i: INTEGER; ch: CHAR;
+        <pre>PROCEDURE ReadInt(VAR x: Int);
+    VAR i: Int; ch: CHAR;
 BEGIN i := 0; Read(ch);
     WHILE ("0" &lt;= ch) &amp; (ch &lt;= "9") DO
         i := 10*i + (ORD(ch) - ORD("0")); Read(ch)
@@ -1149,17 +1095,17 @@ BEGIN i := 0; Read(ch);
 END ReadInt
 </pre>
 
-        <pre>PROCEDURE WriteInt(x: INTEGER); (* 0 &lt;= x &lt; 10^5 *)
-    VAR i: INTEGER;
-    buf: ARRAY 5 OF INTEGER;
+        <pre>PROCEDURE WriteInt(x: Int); (* 0 &lt;= x &lt; 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
 </pre>
 
-        <pre>PROCEDURE log2(x: INTEGER): INTEGER;
-    VAR y: INTEGER; (*assume x&gt;0*)
+        <pre>PROCEDURE log2(x: Int): Int;
+    VAR y: Int; (*assume x&gt;0*)
 BEGIN y := 0;
     WHILE x &gt; 1 DO x := x DIV 2; INC(y) END;
     RETURN y
@@ -1181,41 +1127,17 @@ END log2
                     <th class="last">Function</th>
                 </tr>
                 <tr class="second">
-                    <td class="first">ABS(x)</td>
+                    <td class="first">Abs(x)</td>
                     <td>x: numeric type</td>
                     <td>type of x</td>
                     <td class="last">absolute value</td>
                 </tr>
                 <tr>
-                    <td class="first">ODD(x)</td>
-                    <td>x: INTEGER</td>
-                    <td>BOOLEAN</td>
-                    <td class="last">x MOD 2 = 1</td>
-                </tr>
-                <tr>
-                    <td class="first">LEN(v)</td>
+                    <td class="first">Length(v)</td>
                     <td> v: array</td>
-                    <td>INTEGER</td>
+                    <td>Int</td>
                     <td class="last">the length of v</td>
                 </tr>
-                <tr>
-                    <td class="first">LSL(x, n)</td>
-                    <td>x, n: INTEGER</td>
-                    <td>INTEGER</td>
-                    <td class="last">logical shift left, x * 2<sup>n</sup></td>
-                </tr>
-                <tr>
-                    <td class="first">ASR(x, n)</td>
-                    <td>x, n: INTEGER</td>
-                    <td>INTEGER</td>
-                    <td class="last">signed shift right, x DIV 2<sup>n</sup></td>
-                </tr>
-                <tr>
-                    <td class="first">ROR(x, n)</td>
-                    <td>x, n: INTEGER</td>
-                    <td>INTEGER</td>
-                    <td class="last">x rotated right by n bits</td>
-                </tr>
             </tbody></table>
         </div>
 
@@ -1243,7 +1165,7 @@ END log2
                 </tr>
                 <tr>
                     <td class="first">AsInt(x)</td>
-                    <td>Char, Bool, Set</td>
+                    <td>Char, Bool</td>
                     <td>Int</td>
                     <td class="last">ordinal number of x</td>
                 </tr>
@@ -1285,16 +1207,6 @@ END log2
                     <td>Int</td>
                     <td class="last">v := v - n</td>
                 </tr>
-                <tr class="group-first">
-                    <td class="first">Include(v, x)</td>
-                    <td>v: Set; x: Int</td>
-                    <td class="last">v := v + {x}</td>
-                </tr>
-                <tr>
-                    <td class="first">Exclude(v, x)</td>
-                    <td>v: Set; x: Int</td>
-                    <td class="last">v := v - {x}</td>
-                </tr>
                 <tr class="group-first">
                     <td class="first">New(v)</td>
                     <td>pointer type</td>
@@ -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 &lt; 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].
 </pre>
 
         <pre>expression = SimpleExpression [relation SimpleExpression].
-relation = "=" | "#" | "&lt;" | "&lt;=" | "&gt;" | "&gt;=" | IN | IS.
+relation = "=" | "!=" | "&lt;" | "&lt;=" | "&gt;" | "&gt;=" | IS.
 SimpleExpression = ["+" | "-"] term {AddOperator term}.
 AddOperator = "+" | "-" | OR.
 term = factor {MulOperator factor}.
 MulOperator = "*" | "/" | DIV | MOD | "&amp;".
 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] ")" .
 </pre>