DEADSOFTWARE

f1b175cf476d22f404de648888f0d39e45c9de81
[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 "(* Main module *)"
9 "MODULE Test;"
10 "IMPORT I := Imported;"
11 "VAR"
12 " x, y : I.Rider;"
13 "PROCEDURE Proc(x, y, z : INTEGER);"
14 "BEGIN"
15 " x := 1;"
16 "END Proc;"
17 "BEGIN;"
18 " y.i := 1;"
19 " I.a[0] := 1;"
20 "END Test."
21 ;
23 static char source_imported[] =
24 "MODULE Imported;"
25 "TYPE"
26 " Rider* = RECORD i*, j-, k : INTEGER; END;"
27 "VAR"
28 " i- : INTEGER;"
29 " a* : ARRAY 3 OF INTEGER;"
30 ""
31 "PROCEDURE Ln*;"
32 "END Ln;"
33 ""
34 "BEGIN;"
35 " i := 1;"
36 " a[0] := 555;"
37 "END Imported."
38 ;
40 static oberon_context_t * ctx;
41 static oberon_module_t * mod;
43 static const char *
44 import_module(const char * name)
45 {
46 if(strcmp(name, "Test") == 0)
47 {
48 return source_test;
49 }
50 else if(strcmp(name, "Imported") == 0)
51 {
52 return source_imported;
53 }
54 else
55 {
56 return NULL;
57 }
58 }
60 int
61 main(int argc, char ** argv)
62 {
63 ctx = oberon_create_context(import_module);
64 mod = oberon_compile_module(ctx, source_test);
65 oberon_generate_code(ctx);
66 oberon_generator_dump(ctx, "dump.txt");
67 oberon_destroy_context(ctx);
68 return 0;
69 }