X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=test.c;h=f1b175cf476d22f404de648888f0d39e45c9de81;hb=92fc7033b874920acf1b2f6e21bde51dcd0197f1;hp=914764e39d2d3c25382be63f5fe5dada0b9aa4b9;hpb=1bf625553dc35ac4a5c1afceb6950fd44776a424;p=dsw-obn.git diff --git a/test.c b/test.c index 914764e..f1b175c 100644 --- a/test.c +++ b/test.c @@ -1,41 +1,68 @@ #include "oberon.h" #include "generator.h" + +#include #include -static const char source[] = +static char source_test[] = + "(* Main module *)" "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;" + " x, y : I.Rider;" + "PROCEDURE Proc(x, y, z : INTEGER);" + "BEGIN" + " x := 1;" + "END Proc;" "BEGIN;" - " a := 1;" - "END Tier;" + " y.i := 1;" + " I.a[0] := 1;" + "END Test." +; + +static char source_imported[] = + "MODULE Imported;" + "TYPE" + " Rider* = RECORD i*, j-, k : INTEGER; END;" + "VAR" + " i- : INTEGER;" + " a* : ARRAY 3 OF INTEGER;" "" - "PROCEDURE ^ Tier(x : INTEGER);" + "PROCEDURE Ln*;" + "END Ln;" "" "BEGIN;" - " i := ABS(-666);" - " Tier(i);" - " ABS(1);" - "END Test." + " i := 1;" + " 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;