Rudiments
compiler.h
1 // Copyright (c) 2015 David Muse
2 // See the COPYING file for more information.
3 
4 #ifndef RUDIMENTS_COMPILER_H
5 #define RUDIMENTS_COMPILER_H
6 
7 #include <rudiments/private/compilerincludes.h>
8 
9 class compilerprivate;
10 class compilermodule;
12 class compilerprocessor;
14 
64 class RUDIMENTS_DLLSPEC compiler {
65  public:
66 
68  compiler();
69 
71  virtual ~compiler();
72 
73 
76  void appendModulePath(const char *path);
77 
79  void clearModulePaths();
80 
82  linkedlist< char * > *getModulePaths();
83 
84 
87  void appendPreProcessor(compilerpreprocessor *module);
88 
95  bool appendPreProcessor(const char *filename,
96  const char *classname,
97  const char *id,
98  xmldomnode *parameters);
99 
106  bool appendPreProcessor(const char *filename,
107  const char *classname,
108  const char *id,
109  const char *parameters);
110 
112  void clearPreProcessors();
113 
115  linkedlist< compilermodule * > *getPreProcessors();
116 
117 
118 
121  void appendProcessor(compilerprocessor *module);
122 
129  bool appendProcessor(const char *filename,
130  const char *classname,
131  const char *id,
132  xmldomnode *parameters);
133 
140  bool appendProcessor(const char *filename,
141  const char *classname,
142  const char *id,
143  const char *parameters);
144 
146  void clearProcessors();
147 
149  linkedlist< compilermodule * > *getProcessors();
150 
151 
152 
155  void appendPostProcessor(compilerpostprocessor *module);
156 
163  bool appendPostProcessor(const char *filename,
164  const char *classname,
165  const char *id,
166  xmldomnode *parameters);
167 
174  bool appendPostProcessor(const char *filename,
175  const char *classname,
176  const char *id,
177  const char *parameters);
178 
180  void clearPostProcessors();
181 
183  linkedlist< compilermodule * > *getPostProcessors();
184 
185 
186 
190  bool setInputGrammar(const char *grammar,
191  const char *startsymbol);
192 
195  bool setOutputGrammar(const char *grammar);
196 
197 
198 
213  void setMetaData(xmldomnode *metadata);
214 
215 
231  bool compile(const char *input, stringbuffer *output);
232 
233 
245  bool process(xmldomnode *root);
246 
247 
249  const char *getError();
250 
251 
253  void setDebugLevel(uint8_t debuglevel);
254 
255  #include <rudiments/private/compiler.h>
256 };
257 
258 
259 
263 class RUDIMENTS_DLLSPEC compilermodule {
264  public:
266  compilermodule();
267 
269  virtual ~compilermodule();
270 
272  void setId(const char *id);
273 
275  bool setParameters(const char *parameters);
276 
278  void setParameters(xmldomnode *parameters);
279 
281  const char *getId();
282 
284  xmldomnode *getParameters();
285 
286  protected:
287  const char *id;
288  xmldomnode *parameters;
289 
290  private:
291  xmldom *xmld;
292 };
293 
294 
302 class RUDIMENTS_DLLSPEC compilerpreprocessor : public compilermodule {
303  public:
306 
308  virtual ~compilerpreprocessor();
309 
314  virtual bool process(const char *input,
315  stringbuffer *output,
316  xmldomnode *metadata)=0;
317 };
318 
319 
327 class RUDIMENTS_DLLSPEC compilerprocessor : public compilermodule {
328  public:
331 
333  virtual ~compilerprocessor();
334 
339  virtual bool process(xmldomnode *tree,
340  xmldomnode *metadata)=0;
341 };
342 
343 
352 class RUDIMENTS_DLLSPEC compilerpostprocessor : public compilermodule {
353  public:
357 
359  virtual ~compilerpostprocessor();
360 
365  virtual bool process(const char *input,
366  stringbuffer *output,
367  xmldomnode *metadata)=0;
368 };
369 
370 #endif
Definition: xmldomnode.h:123
Definition: linkedlist.h:60
Definition: stringbuffer.h:22
Definition: compiler.h:327
Definition: process.h:19
Definition: compiler.h:352
Definition: compiler.h:64
Definition: compiler.h:263
Definition: compiler.h:302
Definition: xmldom.h:12