1 | /* |
---|
2 | * |
---|
3 | */ |
---|
4 | |
---|
5 | #include <stdio.h> |
---|
6 | #include <stddef.h> |
---|
7 | #include <stdlib.h> |
---|
8 | #include <stdarg.h> |
---|
9 | #include <string.h> |
---|
10 | #include <limits.h> |
---|
11 | |
---|
12 | #include "modgen.h" |
---|
13 | #include "stype.h" |
---|
14 | |
---|
15 | /* |
---|
16 | * Syntax of a module file: |
---|
17 | * %{ |
---|
18 | * //here may come c/C++ code |
---|
19 | * %} |
---|
20 | * // start of section 1 |
---|
21 | * module="module-name"; |
---|
22 | * version=""; |
---|
23 | * info=""; |
---|
24 | * |
---|
25 | * cxxsource=misc.cc |
---|
26 | * |
---|
27 | * %% start of section 2 |
---|
28 | * |
---|
29 | * proc [<return-type>] <procname>[(argtypelist)] { |
---|
30 | * |
---|
31 | * } |
---|
32 | * |
---|
33 | * %% start of section 3 |
---|
34 | * // some other c/C++ code |
---|
35 | * |
---|
36 | */ |
---|
37 | |
---|
38 | /* |
---|
39 | * How does the module generator works: |
---|
40 | * 1. start parsing the module-definition file |
---|
41 | * 1.1 write c/C++ code into a temporary file |
---|
42 | * 1.2 get modulename in section 1 |
---|
43 | * 2 arrived at the beginnig of section |
---|
44 | * 2.1 write header of .cc and .h files |
---|
45 | * 2.2 append tmpfile to .cc file |
---|
46 | * 2.3 parse section 2 |
---|
47 | * 3. generate code for each proc definition |
---|
48 | * 4. append section 3 to .cc file |
---|
49 | * 5. generate Makefile |
---|
50 | * 6. finished |
---|
51 | */ |
---|
52 | |
---|
53 | extern FILE* yyin; |
---|
54 | extern int yylineno; |
---|
55 | extern char *yytext; |
---|
56 | |
---|
57 | moddef module_def; |
---|
58 | |
---|
59 | int init_modgen( |
---|
60 | moddefv module_def, |
---|
61 | char *filename |
---|
62 | ); |
---|
63 | |
---|
64 | extern int yyparse (void); |
---|
65 | |
---|
66 | main( int argc, char *argv[] ) |
---|
67 | { |
---|
68 | int i; |
---|
69 | |
---|
70 | if ( argc > 1 ) |
---|
71 | yyin = fopen( argv[1], "rb" ); |
---|
72 | else { |
---|
73 | printf("no filename given\n"); |
---|
74 | printf("usage: %s <filename>.mod\n", argv[0]); |
---|
75 | return 1; |
---|
76 | } |
---|
77 | |
---|
78 | if(init_modgen(&module_def, argv[1])) return 1; |
---|
79 | do { |
---|
80 | i=yyparse(); |
---|
81 | if(i)printf("NEXT LOOP at line %d (%s) %d\n", yylineno, yytext, i); |
---|
82 | } |
---|
83 | while (i); |
---|
84 | printf("ENDE\n"); |
---|
85 | |
---|
86 | //fflush(module_def.fmtfp); |
---|
87 | //PrintProclist(&module_def); |
---|
88 | //generate_mod(&module_def, 2); |
---|
89 | //mod_create_makefile(&module_def); |
---|
90 | fclose(module_def.fmtfp); |
---|
91 | } |
---|