X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=test.c;h=5b2fc48e91e4e54175f56baa5dd1ea247781bcb3;hb=0833fd8741d5215e8e8576fecd1f5a5f5dfc84f6;hp=b07a08d0898a7f2816a6bb281c9f6050ac31d9bb;hpb=734fa8f9223c140a583e7f193df810d48555ac34;p=dsw-obn.git diff --git a/test.c b/test.c index b07a08d..5b2fc48 100644 --- a/test.c +++ b/test.c @@ -1,40 +1,57 @@ #include "oberon.h" #include "generator.h" + +#include #include -static const char source[] = +static char source_test[] = "MODULE Test;" - "TYPE" - " Rec = RECORD i : INTEGER; END;" + "IMPORT I := Imported;" "VAR" - " i : INTEGER;" - " j : INTEGER;" - "" - "PROCEDURE ^ Tier(x : INTEGER);" - "" - "PROCEDURE Tier(x : INTEGER);" - "VAR a : INTEGER;" - "BEGIN;" - " a := 1;" - "END Tier;" + " x : I.Rider;" + "BEGIN" + " I.Ln;" + "END Test." +; + +static char source_imported[] = + "MODULE Imported;" + "TYPE" + " Rider* = RECORD i : INTEGER; END;" "" - "PROCEDURE ^ Tier(x : INTEGER);" + "PROCEDURE Ln*;" + "END Ln;" "" "BEGIN;" - " i := 666;" - " Tier(1);" - "END Test." + "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;