DEADSOFTWARE

Разрешено повторно объявлять блоки CONST TYPE VAR, поправлено сравнение массивов...
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 15 Sep 2017 15:15:00 +0000 (18:15 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 15 Sep 2017 15:15:00 +0000 (18:15 +0300)
Test.obn
obn-run-tests.sh
src/backends/jvm/generator-jvm.c
src/oberon-common.h
src/oberon.c
tests/Test28.obn [new file with mode: 0644]

index ecfde58b9f0e5fadb5eb6a9a884a62ede7a56351..950aa0a9ca7e9993974152c16cfff3bc01beb0fc 100644 (file)
--- a/Test.obn
+++ b/Test.obn
@@ -1,21 +1,14 @@
 MODULE Test;
 
-TYPE
-  A = POINTER TO RECORD B : B; END;
+IMPORT Out;
 
-  B = POINTER TO RECORD x : A END;
+TYPE
+  Name = ARRAY 16 OF CHAR;
 
 VAR
-  a : A;
-
-PROCEDURE Do;
-  TYPE
-    ListPtr = POINTER TO ListNode;
-    ListNode = RECORD next: ListPtr END;
-BEGIN
-END Do;
+  key : ARRAY 128 OF Name;
+  name : Name;
 
 BEGIN
-  NEW(a);
-  a.B := NIL;
+  IF name > name THEN Out.Ln; END;
 END Test.
index 88b5c6d36d66c0d2ce7a434b87809fa27e7a79df..8db6f37b203c5a6c9733df4dc90f79b6dc0f8e2e 100755 (executable)
@@ -100,3 +100,4 @@ maketest Test24
 maketest Test25
 maketest Test26
 maketest Test27
+maketest Test28
index 26a0b55e829ed8ee735b5e5eecdc9bba3c31c1e4..7da9b61ce94f0558220d745007e8a8f53688abf7 100644 (file)
@@ -9,6 +9,7 @@
 #include <gc.h>
 
 #include "../../oberon-internals.h"
+#include "../../oberon-type-compat.h"
 #include "../../generator.h"
 #include "generator-jvm.h"
 #include "generator-jvm-abi.h"
@@ -1454,8 +1455,7 @@ jvm_generate_compare_op(gen_proc_t * p, oberon_type_t * t, int op)
        }
        else if(prefix == 'a')
        {
-               if(t -> class == OBERON_TYPE_STRING
-                       || (t -> class == OBERON_TYPE_POINTER && t -> base -> class == OBERON_TYPE_CHAR))
+               if(oberon_is_array_of_char_type(t) || oberon_is_string_type(t))
                {
                        jvm_generate(p, 2, 1, "invokestatic SYSTEM/STRCMP([B[B)I");
                        jvm_generate(p, 1, 0, "if%s L%i", cmpop, label_true);
index ccbe6e1a84301c0c62659845617fc8415aae25fa..d4988a4c398a339b76b314b9be4926b95336e637 100644 (file)
@@ -5,7 +5,6 @@ enum {
         SEMICOLON,
         END,
         DOT,
-        VAR,
         COLON,
         BEGIN,
         ASSIGN,
@@ -29,11 +28,8 @@ enum {
         MOD,
         AND,
         NOT,
-        PROCEDURE,
         COMMA,
         RETURN,
-        CONST,
-        TYPE,
         ARRAY,
         OF,
         LBRACK,
@@ -64,7 +60,12 @@ enum {
         DOTDOT,
         CASE,
         BAR,
-        WITH
+        WITH,
+
+        CONST,
+        TYPE,
+        VAR,
+        PROCEDURE
 };
 
 void
index 04eaf8c8fd29e32e6b5318db2981e64d2a02b2cd..5abb2090477536027219f41e2e0b9e78b69d9ab5 100644 (file)
@@ -3141,33 +3141,34 @@ oberon_prevent_undeclarated_procedures(oberon_context_t * ctx)
 static void
 oberon_decl_seq(oberon_context_t * ctx)
 {
-       if(ctx -> token == CONST)
+       while(ctx -> token >= CONST && ctx -> token <= VAR)
        {
-               oberon_assert_token(ctx, CONST);
-               while(ctx -> token == IDENT)
+               if(ctx -> token == CONST)
                {
-                       oberon_const_decl(ctx);
-                       oberon_assert_token(ctx, SEMICOLON);
+                       oberon_assert_token(ctx, CONST);
+                       while(ctx -> token == IDENT)
+                       {
+                               oberon_const_decl(ctx);
+                               oberon_assert_token(ctx, SEMICOLON);
+                       }
                }
-       }
-
-       if(ctx -> token == TYPE)
-       {
-               oberon_assert_token(ctx, TYPE);
-               while(ctx -> token == IDENT)
+               else if(ctx -> token == TYPE)
                {
-                       oberon_type_decl(ctx);
-                       oberon_assert_token(ctx, SEMICOLON);
+                       oberon_assert_token(ctx, TYPE);
+                       while(ctx -> token == IDENT)
+                       {
+                               oberon_type_decl(ctx);
+                               oberon_assert_token(ctx, SEMICOLON);
+                       }
                }
-       }
-
-       if(ctx -> token == VAR)
-       {
-               oberon_assert_token(ctx, VAR);
-               while(ctx -> token == IDENT)
+               else if(ctx -> token == VAR)
                {
-                       oberon_var_decl(ctx);
-                       oberon_assert_token(ctx, SEMICOLON);
+                       oberon_assert_token(ctx, VAR);
+                       while(ctx -> token == IDENT)
+                       {
+                               oberon_var_decl(ctx);
+                               oberon_assert_token(ctx, SEMICOLON);
+                       }
                }
        }
 
diff --git a/tests/Test28.obn b/tests/Test28.obn
new file mode 100644 (file)
index 0000000..7f9a7ea
--- /dev/null
@@ -0,0 +1,16 @@
+MODULE Test28;
+
+IMPORT Out;
+
+TYPE
+  Name = ARRAY 16 OF CHAR;
+
+VAR
+  key : ARRAY 128 OF Name;
+  name : Name;
+
+BEGIN
+  IF key[0] > name THEN Out.Ln; END;
+END Test28.
+
+Тест сравнения массивов символов.