index 178327ecf317a2ad3298036bf70b59a620c1af39..4bef02c8bd7bc3c33d0788d4243d49e875f575ad 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[] =
"MODULE Test;"
- ""
- "TYPE"
- " MyInt = INTEGER;"
- " MyRec = RECORD"
- " a : MyInt;"
- " END;"
- " MyRecPtr = POINTER TO MyRec;"
- ""
+ "IMPORT I := Imported;"
+ "VAR"
+ " x, y : I.Rider;"
+ "PROCEDURE Proc(x, y, z : INTEGER);"
+ "END Proc;"
"BEGIN"
- " "
+ " x.i := 1;"
+ " I.Ln;"
+ " I.i := 666;"
"END Test."
;
+static char source_imported[] =
+ "MODULE Imported;"
+ "TYPE"
+ " Rider* = RECORD i, j, k : INTEGER; END;"
+ "VAR"
+ " i- : INTEGER;"
+ ""
+ "PROCEDURE Ln*;"
+ "END Ln;"
+ ""
+ "BEGIN;"
+ "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;