if_parser fix
[mala.git] / engine / mala_types.h
blobad9d83ff1e5754fcf88a4f2228a58390cc6d83c2
1 /*
2 stringbucket.h - MaLa stringbuckets
4 Copyright (C) 2004, 2005, 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_TYPES_H
21 #define MALA_TYPES_H
23 #include <assert.h>
24 #include <sys/queue.h>
26 #ifdef DEBUG_MALA
27 #include <stdio.h>
28 #define MALA_ASSERT(exp) assert(exp)
29 /*#define MALA_DEBUG(fmt, ...) do{fprintf(stderr,"MALA_DEBUG: %s: %d: %s: " fmt "\n", strrchr(__FILE__, '/')+1, __LINE__, __func__, ## __VA_ARGS__);}while(0)
31 #else
32 #define MALA_ASSERT(exp)
33 //#define MALA_DEBUG(fmt,...)
34 #endif
38 * mala state codes
40 #define MALA_STATES \
41 /* the first codes are the states of the MaLa VM and never returned from the engine*/ \
42 MALA_STATE(SUCCESS), /* last comand returned true */ \
43 MALA_STATE(FAILURE), /* last comand returned false */ \
44 MALA_STATE(LITERAL), /* dont evaluate argument */ \
45 MALA_STATE(CONTINUE), /* command not fully evaluated yet */ \
46 MALA_STATE(REMOVE), /* no sideeffects remove arguments */ \
47 MALA_STATE(EXCEPTION), /* some error occured (in MaLa code) */ \
49 MALA_STATE(EFAULT), /* beyond are runtime errors */ \
50 MALA_STATE(ENOACTION), /* no action found, exception falltrough */ \
51 MALA_STATE(EACTIONUSED), /* action has childs or is linked to an engine */ \
52 MALA_STATE(ESYNTAX), /* Syntax error in expansion */ \
53 MALA_STATE(EINCOMPLETE), /* interrupted in interactive mode */ \
55 MALA_STATE(EFATAL), /* beyond are fatal errors */ \
56 MALA_STATE(EINIT), /* initialization didnt complete */ \
57 MALA_STATE(EALLOC), /* memory allocation problem */ \
58 MALA_STATE(ENOENV), /* no environment space left */ \
59 MALA_STATE(EPARSER), /* parser wrong or missing */ \
61 MALA_STATE(EINVALID), /* something is really wrong */ \
63 /* state codes for the preprocessor */ \
64 MALA_STATE(NO_EXPANSION), /* nothing expanded */ \
65 MALA_STATE(EXPANSION_ERROR), /* error in engine->state */ \
66 MALA_STATE(STATE_TABLE_SIZEOF)
69 #define MALA_STATE(s) MALA_##s
70 enum mala_state_enum
72 MALA_STATES
74 #undef MALA_STATE
76 typedef enum mala_state_enum mala_state;
81 * datastructure and handle declarations
83 #define MALA_TYPEDEFS(name,Handle) \
84 typedef struct mala_##name##_struct mala_##name;\
85 typedef const mala_##name * const_Mala##Handle;\
86 typedef mala_##name * Mala##Handle;\
87 typedef mala_##name ** Mala##Handle##_ref;\
88 typedef const mala_##name ** const_Mala##Handle##_ref
90 MALA_TYPEDEFS(actioninit,ActionInit);
91 MALA_TYPEDEFS(action,Action);
92 MALA_TYPEDEFS(string,String);
93 MALA_TYPEDEFS(stringbucket,StringBucket);
94 MALA_TYPEDEFS(engine,Engine);
95 MALA_TYPEDEFS(actiondesc,ActionDesc);
97 CIRCLEQ_HEAD (mala_stringlist_struct, mala_stringlistnode_struct);
98 MALA_TYPEDEFS(stringlistnode,StringListNode);
99 MALA_TYPEDEFS(stringlist,StringList);
101 LIST_HEAD(mala_actionstack_struct, mala_action_struct);
102 MALA_TYPEDEFS(actionstack,ActionStack);
104 LIST_HEAD(mala_childstack_struct, mala_action_struct);
105 MALA_TYPEDEFS(childstack,ChildStack);
109 typedef int (*MalaPredicate) (void* value, void * constraint);
110 typedef void* (*MalaDataFactory) (void** dest, const void* src, MalaStringBucket bucket);
111 typedef int (*MalaParserFunc) (MalaEngine eng,
112 MalaStringListNode_ref pptr,
113 void * data);
114 int (*MalaEngineInit) (MalaEngine self);
116 #define MALA_SIDEEFFECT_BEGIN if (eng->state != MALA_REMOVE)
117 #define MALA_SIDEEFFECT_END
119 #endif /* MALA_TYPES_H */
122 // Local Variables:
123 // mode: C
124 // c-file-style: "gnu"
125 // End:
126 // arch-tag: ee20274c-3a62-4022-a312-59572f1ffdb9
127 // end_of_file