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.
24 #include <sys/queue.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)
32 #define MALA_ASSERT(exp)
33 //#define MALA_DEBUG(fmt,...)
42 /* the first codes are the states of the MaLa VM and never returned from the engine*/
43 MALA_SUCCESS
, /* last comand returned true */
44 MALA_FAILURE
, /* last comand returned false */
45 MALA_EXCEPTION
, /* some error occured (in MaLa code) */
46 MALA_LITERAL
, /* dont evaluate argument */
47 MALA_DELAY
, /* delay evaluation of the command */
49 MALA_EFAULT
, /* everything beyond are runtime errors, which may be handled by the userprogram */
50 MALA_ENOACTION
, /* no action found, exception falltrough */
51 MALA_EACTIONUSED
, /* action has childs or is linked to an engine */
52 MALA_ESYNTAX
, /* Syntax error in expansion (missing '}', ']', illegal characters)*/
53 MALA_EINCOMPLETE
, /* interrupted in interactive mode */
55 MALA_EFATAL
, /* everything beyond are fatal errors which leave the VM in a undefined state */
56 MALA_EINIT
, /* initialization didnt complete */
57 MALA_EALLOC
, /* memory allocation problem */
58 MALA_ENOENV
, /* no environment space left */
59 MALA_ESTALEACT
, /* there is an action which dont remove itself from the program */
60 MALA_EPARSER
, /* parser wrong or missing*/
62 MALA_EINVALID
, /* something is really wrong (even a mala_engine_free() might crash)*/
64 // state codes for the preprocessor
65 MALA_NO_EXPANSION
= -1, /* nothing expanded */
66 MALA_EXPANSION_ERROR
= -2 /* error in engine->state */
69 typedef enum mala_state_enum mala_state
;
74 * datastructure and handle declarations
76 #define MALA_TYPEDEFS(name,Handle) \
77 typedef struct mala_##name##_struct mala_##name;\
78 typedef const mala_##name * const_Mala##Handle;\
79 typedef mala_##name * Mala##Handle;\
80 typedef mala_##name ** Mala##Handle##_ref;\
81 typedef const mala_##name ** const_Mala##Handle##_ref
83 MALA_TYPEDEFS(actioninit
,ActionInit
);
84 MALA_TYPEDEFS(action
,Action
);
85 MALA_TYPEDEFS(string
,String
);
86 MALA_TYPEDEFS(stringbucket
,StringBucket
);
87 MALA_TYPEDEFS(engine
,Engine
);
88 MALA_TYPEDEFS(actiondesc
,ActionDesc
);
90 CIRCLEQ_HEAD (mala_stringlist_struct
, mala_stringlistnode_struct
);
91 MALA_TYPEDEFS(stringlistnode
,StringListNode
);
92 MALA_TYPEDEFS(stringlist
,StringList
);
94 LIST_HEAD(mala_actionstack_struct
, mala_action_struct
);
95 MALA_TYPEDEFS(actionstack
,ActionStack
);
97 LIST_HEAD(mala_childstack_struct
, mala_action_struct
);
98 MALA_TYPEDEFS(childstack
,ChildStack
);
102 typedef void* (*MalaDataFactory
)(void** dest
, const void* src
, MalaStringBucket bucket
);
103 typedef int (*MalaParserFunc
) (MalaEngine eng
,
104 MalaStringListNode_ref pptr
,
106 int (*MalaEngineInit
) (MalaEngine self
);
110 #endif /* MALA_TYPES_H */
115 // c-file-style: "gnu"
117 // arch-tag: ee20274c-3a62-4022-a312-59572f1ffdb9