X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=test.c;h=541b3a57f55dae71a8936e0c696f6ad506084340;hb=89dfaf94ddbbc501020554232ce026b6584e8045;hp=7c8e6720506e4c8113282b94656fdaf20d44baca;hpb=063ba732ee8778c34a3781270b18d52481dbf0cd;p=dsw-obn.git diff --git a/test.c b/test.c index 7c8e672..541b3a5 100644 --- a/test.c +++ b/test.c @@ -1,56 +1,68 @@ #include "oberon.h" +#include "generator.h" + +#include #include -static const char source[] = +static char source_test[] = "MODULE Test;" - "CONST" - " con = 3;" - "" - "TYPE" - " MyInt = INTEGER;" - " MyArr = ARRAY con OF MyInt;" - "" + "IMPORT I := Imported;" "VAR" - " k : INTEGER;" - " i : INTEGER;" - " b : BOOLEAN;" - " arr : MyArr;" - "" - "PROCEDURE Tier;" + " x, y : I.Rider;" + "PROCEDURE Proc(x, y, z : INTEGER);" "BEGIN" - " k := 314 + con;" - "END Tier;" - "" - "PROCEDURE Tier2(x : INTEGER; y : INTEGER);" - "BEGIN" - " k := x + y;" - "END Tier2;" + " x := 1;" + "END Proc;" + "BEGIN;" + " 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 Tier3(x : INTEGER) : INTEGER;" - "BEGIN" - " RETURN x * x * x;" - "END Tier3;" + "PROCEDURE Ln*;" + "END Ln;" "" - "BEGIN" - " k := 1;" - " i := k;" - " b := (TRUE # FALSE);" - " Tier();" - " Tier2(21, 13);" - " k := Tier3(2);" -// " arr[0] := 1;" - "END Test." + "BEGIN;" + " 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; }