source: git/dyn_modules/modgen/modgen.h @ 6ce030f

spielwiese
Last change on this file since 6ce030f was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 6.9 KB
Line 
1/*
2 *
3 */
4
5#ifndef _MODGEN_H
6#define _MODGEN_H
7#define MOD_GEN_VERSION "0.3"
8
9#define BUFLEN 128
10#define TMPL_HEAD ""
11#define TMPL_FOOT ""
12
13#include <stdio.h>
14#include <string.h>
15
16/* Basic definitions */
17#ifndef BOOLEAN
18  typedef int BOOLEAN;
19#endif
20
21#ifndef TRUE
22#  define TRUE 1
23#endif
24
25#ifndef FALSE
26#  define FALSE 0
27#endif
28
29/*
30 * LANG_TOP     : Toplevel package only
31 * LANG_SINGULAR:
32 * LANG_C       :
33 */
34typedef enum { LANG_NONE, LANG_TOP, LANG_SINGULAR, LANG_C, LANG_MAX}
35  language_defs;
36
37/* id type */
38typedef int idtyp;
39
40
41
42class paramdef;
43class procdef;
44class moddef;
45class cfiles;
46class procflags;
47class stringdef;
48
49typedef paramdef * paramdefv;
50typedef procdef * procdefv;
51typedef cfiles * cfilesv;
52typedef moddef * moddefv;
53typedef procflags *procflagsv;
54typedef stringdef *stringdefv;
55
56class procflags {
57  public:
58  char start_of_code;
59  char declaration_done;
60  char typecheck_done;
61
62  char auto_header;
63  char do_declaration;
64  char do_typecheck;
65  char do_return;
66  char result_done;
67};
68
69class paramdef {
70 public:
71  char *name;
72  char *typname;
73  int  typ;
74  char *varname;
75};
76
77class procdef {
78 public:
79  char       * procname;
80  char       * funcname;
81  language_defs language;
82  int          lineno;
83  int          lineno_other;
84  int          is_static;
85  paramdef     return_val;
86  paramdefv    param;
87  int          paramcnt;
88  procflags    flags;
89  char       * c_code;
90  char       * help_string;
91  long         example_len;
92  char       * example_string;
93  long         sing_start;
94  long         sing_end;
95};
96
97class cfiles {
98  public:
99  cfilesv next;
100  char *filename;
101};
102
103class moddef {
104 public:
105  FILE * modfp;           /* module file */
106  FILE * modfp_h;         /* header file */
107  FILE * fmtfp;           /* temporary file */
108  FILE * fmtfp2;          /* temporary file */
109  FILE * fmtfp3;          /* temporary file */
110  FILE * binfp;           /* include singular procedures are stored
111                             in an extra file */
112  FILE * docfp;           /* help/example is stored in this file
113                             for building the reference manual */
114  char * filename;        /* inputfile to parse */
115  char * name;            /* name of the module directory*/
116  char * targetname;      /* name of dynamic module + package */
117  unsigned int major, minor, level;
118  char * version;
119  char * category;
120  char * revision;
121  char * info;
122  char * c_code;
123  procdefv procs;
124  int      proccnt;
125  cfilesv  files;
126  int      filecnt;
127};
128
129class stringdef
130{
131  public:
132  char *string;
133  int lineno;
134};
135
136typedef enum { VAR_UNKNOWN, VAR_BOOL, VAR_NUM, VAR_STRING,
137               VAR_FILE, VAR_FILES
138} var_type;
139
140typedef enum { CMD_NONE, CMD_BADSYNTAX, CMD_DECL, CMD_CHECK, CMD_RETURN,
141               CMD_SINGULAR, CMD_ERROR, CMD_NODECL
142} cmd_token;
143
144typedef enum { CMDT_SINGLE, CMDT_0, CMDT_ANY, CMDT_EQ
145} cmd_type;
146
147
148typedef enum { VAR_NONE, VAR_MODULE, VAR_HELP, VAR_INFO, VAR_VERSION,
149               VAR_TYPECHECK, VAR_RETURN, VAR_FUNCTION, VAR_CATEGORY
150} var_token;
151
152/*
153 *
154 */
155extern int modlineno;    /* lineno within module */
156extern int debug;
157extern int trace;
158extern int xyz;
159
160extern int IsCmd(char *n, int & tok);
161extern char * decl2str(int n, char *name);
162
163extern int myyyerror(char *fmt, ...);
164
165
166extern void PrintProclist(moddefv module);
167extern void generate_mod(moddefv module, int section);
168extern void mod_create_makefile(moddefv module);
169extern void Add2files(moddefv module, char *buff);
170
171extern void mod_copy_tmp(FILE *fp_out, FILE *fp_in);
172extern void mod_write_header(FILE *fp, char *module, char what);
173extern void generate_header(procdefv pi, FILE *fp);
174extern void write_header(FILE *fp, char *module, char *comment="");
175extern void make_version(char *p, moddefv module);
176extern void make_module_name(char *p, moddefv module);
177extern void write_procedure_text(moddefv module, int lineno);
178/*extern void write_procedure_header(moddefv module);*/
179
180extern int init_proc(procdefv p, char *procname, paramdefv ret, int line,
181                     language_defs language = LANG_C);
182extern void setup_proc(moddefv module, procdefv p);
183extern void proc_set_var(procdefv p, var_type type, var_token varid,
184                         char *varname, void *varvalue);
185void proc_set_default_var(var_type type, var_token varid, char *varname,
186                          void *varvalue);
187void write_finish_functions(moddefv module, procdefv proc);
188void AddParam(procdefv p, paramdefv vnew, char *name = NULL);
189
190/* from makefile.cc */
191extern void mod_create_makefile(moddefv module);
192extern void build_head_section(FILE *fp, moddefv module);
193extern void build_clean_section(FILE *fp, moddefv module);
194extern void build_install_section(FILE *fp, moddefv module);
195static char *object_name(char *p);
196extern void build_compile_section(FILE *fp, moddefv module);
197
198/* from utils.cc */
199extern int create_tmpfile(moddefv module_def, int which = 0);
200extern char *build_filename(moddefv module, char *text, int what);
201extern unsigned long crccheck(char *file);
202extern void write_crccheck(FILE *fp);
203extern void write_crctable(FILE *fp);
204
205/* from proc_setup.cc */
206extern int check_reseverd(char *name);
207
208/* from proc.cc */
209extern void write_function_header(moddefv module, procdefv proc);
210extern void write_procedure_typecheck(moddefv module, procdefv pi, FILE *fmtfp);
211extern void write_procedure_return(moddefv module, procdefv pi, FILE *fmtfp);
212extern void write_function_declaration(moddefv module, procdefv pi, void *arg = NULL);
213extern void write_function_nodecl(moddefv module, procdefv pi, void *arg = NULL);
214extern void write_function_error(moddefv module, procdefv pi, void *arg = NULL);
215extern void write_function_typecheck(moddefv module, procdefv pi, void *arg = NULL);
216extern void write_function_result(moddefv module, procdefv pi, void *arg = NULL);
217extern void write_function_return(moddefv module, procdefv pi, void *arg = NULL);
218extern void write_function_singularcmd(moddefv module, procdefv pi, void *arg = NULL);
219extern void write_function_errorhandling(moddefv module, procdefv pi);
220extern void write_help(moddefv module, procdefv pi);
221extern void write_example(moddefv module, procdefv pi);
222extern int  write_singular_procedures(moddefv module, procdefv proc);
223extern void write_singular_parameter(moddefv module,int lineno,
224                                     char *typname, char *varname);
225extern void write_singular_end(moddefv module, procdefv proc,int lineno);
226extern int write_helpfile_help(moddefv module, procdefv proc);
227
228extern void write_codeline(moddefv module, procdefv proc,
229                           char *line, int lineno = -1);
230
231/* from misc.cc */
232extern cmd_token checkcmd(
233  char *cmdname,
234  void(**write_cmd)(moddefv module, procdefv pi, void *arg),
235  cmd_type  type,
236  int args);
237extern var_token checkvar(
238  char *varname, var_type type,
239  void (**write_cmd)(moddefv module, var_token type, idtyp t,
240                     void *arg1, void *arg2));
241void write_main_variable(moddefv module, var_token type,
242                         idtyp t, void *arg1, void *arg2);
243
244#endif /* _MODGEN_H */
Note: See TracBrowser for help on using the repository browser.