macrodelete_parser
[mala.git] / engine / engine.h
blobb5df8e5f62b6e92b3e35af295196ece254f825b6
1 /*
2 engine.h - MaLa core engine
4 Copyright (C) 2004, Christian Thaeter <chth@gmx.net>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License version 2 as
8 published by the Free Software Foundation.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, contact me.
20 #ifndef MALA_ENGINE_H
21 #define MALA_ENGINE_H
23 #include "mala_types.h"
24 #include "stringbucket.h"
25 #include "stringlist.h"
26 //#include "action.h"
28 enum mala_common_strings_enum
30 MALA_STRING_FALSE,
31 MALA_STRING_TRUE,
32 MALA_STRING_ZERO,
33 MALA_STRING_NULL,
34 MALA_STRING_EXCLAMATIONMARK,
35 MALA_STRING_ASSIGN,
36 MALA_STRING_BACKQUOTE,
37 MALA_STRING_NOT,
38 MALA_STRING_LITERAL,
39 MALA_STRING_ENVSUBST,
40 MALA_STRING_SETENV,
41 MALA_STRING_SECTION,
42 MALA_STRING_HERE,
43 MALA_STRING_BEGIN,
44 MALA_STRING_END,
45 MALA_STRING_DEL,
46 MALA_STRING_FLAG_LITERAL_EXPANSION,
47 MALA_STRING_FLAG_EXCLAM_EXPANSION,
48 MALA_STRING_FLAG_NO_EXPANSION,
49 MALA_STRING_FLAG_NUMSPLIT_EXPANSION,
50 MALA_STRING_FLAG_CHAR_EXPANSION,
51 MALA_STRING_FLAG_ASSIGN_EXPANSION,
52 MALA_STRING_FLAG_SETENV_EXPANSION,
53 MALA_STRING_FLAG_ENVVAR_EXPANSION,
54 MALA_STRING_FLAG_UNDERSCORE_EXPANSION,
55 MALA_STRING_FLAG_BRACKET_EXPANSION,
56 MALA_STRING_FLAG_ASSIGN_CONTRACTION,
57 MALA_STRING_ERROR_MISSING_ARGUMENT,
58 MALA_STRING_ERROR_MISSING_END,
59 MALA_MAX_COMMON_STRING
67 //#ifdef MALA_PRIVATE
68 struct mala_engine_struct
71 * every tokenized word is collected in 'words'
72 * actions can be bound to these words through the strings user variable
74 mala_stringbucket words;
75 mala_stringlist program;
76 mala_stringlist arguments;
78 MalaString common_string[MALA_MAX_COMMON_STRING];
80 /*TODO static ringbuffer char ringbuffer *[10] */
82 //const char * argv_0;
84 int negated:1;
86 /* --BEGIN ... --END blocks are translated to --BLOCK-xxxxxxxx macros,
87 where xxxxxxxx is a monotonic incrementing counter, its value is stored here */
88 unsigned blockcnt;
90 int state;
92 //#endif
95 \f/**/
100 * Mala engine
102 MalaEngine
103 mala_engine_new ();
105 #if 0
106 MalaEngine
107 mala_engine_new_main (int (*initfunc) (MalaEngine),
108 int argc, char ** argv,
109 mala_actioninit * actions_init);
110 #endif
112 void
113 mala_engine_free (MalaEngine self);
116 mala_engine_actions_register (MalaEngine, MalaActionInit);
119 mala_engine_exception (MalaEngine self,
120 MalaStringListNode_ref pptr,
121 MalaStringListNode here,
122 MalaString message);
125 mala_engine_macro_define (MalaEngine self, const char * name, int argc, char **argv);
128 mala_engine_pushback_word (MalaEngine self, const char * word);
130 MalaStringList
131 mala_engine_getprogram (MalaEngine self);
133 mala_state
134 mala_engine_state_get (MalaEngine self);
136 void
137 mala_engine_clearstate (MalaEngine self);
140 mala_engine_negated (MalaEngine self);
142 void
143 mala_engine_clear_negated (MalaEngine self);
145 void
146 mala_engine_dumpprogram (MalaEngine self, const char * prefix, const char * suffix);
148 void
149 mala_engine_dumpargs (MalaEngine self, const char * prefix, const char * suffix);
151 MalaEngine
152 mala_engine_run (MalaEngine self);
155 mala_engine_eval (MalaEngine self, MalaStringListNode_ref pptr);
157 //int
158 //mala_engine_expansions (MalaEngine self, MalaStringListNode_ref pptr);
162 mala_engine_string_istrue (MalaEngine self, MalaString str);
165 mala_engine_check_expansionflag (MalaEngine self, int flag);
169 mala_engine_expand (MalaEngine self, MalaStringList list, MalaStringListNode_ref pptr);
172 mala_engine_literal_expansion (MalaEngine self,
173 MalaStringList list,
174 MalaStringListNode_ref pptr);
177 mala_engine_backquote_expansion (MalaEngine self,
178 MalaStringList list,
179 MalaStringListNode_ref pptr);
182 mala_engine_numsplit_expansion (MalaEngine self,
183 MalaStringList list,
184 MalaStringListNode_ref pptr);
187 mala_engine_exclam_expansion (MalaEngine self,
188 MalaStringList list,
189 MalaStringListNode_ref pptr);
192 mala_engine_no_expansion (MalaEngine self,
193 MalaStringList list,
194 MalaStringListNode_ref pptr);
197 mala_engine_assign_expansion (MalaEngine self,
198 MalaStringList list,
199 MalaStringListNode_ref pptr);
202 mala_engine_envvar_expansion (MalaEngine self,
203 MalaStringList list,
204 MalaStringListNode_ref pptr);
207 mala_engine_char_expansion (MalaEngine self,
208 MalaStringList list,
209 MalaStringListNode_ref pptr);
212 mala_engine_underscore_expansion (MalaEngine self,
213 MalaStringList list,
214 MalaStringListNode_ref pptr);
216 int mala_engine_setenv_expansion (MalaEngine self,
217 MalaStringList list,
218 MalaStringListNode_ref pptr);
220 int mala_engine_bracket_expansion (MalaEngine self,
221 MalaStringList list,
222 MalaStringListNode_ref pptr);
224 int mala_engine_assign_contraction (MalaEngine self,
225 MalaStringList list,
226 MalaStringListNode_ref pptr);
229 mala_engine_add_action_cstr (MalaEngine self, const char* cname, void* data,
230 MalaParserFunc parser, MalaDataFactory factory,
231 MalaAction parent);
234 mala_engine_add_action (MalaEngine self, MalaString name, void* data,
235 MalaParserFunc parser, MalaDataFactory factory,
236 MalaAction parent);
238 void
239 mala_engine_try_eval_arg_n (MalaEngine self, MalaStringListNode_ref pptr, unsigned n);
242 #if 0 /*TODO*/
244 MalaEngine
245 mala_engine_new_initfunc (int (*initfunc) (MalaEngine));
249 void
250 mala_engine_pushfront_program (MalaEngine self, int args, char ** argv);
254 mala_engine_erase_action (MalaEngine, const t_uchar * key);
257 mala_engine_eval (MalaEngine self, LList pptr);
260 mala_engine_deepeval (MalaEngine self, LList pptr);
262 MalaEngine
263 mala_engine_run (MalaEngine);
265 mala_engine_exception (MalaEngine, LList begin, LList end, const char *);
267 MalaAction
268 mala_engine_action_new (MalaEngine, t_uchar** name, void** data,
269 MalaParserFunc parser, MalaDataDestructor destructor);
272 MalaAction
273 mala_engine_getaction (MalaEngine, const t_uchar * name);
275 MalaAction
276 mala_engine_getprevaction (MalaEngine, const t_uchar * name);
278 #endif /*TODO*/
284 #endif /*MALA_ENGINE_H*/
286 // Local Variables:
287 // mode: C
288 // c-file-style: "gnu"
289 // End:
290 // arch-tag: 47d718f6-e397-400c-93a6-bc71f475c0c7
291 // end_of_file