summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 674b8e8)
raw | patch | inline | side by side (parent: 674b8e8)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 15 Sep 2017 15:15:00 +0000 (18:15 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Fri, 15 Sep 2017 15:15:00 +0000 (18:15 +0300) |
Test.obn | patch | blob | history | |
obn-run-tests.sh | patch | blob | history | |
src/backends/jvm/generator-jvm.c | patch | blob | history | |
src/oberon-common.h | patch | blob | history | |
src/oberon.c | patch | blob | history | |
tests/Test28.obn | [new file with mode: 0644] | patch | blob |
diff --git a/Test.obn b/Test.obn
index ecfde58b9f0e5fadb5eb6a9a884a62ede7a56351..950aa0a9ca7e9993974152c16cfff3bc01beb0fc 100644 (file)
--- a/Test.obn
+++ b/Test.obn
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.
diff --git a/obn-run-tests.sh b/obn-run-tests.sh
index 88b5c6d36d66c0d2ce7a434b87809fa27e7a79df..8db6f37b203c5a6c9733df4dc90f79b6dc0f8e2e 100755 (executable)
--- a/obn-run-tests.sh
+++ b/obn-run-tests.sh
maketest Test25
maketest Test26
maketest Test27
+maketest Test28
index 26a0b55e829ed8ee735b5e5eecdc9bba3c31c1e4..7da9b61ce94f0558220d745007e8a8f53688abf7 100644 (file)
#include <gc.h>
#include "../../oberon-internals.h"
+#include "../../oberon-type-compat.h"
#include "../../generator.h"
#include "generator-jvm.h"
#include "generator-jvm-abi.h"
}
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);
diff --git a/src/oberon-common.h b/src/oberon-common.h
index ccbe6e1a84301c0c62659845617fc8415aae25fa..d4988a4c398a339b76b314b9be4926b95336e637 100644 (file)
--- a/src/oberon-common.h
+++ b/src/oberon-common.h
SEMICOLON,
END,
DOT,
- VAR,
COLON,
BEGIN,
ASSIGN,
MOD,
AND,
NOT,
- PROCEDURE,
COMMA,
RETURN,
- CONST,
- TYPE,
ARRAY,
OF,
LBRACK,
DOTDOT,
CASE,
BAR,
- WITH
+ WITH,
+
+ CONST,
+ TYPE,
+ VAR,
+ PROCEDURE
};
void
diff --git a/src/oberon.c b/src/oberon.c
index 04eaf8c8fd29e32e6b5318db2981e64d2a02b2cd..5abb2090477536027219f41e2e0b9e78b69d9ab5 100644 (file)
--- a/src/oberon.c
+++ b/src/oberon.c
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
--- /dev/null
+++ b/tests/Test28.obn
@@ -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.
+
+Тест сравнения массивов символов.