exception fix
[mala.git] / engine / engine.h
blobcf469b4d3d0f2aeb4b7d6573acfa78850ffc40db
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_FLAG_LITERAL_EXPANSION,
44 MALA_STRING_FLAG_EXCLAM_EXPANSION,
45 MALA_STRING_FLAG_NO_EXPANSION,
46 MALA_STRING_FLAG_NUMSPLIT_EXPANSION,
47 MALA_STRING_FLAG_CHAR_EXPANSION,
48 MALA_STRING_FLAG_ASSIGN_EXPANSION,
49 MALA_STRING_FLAG_SETENV_EXPANSION,
50 MALA_STRING_FLAG_ENVVAR_EXPANSION,
51 MALA_STRING_FLAG_UNDERSCORE_EXPANSION,
52 MALA_STRING_FLAG_BRACKET_EXPANSION,
53 MALA_STRING_FLAG_ASSIGN_CONTRACTION,
54 MALA_STRING_ERROR_MISSING_ARGUMENT,
55 MALA_MAX_COMMON_STRING
63 //#ifdef MALA_PRIVATE
64 struct mala_engine_struct
67 * every tokenized word is collected in 'words'
68 * actions can be bound to these words through the strings user variable
70 mala_stringbucket words;
71 mala_stringlist program;
72 mala_stringlist arguments;
74 MalaString common_string[MALA_MAX_COMMON_STRING];
76 /*TODO static ringbuffer char ringbuffer *[10] */
78 const char * argv_0;
80 int negated:1;
82 int state;
84 //#endif
87 \f/**/
92 * Mala engine
94 MalaEngine
95 mala_engine_new ();
97 #if 0
98 MalaEngine
99 mala_engine_new_main (int (*initfunc) (MalaEngine),
100 int argc, char ** argv,
101 mala_actioninit * actions_init);
102 #endif
104 void
105 mala_engine_free (MalaEngine self);
108 mala_engine_actions_register (MalaEngine, MalaActionInit);
111 mala_engine_exception (MalaEngine self,
112 MalaStringListNode_ref pptr,
113 MalaStringListNode here,
114 MalaString message);
117 mala_engine_macro_define (MalaEngine self, const char * name, int argc, char **argv);
120 mala_engine_pushback_word (MalaEngine self, const char * word);
122 MalaStringList
123 mala_engine_getprogram (MalaEngine self);
125 mala_state
126 mala_engine_state_get (MalaEngine self);
128 void
129 mala_engine_clearstate (MalaEngine self);
132 mala_engine_negated (MalaEngine self);
134 void
135 mala_engine_clear_negated (MalaEngine self);
137 void
138 mala_engine_dumpprogram (MalaEngine self, const char * prefix, const char * suffix);
140 void
141 mala_engine_dumpargs (MalaEngine self, const char * prefix, const char * suffix);
143 MalaEngine
144 mala_engine_run (MalaEngine self);
147 mala_engine_eval (MalaEngine self, MalaStringListNode_ref pptr);
149 //int
150 //mala_engine_expansions (MalaEngine self, MalaStringListNode_ref pptr);
154 mala_engine_string_istrue (MalaEngine self, MalaString str);
157 mala_engine_check_expansionflag (MalaEngine self, int flag);
161 mala_engine_expand (MalaEngine self, MalaStringList list, MalaStringListNode_ref pptr);
164 mala_engine_literal_expansion (MalaEngine self,
165 MalaStringList list,
166 MalaStringListNode_ref pptr);
169 mala_engine_backquote_expansion (MalaEngine self,
170 MalaStringList list,
171 MalaStringListNode_ref pptr);
174 mala_engine_numsplit_expansion (MalaEngine self,
175 MalaStringList list,
176 MalaStringListNode_ref pptr);
179 mala_engine_exclam_expansion (MalaEngine self,
180 MalaStringList list,
181 MalaStringListNode_ref pptr);
184 mala_engine_no_expansion (MalaEngine self,
185 MalaStringList list,
186 MalaStringListNode_ref pptr);
189 mala_engine_assign_expansion (MalaEngine self,
190 MalaStringList list,
191 MalaStringListNode_ref pptr);
194 mala_engine_envvar_expansion (MalaEngine self,
195 MalaStringList list,
196 MalaStringListNode_ref pptr);
199 mala_engine_char_expansion (MalaEngine self,
200 MalaStringList list,
201 MalaStringListNode_ref pptr);
204 mala_engine_underscore_expansion (MalaEngine self,
205 MalaStringList list,
206 MalaStringListNode_ref pptr);
208 int mala_engine_setenv_expansion (MalaEngine self,
209 MalaStringList list,
210 MalaStringListNode_ref pptr);
212 int mala_engine_bracket_expansion (MalaEngine self,
213 MalaStringList list,
214 MalaStringListNode_ref pptr);
216 int mala_engine_assign_contraction (MalaEngine self,
217 MalaStringList list,
218 MalaStringListNode_ref pptr);
221 mala_engine_add_action (MalaEngine self, const char* name, void* data,
222 MalaParserFunc parser, MalaDataFactory factory,
223 MalaAction parent);
227 #if 0 /*TODO*/
229 MalaEngine
230 mala_engine_new_initfunc (int (*initfunc) (MalaEngine));
234 void
235 mala_engine_pushfront_program (MalaEngine self, int args, char ** argv);
239 mala_engine_erase_action (MalaEngine, const t_uchar * key);
242 mala_engine_eval (MalaEngine self, LList pptr);
245 mala_engine_deepeval (MalaEngine self, LList pptr);
247 MalaEngine
248 mala_engine_run (MalaEngine);
250 mala_engine_exception (MalaEngine, LList begin, LList end, const char *);
252 MalaAction
253 mala_engine_action_new (MalaEngine, t_uchar** name, void** data,
254 MalaParserFunc parser, MalaDataDestructor destructor);
257 MalaAction
258 mala_engine_getaction (MalaEngine, const t_uchar * name);
260 MalaAction
261 mala_engine_getprevaction (MalaEngine, const t_uchar * name);
263 #endif /*TODO*/
269 #endif /*MALA_ENGINE_H*/
271 // Local Variables:
272 // mode: C
273 // c-file-style: "gnu"
274 // End:
275 // arch-tag: 47d718f6-e397-400c-93a6-bc71f475c0c7
276 // end_of_file