DEADSOFTWARE

4bef02c8bd7bc3c33d0788d4243d49e875f575ad
[dsw-obn.git] / test.c
1 #include "oberon.h"
2 #include "generator.h"
4 #include <string.h>
5 #include <assert.h>
7 static char source_test[] =
8 "MODULE Test;"
9 "IMPORT I := Imported;"
10 "VAR"
11 " x, y : I.Rider;"
12 "PROCEDURE Proc(x, y, z : INTEGER);"
13 "END Proc;"
14 "BEGIN"
15 " x.i := 1;"
16 " I.Ln;"
17 " I.i := 666;"
18 "END Test."
19 ;
21 static char source_imported[] =
22 "MODULE Imported;"
23 "TYPE"
24 " Rider* = RECORD i, j, k : INTEGER; END;"
25 "VAR"
26 " i- : INTEGER;"
27 ""
28 "PROCEDURE Ln*;"
29 "END Ln;"
30 ""
31 "BEGIN;"
32 "END Imported."
33 ;
35 static oberon_context_t * ctx;
36 static oberon_module_t * mod;
38 static const char *
39 import_module(const char * name)
40 {
41 if(strcmp(name, "Test") == 0)
42 {
43 return source_test;
44 }
45 else if(strcmp(name, "Imported") == 0)
46 {
47 return source_imported;
48 }
49 else
50 {
51 return NULL;
52 }
53 }
55 int
56 main(int argc, char ** argv)
57 {
58 ctx = oberon_create_context(import_module);
59 mod = oberon_compile_module(ctx, source_test);
60 oberon_generate_code(ctx);
61 oberon_generator_dump(ctx, "dump.txt");
62 oberon_destroy_context(ctx);
63 return 0;
64 }