index 8f3edc4aec855db2d7e30c6f1b24d0f45ece44c3..5b2fc48e91e4e54175f56baa5dd1ea247781bcb3 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 = POINTER TO RECORD"
- " a : MyInt;"
- " next : MyRec;"
- " END;"
- ""
+ "IMPORT I := Imported;"
"VAR"
- " r : MyRec;"
- ""
+ " x : I.Rider;"
"BEGIN"
- " "
+ " I.Ln;"
"END Test."
;
+static char source_imported[] =
+ "MODULE Imported;"
+ "TYPE"
+ " Rider* = RECORD i : INTEGER; END;"
+ ""
+ "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;