stringlib refactoring
[mala.git] / engine / engine.h
blobf4fb6f123d741c8db9c3465a4faa835b8651e6c4
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_EXCLAMATIONMARK,
34 MALA_STRING_NOT,
35 MALA_STRING_FLAG_EXCLAM_EXPANSION,
36 MALA_STRING_FLAG_NO_EXPANSION,
37 MALA_STRING_FLAG_NUMSPLIT_EXPANSION,
38 MALA_STRING_FLAG_CHAR_EXPANSION,
39 MALA_STRING_FLAG_ASSIGN_EXPANSION,
40 MALA_STRING_FLAG_SETENV_EXPANSION,
41 MALA_STRING_FLAG_ENVVAR_EXPANSION,
42 MALA_STRING_FLAG_UNDERSCORE_EXPANSION,
43 MALA_STRING_FLAG_BRACKET_EXPANSION,
44 MALA_STRING_FLAG_ASSIGN_CONTRACTION,
45 MALA_MAX_COMMON_STRING
53 //#ifdef MALA_PRIVATE
54 struct mala_engine_struct
57 * every tokenized word is collected in 'words'
58 * actions can be bound to these words through the strings user variable
60 mala_stringbucket words;
61 mala_stringlist program;
62 mala_stringlist arguments;
64 MalaString common_string[MALA_MAX_COMMON_STRING];
66 /*TODO static ringbuffer char ringbuffer *[10] */
68 const char * argv_0;
70 int negated:1;
72 int state;
74 //#endif
77 \f/**/
85 * Mala engine
87 MalaEngine
88 mala_engine_new_main (int (*initfunc) (MalaEngine),
89 int argc, char ** argv,
90 mala_actioninit * actions_init);
93 void
94 mala_engine_free (MalaEngine self);
96 int
97 mala_engine_register_actions (MalaEngine, MalaActionInit);
99 int
100 mala_engine_pushback_program (MalaEngine self, int args, char ** argv);
102 MalaStringList
103 mala_engine_getprogram (MalaEngine self);
105 mala_state
106 mala_engine_state_get (MalaEngine self);
108 void
109 mala_engine_clearstate (MalaEngine self);
112 mala_engine_negated (MalaEngine self);
114 void
115 mala_engine_clear_negated (MalaEngine self);
117 void
118 mala_engine_dumpprogram (MalaEngine self, const char * prefix, const char * suffix);
120 void
121 mala_engine_dumpargs (MalaEngine self, const char * prefix, const char * suffix);
123 MalaEngine
124 mala_engine_run (MalaEngine self);
127 mala_engine_eval (MalaEngine self, MalaStringListNode_ref pptr);
129 //int
130 //mala_engine_expansions (MalaEngine self, MalaStringListNode_ref pptr);
134 mala_engine_string_istrue (MalaEngine self, MalaString str);
137 mala_engine_check_expansionflag (MalaEngine self, int flag);
140 #if 0 /*TODO*/
142 MalaEngine
143 mala_engine_new_initfunc (int (*initfunc) (MalaEngine));
147 void
148 mala_engine_pushfront_program (MalaEngine self, int args, const char ** argv);
151 mala_engine_add_action (MalaEngine self, const t_uchar* key, void* data,
152 MalaParserFunc, MalaDataDestructor);
155 mala_engine_erase_action (MalaEngine, const t_uchar * key);
158 mala_engine_eval (MalaEngine self, LList pptr);
161 mala_engine_deepeval (MalaEngine self, LList pptr);
163 MalaEngine
164 mala_engine_run (MalaEngine);
166 mala_engine_exception (MalaEngine, LList begin, LList end, const char *);
168 MalaAction
169 mala_engine_action_new (MalaEngine, t_uchar** name, void** data,
170 MalaParserFunc parser, MalaDataDestructor destructor);
173 mala_engine_check_expansionflag (MalaEngine self, const t_uchar * name);
175 MalaAction
176 mala_engine_getaction (MalaEngine, const t_uchar * name);
178 MalaAction
179 mala_engine_getprevaction (MalaEngine, const t_uchar * name);
181 #endif /*TODO*/
187 #endif /*MALA_ENGINE_H*/
189 // Local Variables:
190 // mode: C
191 // c-file-style: "gnu"
192 // End:
193 // arch-tag: 47d718f6-e397-400c-93a6-bc71f475c0c7
194 // end_of_file