X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=test.c;h=297da8de9a9c9d21c05fe7db43989753f35613cb;hb=c15b86365824545bdee7d813ce0c796f1bdff592;hp=b934af876ca2bde9d44397015f95c7ce70953bd5;hpb=338eeae16495bbdcbd8c4f3dad4996346e26139b;p=dsw-obn.git diff --git a/test.c b/test.c index b934af8..297da8d 100644 --- a/test.c +++ b/test.c @@ -1,31 +1,71 @@ #include "oberon.h" #include "generator.h" + +#include #include -static const char source[] = +static char source_test[] = "MODULE Test;" + "IMPORT I := Imported;" "TYPE" - " MyRec = POINTER TO MyRecDesc;" - " MyRecDesc = RECORD" - " a : INTEGER;" - " END;" + " Callback = PROCEDURE() : INTEGER;" + "" "VAR" - " r : MyRec;" + " cb : Callback;" + " i : INTEGER;" + " r : I.Rider;" + "" + "PROCEDURE RelBack;" + "BEGIN" + " i := 666;" + "END RelBack;" + "" "BEGIN;" - " r := NIL;" - " r.a := 1;" + " i := ABS(-1);" + " i := cb();" + " RelBack;" + " 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;