diff --git a/oberon.c b/oberon.c
index bd5498bbccc06ee9a4ac7ff684ca9f2532149bf9..7ca600e205a26e377f25bea0de64ff7ad0c758cf 100644 (file)
--- a/oberon.c
+++ b/oberon.c
OF,
LBRACE,
RBRACE,
- RECORD
+ RECORD,
+ POINTER,
+ TO
};
// =======================================================================
{
ctx -> token = RECORD;
}
+ else if(strcmp(ident, "POINTER") == 0)
+ {
+ ctx -> token = POINTER;
+ }
+ else if(strcmp(ident, "TO") == 0)
+ {
+ ctx -> token = TO;
+ }
}
static void
}
}
+static oberon_type_t *
+oberon_make_pointer(oberon_context_t * ctx, oberon_type_t * type)
+{
+ if(type -> class == OBERON_TYPE_POINTER)
+ {
+ return type;
+ }
+
+ if(type -> class == OBERON_TYPE_INTEGER
+ || type -> class == OBERON_TYPE_BOOLEAN
+ || type -> class == OBERON_TYPE_PROCEDURE
+ || type -> class == OBERON_TYPE_VOID)
+ {
+ oberon_error(ctx, "oberon not support pointers to non structure types");
+ }
+
+ oberon_type_t * newtype;
+ newtype = oberon_new_type_ptr(OBERON_TYPE_POINTER);
+ newtype -> base = type;
+
+ oberon_generator_init_type(ctx, newtype);
+
+ return newtype;
+}
+
static oberon_type_t * oberon_opt_formal_pars(oberon_context_t * ctx, int class);
static oberon_type_t *
type -> decl = type -> decl -> next;
oberon_generator_init_type(ctx, type);
}
+ else if(ctx -> token == POINTER)
+ {
+ oberon_assert_token(ctx, POINTER);
+ oberon_assert_token(ctx, TO);
+ type = oberon_type(ctx);
+ type = oberon_make_pointer(ctx, type);
+ }
else if(ctx -> token == PROCEDURE)
{
oberon_assert_token(ctx, PROCEDURE);