From: mike lowis Date: Sat, 10 Apr 2021 00:31:11 +0000 (-0400) Subject: FLT ORD CHR to AsReal AsInt AsChar X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=55f135755da059c383c0e779fb1e2f1c602028ca;p=proto%2Fobnc.git FLT ORD CHR to AsReal AsInt AsChar --- diff --git a/CONFIG.bak b/CONFIG.bak new file mode 100644 index 0000000..b1a6bfc --- /dev/null +++ b/CONFIG.bak @@ -0,0 +1,5 @@ +prefix=/usr/local +libdir=lib +cIntType=int +cRealType=double +version=0.16.1 diff --git a/lib/obnc/Strings.obn b/lib/obnc/Strings.obn index 9ca30dc..353564a 100644 --- a/lib/obnc/Strings.obn +++ b/lib/obnc/Strings.obn @@ -155,7 +155,7 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co i := 0; while s[i] # 0X do if (s[i] >= "a") & (s[i] <= "z") then - s[i] := CHR(ORD("A") + ORD(s[i]) - ORD("a")); + s[i] := AsChar(AsInt("A") + AsInt(s[i]) - AsInt("a")); end; INC(i) end diff --git a/lib/obnc/XYplane.obn b/lib/obnc/XYplane.obn index 04fe889..4d67b33 100644 --- a/lib/obnc/XYplane.obn +++ b/lib/obnc/XYplane.obn @@ -41,7 +41,7 @@ Implements the basic library module from "The Oakwood Guidelines for Oberon-2 Co procedure Key*(): Char; (**reads the keyboard. If a key was pressed prior to invocation, its character value is returned, otherwise the result is 0X.*) - return CHR(0) (*dummy value*) + return AsChar(0) (*dummy value*) end Key; procedure SetSize*(width, height: Int); diff --git a/src/Oberon.y b/src/Oberon.y index dbe1e65..cbf803a 100644 --- a/src/Oberon.y +++ b/src/Oberon.y @@ -3589,17 +3589,17 @@ static Trees_Node PredeclaredProcedureAST(const char procName[], Trees_Node expL { static const struct { const char *name; int symbol; } symbols[] = { {"ABS", TREES_ABS_PROC}, + {"AsChar", TREES_CHR_PROC}, + {"AsInt", TREES_ORD_PROC}, + {"AsReal", TREES_FLT_PROC}, {"Assert", TREES_ASSERT_PROC}, - {"CHR", TREES_CHR_PROC}, {"DEC", TREES_DEC_PROC}, {"EXCL", TREES_EXCL_PROC}, {"FLOOR", TREES_FLOOR_PROC}, - {"FLT", TREES_FLT_PROC}, {"INC", TREES_INC_PROC}, {"INCL", TREES_INCL_PROC}, {"Length", TREES_LEN_PROC}, {"New", TREES_NEW_PROC}, - {"ORD", TREES_ORD_PROC}, {"ADR", TREES_ADR_PROC}, {"SIZE", TREES_SIZE_PROC}, diff --git a/src/Table.c b/src/Table.c index 2e78253..a73e408 100644 --- a/src/Table.c +++ b/src/Table.c @@ -88,21 +88,21 @@ void Table_Init(void) */ static const struct { const char *name; int kind, type; } predecIdents[] = { {"ABS", TREES_PROCEDURE_KIND, TREES_ABS_PROC}, /* Remove */ + {"AsChar", TREES_PROCEDURE_KIND, TREES_CHR_PROC}, + {"AsInt", TREES_PROCEDURE_KIND, TREES_ORD_PROC}, + {"AsReal", TREES_PROCEDURE_KIND, TREES_FLT_PROC}, {"Assert", TREES_PROCEDURE_KIND, TREES_ASSERT_PROC}, {"Bool", TREES_TYPE_KIND, TREES_BOOLEAN_TYPE}, {"Byte", TREES_TYPE_KIND, TREES_BYTE_TYPE}, - {"CHR", TREES_PROCEDURE_KIND, TREES_CHR_PROC}, {"Char", TREES_TYPE_KIND, TREES_CHAR_TYPE}, {"DEC", TREES_PROCEDURE_KIND, TREES_DEC_PROC}, /* Operator */ {"EXCL", TREES_PROCEDURE_KIND, TREES_EXCL_PROC}, {"FLOOR", TREES_PROCEDURE_KIND, TREES_FLOOR_PROC}, - {"FLT", TREES_PROCEDURE_KIND, TREES_FLT_PROC}, {"INC", TREES_PROCEDURE_KIND, TREES_INC_PROC}, /* Operator */ {"INCL", TREES_PROCEDURE_KIND, TREES_INCL_PROC}, {"Int", TREES_TYPE_KIND, TREES_INTEGER_TYPE}, {"Length", TREES_PROCEDURE_KIND, TREES_LEN_PROC}, {"New", TREES_PROCEDURE_KIND, TREES_NEW_PROC}, - {"ORD", TREES_PROCEDURE_KIND, TREES_ORD_PROC}, {"Real", TREES_TYPE_KIND, TREES_REAL_TYPE}, {"Set", TREES_TYPE_KIND, TREES_SET_TYPE}, }; diff --git a/src/y.tab.c b/src/y.tab.c index 167005b..8d0a395 100644 --- a/src/y.tab.c +++ b/src/y.tab.c @@ -5567,17 +5567,17 @@ static Trees_Node PredeclaredProcedureAST(const char procName[], Trees_Node expL { static const struct { const char *name; int symbol; } symbols[] = { {"ABS", TREES_ABS_PROC}, + {"AsChar", TREES_CHR_PROC}, + {"AsInt", TREES_ORD_PROC}, + {"AsReal", TREES_FLT_PROC}, {"Assert", TREES_ASSERT_PROC}, - {"CHR", TREES_CHR_PROC}, {"DEC", TREES_DEC_PROC}, {"EXCL", TREES_EXCL_PROC}, {"FLOOR", TREES_FLOOR_PROC}, - {"FLT", TREES_FLT_PROC}, {"INC", TREES_INC_PROC}, {"INCL", TREES_INCL_PROC}, {"Length", TREES_LEN_PROC}, {"New", TREES_NEW_PROC}, - {"ORD", TREES_ORD_PROC}, {"ADR", TREES_ADR_PROC}, {"SIZE", TREES_SIZE_PROC}, diff --git a/tests/obnc/passing/A.obn b/tests/obnc/passing/A.obn index 741c7a8..1fa2805 100644 --- a/tests/obnc/passing/A.obn +++ b/tests/obnc/passing/A.obn @@ -21,7 +21,7 @@ module A; const boolConst* = true; - charConst* = CHR(22H); + charConst* = AsChar(22H); intConst* = 1; realConst* = 2.3; strConst* = "hello there"; diff --git a/tests/obnc/passing/T1ConstantDeclarations.obn b/tests/obnc/passing/T1ConstantDeclarations.obn index c0335ae..a64a3e9 100644 --- a/tests/obnc/passing/T1ConstantDeclarations.obn +++ b/tests/obnc/passing/T1ConstantDeclarations.obn @@ -25,7 +25,7 @@ module T1ConstantDeclarations; quotes = 22X; backslash = "\"; nonAscii = 80X; - letterA = CHR(ORD("A")); + letterA = AsChar(AsInt("A")); sevenDigits = "1234567"; count = 37; pi = 3.14; diff --git a/tests/obnc/passing/T4Expressions.obn b/tests/obnc/passing/T4Expressions.obn index 3e57b7f..1d6755a 100644 --- a/tests/obnc/passing/T4Expressions.obn +++ b/tests/obnc/passing/T4Expressions.obn @@ -73,9 +73,9 @@ module T4Expressions; begin a := 4; b := 6; -Out.Integer(ORD({1, 2, a, 5, b, 8}), 0); Out.Ln; -Out.Integer(ORD({1, 2, a..b, 8}), 0); Out.Ln; -Out.Integer(ORD({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln; +Out.Integer(AsInt({1, 2, a, 5, b, 8}), 0); Out.Ln; +Out.Integer(AsInt({1, 2, a..b, 8}), 0); Out.Ln; +Out.Integer(AsInt({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln; Assert({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}); i := 0; j := 0; @@ -380,9 +380,9 @@ Out.Integer(ORD({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln; (*make sure function procedures with constant parameters are constant expressions*) absConst = ABS(0); floorConst = FLOOR(eps); - fltConst = FLT(0); - ordConst = ORD(true); - chrConst = CHR(0); + fltConst = AsReal(0); + ordConst = AsInt(true); + chrConst = AsChar(0); var a: array 10 of Char; b: Bool; @@ -410,45 +410,45 @@ Out.Integer(ORD({1, 2, a, 5, b, 8} = {1, 2, a..b, 8}), 0); Out.Ln; Assert(FLOOR(0.0) = 0); Assert(FLOOR(1.5) = 1); i := 0; - j := FLOOR(FLT(IncReturnZero(i)) + 1.5); + j := FLOOR(AsReal(IncReturnZero(i)) + 1.5); Assert(j = 1); Assert(i = 1); - Assert(FLT(-1) = -1.0); - Assert(FLT(0) = 0.0); - Assert(FLT(1) = 1.0); + Assert(AsReal(-1) = -1.0); + Assert(AsReal(0) = 0.0); + Assert(AsReal(1) = 1.0); - Assert(ORD(0X) = 0); + Assert(AsInt(0X) = 0); ch := 0X; - Assert(ORD(ch) = 0); - Assert(ORD("A") = 41H); + Assert(AsInt(ch) = 0); + Assert(AsInt("A") = 41H); ch := "A"; - Assert(ORD(ch) = 41H); - Assert(ORD(0FFX) = 0FFH); + Assert(AsInt(ch) = 41H); + Assert(AsInt(0FFX) = 0FFH); ch := 0FFX; - Assert(ORD(ch) = 0FFH); + Assert(AsInt(ch) = 0FFH); - Assert(ORD(false) = 0); + Assert(AsInt(false) = 0); b := false; - Assert(ORD(b) = 0); - Assert(ORD(true) = 1); + Assert(AsInt(b) = 0); + Assert(AsInt(true) = 1); b := true; - Assert(ORD(b) = 1); + Assert(AsInt(b) = 1); - Assert(ORD({}) = 0); + Assert(AsInt({}) = 0); s := {}; - Assert(ORD(s) = 0); - Assert(ORD({8}) = 256); + Assert(AsInt(s) = 0); + Assert(AsInt({8}) = 256); s := {8}; - Assert(ORD(s) = 256); + Assert(AsInt(s) = 256); - Assert(CHR(0) = 0X); - Assert(CHR(1) = 1X); - Assert(CHR(7FH) = 7FX); + Assert(AsChar(0) = 0X); + Assert(AsChar(1) = 1X); + Assert(AsChar(7FH) = 7FX); ch := 7FX; - Assert(CHR(7FH) = ch); + Assert(AsChar(7FH) = ch); x := 1; - Assert(CHR(x) = 1X); + Assert(AsChar(x) = 1X); i := absConst; i := floorConst; diff --git a/tests/obnc/passing/T7Modules.obn b/tests/obnc/passing/T7Modules.obn index 9fc125f..d780e15 100644 --- a/tests/obnc/passing/T7Modules.obn +++ b/tests/obnc/passing/T7Modules.obn @@ -45,7 +45,7 @@ module T7Modules; begin Assert(A.boolConst); - Assert(A.charConst = CHR(22H)); + Assert(A.charConst = AsChar(22H)); Assert(A.intConst = 1); Assert(A.realConst = 2.3); Assert(A.strConst = "hello there");