index d828f4a2e855adbbd24d2852738453892614f634..f1b175cf476d22f404de648888f0d39e45c9de81 100644 (file)
--- a/test.c
+++ b/test.c
#include "oberon.h"
#include "generator.h"
+
+#include <string.h>
#include <assert.h>
-static const char source[] =
+static char source_test[] =
+ "(* Main module *)"
"MODULE Test;"
+ "IMPORT I := Imported;"
+ "VAR"
+ " x, y : I.Rider;"
+ "PROCEDURE Proc(x, y, z : INTEGER);"
+ "BEGIN"
+ " x := 1;"
+ "END Proc;"
+ "BEGIN;"
+ " y.i := 1;"
+ " I.a[0] := 1;"
+ "END Test."
+;
+
+static char source_imported[] =
+ "MODULE Imported;"
"TYPE"
- " Callback = PROCEDURE() : INTEGER;"
- ""
+ " Rider* = RECORD i*, j-, k : INTEGER; END;"
"VAR"
- " cb : Callback;"
- " i : INTEGER;"
+ " i- : INTEGER;"
+ " a* : ARRAY 3 OF INTEGER;"
""
- "PROCEDURE RelBack;"
- "BEGIN"
- " i := 666;"
- "END RelBack;"
+ "PROCEDURE Ln*;"
+ "END Ln;"
""
"BEGIN;"
" i := 1;"
- " i := cb();"
- " RelBack;"
- "END Test."
+ " a[0] := 555;"
+ "END Imported."
;
static oberon_context_t * ctx;
static oberon_module_t * mod;
+static const char *
+import_module(const char * name)
+{
+ if(strcmp(name, "Test") == 0)
+ {
+ return source_test;
+ }
+ else if(strcmp(name, "Imported") == 0)
+ {
+ return source_imported;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
int
main(int argc, char ** argv)
{
- ctx = oberon_create_context();
- mod = oberon_compile_module(ctx, source);
- //mod -> begin();
+ ctx = oberon_create_context(import_module);
+ mod = oberon_compile_module(ctx, source_test);
+ oberon_generate_code(ctx);
oberon_generator_dump(ctx, "dump.txt");
oberon_destroy_context(ctx);
return 0;