DEADSOFTWARE

Добавлены модули
[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 "TYPE"
11 " Callback = PROCEDURE() : INTEGER;"
12 ""
13 "VAR"
14 " cb : Callback;"
15 " i : INTEGER;"
16 " r : I.Rider;"
17 ""
18 "PROCEDURE RelBack;"
19 "BEGIN"
20 " i := 666;"
21 "END RelBack;"
22 ""
23 "BEGIN;"
24 " i := ABS(-1);"
25 " i := cb();"
26 " RelBack;"
27 " I.Ln;"
28 "END Test."
29 ;
31 static char source_imported[] =
32 "MODULE Imported;"
33 "TYPE"
34 " Rider = RECORD i : INTEGER; END;"
35 ""
36 "PROCEDURE Ln;"
37 "END Ln;"
38 ""
39 "BEGIN;"
40 "END Imported."
41 ;
43 static oberon_context_t * ctx;
44 static oberon_module_t * mod;
46 static const char *
47 import_module(const char * name)
48 {
49 if(strcmp(name, "Test") == 0)
50 {
51 return source_test;
52 }
53 else if(strcmp(name, "Imported") == 0)
54 {
55 return source_imported;
56 }
57 else
58 {
59 return NULL;
60 }
61 }
63 int
64 main(int argc, char ** argv)
65 {
66 ctx = oberon_create_context(import_module);
67 mod = oberon_compile_module(ctx, source_test);
68 oberon_generate_code(ctx);
69 oberon_generator_dump(ctx, "dump.txt");
70 oberon_destroy_context(ctx);
71 return 0;
72 }