]> git.mdlowis.com Git - proto/obnc.git/commitdiff
changed LEN to Length
authormike lowis <mike@mdlowis.com>
Fri, 9 Apr 2021 20:37:06 +0000 (16:37 -0400)
committermike lowis <mike@mdlowis.com>
Fri, 9 Apr 2021 20:37:06 +0000 (16:37 -0400)
lib/obnc/FilesTest.obn
lib/obnc/Strings.obn
lib/obnc/StringsTest.obn
src/.Oberon.y.swp [deleted file]
src/Oberon.y
src/Table.c
src/y.tab.c
tests/obnc/passing/T4Expressions.obn
tests/obnc/passing/T6ProcedureDeclarations.obn

index 9b37be0d5706d6849987821a34c88786e8b3d0cf..2388e2c0750d85337ff69d4ed17c4cdcc1f53edd 100644 (file)
@@ -395,33 +395,33 @@ module FilesTest;
                        buf: array 4 of Byte;
                        i: Int;
        begin
-               for i := 0 to LEN(buf) - 1 do buf[i] := i + 1 end;
+               for i := 0 to Length(buf) - 1 do buf[i] := i + 1 end;
 
                f := Files.New("ReadWriteBytesTest");
                Assert(f # nil);
 
                Files.SetPos(r, f, 0);
-               Files.WriteBytes(r, buf, LEN(buf));
-               Files.WriteBytes(r, buf, LEN(buf));
+               Files.WriteBytes(r, buf, Length(buf));
+               Files.WriteBytes(r, buf, Length(buf));
                Files.Close(f);
 
-               for i := 0 to LEN(buf) - 1 do buf[i] := 0 end;
+               for i := 0 to Length(buf) - 1 do buf[i] := 0 end;
 
                Files.SetPos(r, f, 0);
 
-               Files.ReadBytes(r, buf, LEN(buf));
+               Files.ReadBytes(r, buf, Length(buf));
                Assert(~r.eof);
-               for i := 0 to LEN(buf) - 1 do
+               for i := 0 to Length(buf) - 1 do
                        Assert(buf[i] = i + 1)
                end;
 
-               Files.ReadBytes(r, buf, LEN(buf));
+               Files.ReadBytes(r, buf, Length(buf));
                Assert(~r.eof);
-               for i := 0 to LEN(buf) - 1 do
+               for i := 0 to Length(buf) - 1 do
                        Assert(buf[i] = i + 1)
                end;
 
-               Files.ReadBytes(r, buf, LEN(buf));
+               Files.ReadBytes(r, buf, Length(buf));
                Assert(r.eof)
        end TestReadWriteBytes;
 
index ba95fd624a247a61096a665a5a800ad1efadf43e..9ca30dca26f81c51d43c224f5a7b611a9910ed19 100644 (file)
@@ -9,8 +9,8 @@ module Strings;
 
 Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Compiler Developers". All character arrays are assumed to contain 0X as a terminator and positions start at 0.*)
 
-       procedure Length*(s: array of Char): Int;
-(**Length(s) returns the number of characters in s up to and excluding the first 0X.*)
+       procedure Len*(s: array of Char): Int;
+(**Len(s) returns the number of characters in s up to and excluding the first 0X.*)
                var i: Int;
        begin
                i := 0;
@@ -18,7 +18,7 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
                        INC(i)
                end
        return i
-       end Length;
+       end Len;
 
 
        procedure Min(a, b: Int): Int;
@@ -28,16 +28,16 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
 
 
        procedure Insert*(source: array of Char; pos: Int; var dest: array of Char);
-(**Insert(src, pos, dst) inserts the string src into the string dst at position pos (0 <= pos <= Length(dst)). If pos = Length(dst), src is appended to dst. If the size of dst is not large enough to hold the result of the operation, the result is truncated so that dst is always terminated with a 0X.*)
+(**Insert(src, pos, dst) inserts the string src into the string dst at position pos (0 <= pos <= Len(dst)). If pos = Len(dst), src is appended to dst. If the size of dst is not large enough to hold the result of the operation, the result is truncated so that dst is always terminated with a 0X.*)
                var sourceLength, destLength, newLength: Int;
                        i, lim: Int;
        begin
-               destLength := Length(dest);
+               destLength := Len(dest);
                Assert(pos >= 0);
                Assert(pos <= destLength);
 
-               sourceLength := Length(source);
-               newLength := Min(destLength + sourceLength, LEN(dest) - 1);
+               sourceLength := Len(source);
+               newLength := Min(destLength + sourceLength, Length(dest) - 1);
 
                (*make room for source in dest*)
                dest[newLength] := 0X;
@@ -54,12 +54,12 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
 
 
        procedure Append*(extra: array of Char; var dest: array of Char);
-(**Append(s, dst) has the same effect as Insert(s, Length(dst), dst).*)
+(**Append(s, dst) has the same effect as Insert(s, Len(dst), dst).*)
                var destLength, newLength: Int;
                        i: Int;
        begin
-               destLength := Length(dest);
-               newLength := Min(destLength + Length(extra), LEN(dest) - 1);
+               destLength := Len(dest);
+               newLength := Min(destLength + Len(extra), Length(dest) - 1);
 
                for i := destLength to newLength - 1 do
                        dest[i] := extra[i - destLength]
@@ -69,10 +69,10 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
 
 
        procedure Delete*(var s: array of Char; pos, n: Int);
-(**Delete(s, pos, n) deletes n characters from s starting at position pos (0 <= pos <= Length(s)). If n > Length(s) - pos, the new length of s is pos.*)
+(**Delete(s, pos, n) deletes n characters from s starting at position pos (0 <= pos <= Len(s)). If n > Len(s) - pos, the new length of s is pos.*)
                var length, n1, i: Int;
        begin
-               length := Length(s);
+               length := Len(s);
                Assert(pos >= 0);
                Assert(pos <= length);
                Assert(n >= 0);
@@ -85,14 +85,14 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
 
 
        procedure Replace*(source: array of Char; pos: Int; var dest: array of Char);
-(**Replace(src, pos, dst) has the same effect as Delete(dst, pos, Length(src)) followed by an Insert(src, pos, dst).*)
+(**Replace(src, pos, dst) has the same effect as Delete(dst, pos, Len(src)) followed by an Insert(src, pos, dst).*)
                var destLength, n, i: Int;
        begin
-               destLength := Length(dest);
+               destLength := Len(dest);
                Assert(pos >= 0);
                Assert(pos <= destLength);
 
-               n := Min(Length(source), LEN(dest) - 1 - pos); (*actual number of characters to replace*)
+               n := Min(Len(source), Length(dest) - 1 - pos); (*actual number of characters to replace*)
 
                (*replace characters*)
                for i := 0 to n - 1 do
@@ -106,14 +106,14 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
 
 
        procedure Extract*(source: array of Char; pos, n: Int; var dest: array of Char);
-(**Extract(src, pos, n, dst) extracts a substring dst with n characters from position pos (0 <= pos <= Length(src)) in src. If n > Length(src) - pos, dst is only the part of src from pos to the end of src, i.e. Length(src) - 1. If the size of dst is not large enough to hold the result of the operation, the result is truncated so that dst is always terminated with a 0X.*)
+(**Extract(src, pos, n, dst) extracts a substring dst with n characters from position pos (0 <= pos <= Len(src)) in src. If n > Len(src) - pos, dst is only the part of src from pos to the end of src, i.e. Len(src) - 1. If the size of dst is not large enough to hold the result of the operation, the result is truncated so that dst is always terminated with a 0X.*)
                var sourceLength, n1, i: Int;
        begin
-               sourceLength := Length(source);
+               sourceLength := Len(source);
                Assert(pos >= 0);
                Assert(pos <= sourceLength);
 
-               n1 := Min(n, Min(sourceLength - pos, LEN(dest) - 1)); (*actual number of characters to extract*)
+               n1 := Min(n, Min(sourceLength - pos, Length(dest) - 1)); (*actual number of characters to extract*)
                for i := 0 to n1 - 1 do
                        dest[i] := source[pos + i]
                end;
@@ -122,11 +122,11 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
 
 
        procedure Pos*(pattern, s: array of Char; pos: Int): Int;
-(**Pos(pat, s, pos) returns the position of the first occurrence of pat in s. Searching starts at position pos (0 <= pos <= Length(s)). If pat is not found, -1 is returned.*)
+(**Pos(pat, s, pos) returns the position of the first occurrence of pat in s. Searching starts at position pos (0 <= pos <= Len(s)). If pat is not found, -1 is returned.*)
                var idxs, idxp, result: Int;
        begin
                Assert(pos >= 0);
-               Assert(pos < LEN(s));
+               Assert(pos < Length(s));
                
                idxs := pos - 1;
                repeat
@@ -143,7 +143,7 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co
                        result := -1
                end;
 
-               Assert((result = -1) or (result >= 0) & (result + idxp < LEN(s)))
+               Assert((result = -1) or (result >= 0) & (result + idxp < Length(s)))
        return result
        end Pos;
 
index f3933fadc3fc1b2072478f12483963172594d3ba..8199b70a8822d8974e66ab2f60c8fa881937ebf6 100644 (file)
@@ -25,13 +25,13 @@ module StringsTest;
 
 begin
        (*test Length*)
-       Assert(Strings.Length("") = 0);
+       Assert(Strings.Len("") = 0);
        shortStr := "";
-       Assert(Strings.Length(shortStr) = 0);
+       Assert(Strings.Len(shortStr) = 0);
        shortStr := 22X;
-       Assert(Strings.Length(shortStr) = 1);
+       Assert(Strings.Len(shortStr) = 1);
        shortStr := "123";
-       Assert(Strings.Length(shortStr) = 3);
+       Assert(Strings.Len(shortStr) = 3);
 
        (*test Insert*)
        s := "cde";
@@ -47,9 +47,9 @@ begin
        Strings.Insert("bcd", 1, shortStr);
        Assert(shortStr = "abc");
        s := "foo bar";
-       Strings.Insert(" baz", Strings.Length(s), s);
+       Strings.Insert(" baz", Strings.Len(s), s);
        Assert(s = "foo bar baz");
-       Strings.Insert(" qux qux qux qux qux", Strings.Length(s), s);
+       Strings.Insert(" qux qux qux qux qux", Strings.Len(s), s);
        Assert(s = "foo bar baz q");
 
        (*test Append*)
diff --git a/src/.Oberon.y.swp b/src/.Oberon.y.swp
deleted file mode 100644 (file)
index 0627e87..0000000
Binary files a/src/.Oberon.y.swp and /dev/null differ
index a8290f46e84639dffb977845c72cc41466acbd5b..76f82a682855f37480f34615435ef0fd7318d994 100644 (file)
@@ -3598,8 +3598,8 @@ static Trees_Node PredeclaredProcedureAST(const char procName[], Trees_Node expL
                {"FLT", TREES_FLT_PROC},
                {"INC", TREES_INC_PROC},
                {"INCL", TREES_INCL_PROC},
-               {"LEN", TREES_LEN_PROC},
                {"LSL", TREES_LSL_PROC},
+               {"Length", TREES_LEN_PROC},
                {"New", TREES_NEW_PROC},
                {"ORD", TREES_ORD_PROC},
                {"PACK", TREES_PACK_PROC},
index f375689303875c6b25106151d89743b89aa747d5..24145ecd0e1ac983f68db5fee95f88a9e0dbb97a 100644 (file)
@@ -93,8 +93,8 @@ void Table_Init(void)
                {"INC", TREES_PROCEDURE_KIND, TREES_INC_PROC},
                {"INCL", TREES_PROCEDURE_KIND, TREES_INCL_PROC},
                {"Int", TREES_TYPE_KIND, TREES_INTEGER_TYPE},
-               {"LEN", TREES_PROCEDURE_KIND, TREES_LEN_PROC},
                {"LSL", TREES_PROCEDURE_KIND, TREES_LSL_PROC},
+               {"Length", TREES_PROCEDURE_KIND, TREES_LEN_PROC},
                {"New", TREES_PROCEDURE_KIND, TREES_NEW_PROC},
                {"ORD", TREES_PROCEDURE_KIND, TREES_ORD_PROC},
                {"PACK", TREES_PROCEDURE_KIND, TREES_PACK_PROC},
index aaab518878b0e67c1cc3440eb67352d4ede5c77b..f641effd8189ec277d37f872d930f414226e7127 100644 (file)
@@ -5576,8 +5576,8 @@ static Trees_Node PredeclaredProcedureAST(const char procName[], Trees_Node expL
                {"FLT", TREES_FLT_PROC},
                {"INC", TREES_INC_PROC},
                {"INCL", TREES_INCL_PROC},
-               {"LEN", TREES_LEN_PROC},
                {"LSL", TREES_LSL_PROC},
+               {"Length", TREES_LEN_PROC},
                {"New", TREES_NEW_PROC},
                {"ORD", TREES_ORD_PROC},
                {"PACK", TREES_PACK_PROC},
index 35b9162ab1b00dc85d0a6b46ac25d0be578b3179..74ff49293741a8ddd331c140dfd47a6a0deef028 100644 (file)
@@ -407,7 +407,7 @@ Out.Integer(ORD({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln;
                Assert(i = 1);
 
                a := "";
-               Assert(LEN(a) = 10);
+               Assert(Length(a) = 10);
 
                Assert(LSL(0, 0) = 0);
                Assert(LSL(0, 1) = 0);
index 268d0fd90f678afef5cf81ecba1da84ec9a89fac..28d3ae4e0334d484049eea831337b0f230f730e9 100644 (file)
@@ -51,8 +51,8 @@ module T6ProcedureDeclarations;
 
                procedure P3(A: Matrix);
                begin
-                       Assert(LEN(A) = 10);
-                       Assert(LEN(A[0]) = 20)
+                       Assert(Length(A) = 10);
+                       Assert(Length(A[0]) = 20)
                end P3;
 
                procedure P4(A: array of Row);
@@ -81,8 +81,8 @@ module T6ProcedureDeclarations;
 
                procedure P(var A: Matrix);
                begin
-                       Assert(LEN(A) = 10);
-                       Assert(LEN(A[0]) = 20)
+                       Assert(Length(A) = 10);
+                       Assert(Length(A[0]) = 20)
                end P;
 
                procedure Q(var x: T0);
@@ -113,7 +113,7 @@ module T6ProcedureDeclarations;
                procedure P(a: array of Int);
                        var i: Int;
                begin
-                       for i := 0 to LEN(a) - 1 do
+                       for i := 0 to Length(a) - 1 do
                                Assert(a[i] = i + 1)
                        end
                end P;
@@ -125,8 +125,8 @@ module T6ProcedureDeclarations;
                                var c, i, j: Int;
                        begin
                                c := 0;
-                               for i := 0 to LEN(M) - 1 do
-                                       for j := 0 to LEN(M[0]) - 1 do
+                               for i := 0 to Length(M) - 1 do
+                                       for j := 0 to Length(M[0]) - 1 do
                                                Assert(M[i, j] = c);
                                                INC(c)
                                        end
@@ -136,8 +136,8 @@ module T6ProcedureDeclarations;
                        procedure Inner1(row: array of Int);
                                var c, j: Int;
                        begin
-                               c := LEN(row);
-                               for j := 0 to LEN(row) - 1 do
+                               c := Length(row);
+                               for j := 0 to Length(row) - 1 do
                                        Assert(row[j] = c);
                                        INC(c)
                                end
@@ -153,9 +153,9 @@ module T6ProcedureDeclarations;
                        var c, i, j, k: Int;
                begin
                        c := 0;
-                       for i := 0 to LEN(T) - 1 do
-                               for j := 0 to LEN(T[0]) - 1 do
-                                       for k := 0 to LEN(T[0, 0]) - 1 do
+                       for i := 0 to Length(T) - 1 do
+                               for j := 0 to Length(T[0]) - 1 do
+                                       for k := 0 to Length(T[0, 0]) - 1 do
                                                Assert(T[i, j, k] = c);
                                                INC(c)
                                        end
@@ -165,14 +165,14 @@ module T6ProcedureDeclarations;
                end R;
 
        begin
-               for i := 0 to LEN(a) - 1 do
+               for i := 0 to Length(a) - 1 do
                        a[i] := i + 1
                end;
                P(a);
 
                c := 0;
-               for i := 0 to LEN(M) - 1 do
-                       for j := 0 to LEN(M[0]) - 1 do
+               for i := 0 to Length(M) - 1 do
+                       for j := 0 to Length(M[0]) - 1 do
                                M[i, j] := c;
                                INC(c)
                        end
@@ -180,9 +180,9 @@ module T6ProcedureDeclarations;
                Q(M);
 
                c := 0;
-               for i := 0 to LEN(T) - 1 do
-                       for j := 0 to LEN(T[0]) - 1 do
-                               for k := 0 to LEN(T[0, 0]) - 1 do
+               for i := 0 to Length(T) - 1 do
+                       for j := 0 to Length(T[0]) - 1 do
+                               for k := 0 to Length(T[0, 0]) - 1 do
                                        T[i, j, k] := c;
                                        INC(c)
                                end