From: mike lowis Date: Fri, 9 Apr 2021 20:37:06 +0000 (-0400) Subject: changed LEN to Length X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=5da06327a09b767f763f8151e66fb0596a289c4a;p=proto%2Fobnc.git changed LEN to Length --- diff --git a/lib/obnc/FilesTest.obn b/lib/obnc/FilesTest.obn index 9b37be0..2388e2c 100644 --- a/lib/obnc/FilesTest.obn +++ b/lib/obnc/FilesTest.obn @@ -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; diff --git a/lib/obnc/Strings.obn b/lib/obnc/Strings.obn index ba95fd6..9ca30dc 100644 --- a/lib/obnc/Strings.obn +++ b/lib/obnc/Strings.obn @@ -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; diff --git a/lib/obnc/StringsTest.obn b/lib/obnc/StringsTest.obn index f3933fa..8199b70 100644 --- a/lib/obnc/StringsTest.obn +++ b/lib/obnc/StringsTest.obn @@ -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 index 0627e87..0000000 Binary files a/src/.Oberon.y.swp and /dev/null differ diff --git a/src/Oberon.y b/src/Oberon.y index a8290f4..76f82a6 100644 --- a/src/Oberon.y +++ b/src/Oberon.y @@ -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}, diff --git a/src/Table.c b/src/Table.c index f375689..24145ec 100644 --- a/src/Table.c +++ b/src/Table.c @@ -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}, diff --git a/src/y.tab.c b/src/y.tab.c index aaab518..f641eff 100644 --- a/src/y.tab.c +++ b/src/y.tab.c @@ -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}, diff --git a/tests/obnc/passing/T4Expressions.obn b/tests/obnc/passing/T4Expressions.obn index 35b9162..74ff492 100644 --- a/tests/obnc/passing/T4Expressions.obn +++ b/tests/obnc/passing/T4Expressions.obn @@ -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); diff --git a/tests/obnc/passing/T6ProcedureDeclarations.obn b/tests/obnc/passing/T6ProcedureDeclarations.obn index 268d0fd..28d3ae4 100644 --- a/tests/obnc/passing/T6ProcedureDeclarations.obn +++ b/tests/obnc/passing/T6ProcedureDeclarations.obn @@ -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