Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AUDACIOUS_TUPLE_COMPILER_H
00021 #define AUDACIOUS_TUPLE_COMPILER_H
00022
00023 #include <glib.h>
00024 #include <mowgli.h>
00025 #include "tuple.h"
00026
00027 G_BEGIN_DECLS
00028
00029 #define TUPLEZ_MAX_VARS (4)
00030
00031
00032 enum {
00033 OP_RAW = 0,
00034 OP_FIELD,
00035 OP_EXISTS,
00036 OP_DEF_STRING,
00037 OP_DEF_INT,
00038 OP_EQUALS,
00039 OP_NOT_EQUALS,
00040 OP_GT,
00041 OP_GTEQ,
00042 OP_LT,
00043 OP_LTEQ,
00044 OP_IS_EMPTY,
00045
00046 OP_FUNCTION,
00047 OP_EXPRESSION
00048 };
00049
00050
00051 enum {
00052 TUPLE_VAR_FIELD = 0,
00053 TUPLE_VAR_CONST,
00054 TUPLE_VAR_DEF
00055 };
00056
00057
00058
00059
00060 typedef struct {
00061 gchar *name;
00062 gboolean istemp;
00063 gint type;
00064 gchar *defvals;
00065 gint defvali;
00066 TupleValueType ctype;
00067
00068 gint fieldidx;
00069 TupleValue *fieldref;
00070 } TupleEvalVar;
00071
00072
00073 typedef struct {
00074 gchar *name;
00075 gboolean isdeterministic;
00076 gchar *(*func)(Tuple *tuple, TupleEvalVar **argument);
00077 } TupleEvalFunc;
00078
00079
00080 typedef struct _TupleEvalNode {
00081 gint opcode;
00082 gint var[TUPLEZ_MAX_VARS];
00083 gboolean global[TUPLEZ_MAX_VARS];
00084 gchar *text;
00085 gint function, expression;
00086 struct _TupleEvalNode *children, *next, *prev;
00087 } TupleEvalNode;
00088
00089
00090 typedef struct {
00091 gint nvariables, nfunctions, nexpressions;
00092 TupleEvalVar **variables;
00093 TupleEvalFunc **functions;
00094
00095
00096 gboolean iserror;
00097 gchar *errmsg;
00098 } TupleEvalContext;
00099
00100
00101 TupleEvalContext * tuple_evalctx_new(void);
00102 void tuple_evalctx_reset(TupleEvalContext *ctx);
00103 void tuple_evalctx_free(TupleEvalContext *ctx);
00104 gint tuple_evalctx_add_var(TupleEvalContext *ctx, const gchar *name, const gboolean istemp, const gint type, const TupleValueType ctype);
00105
00106 void tuple_evalnode_free(TupleEvalNode *expr);
00107
00108 gint tuple_formatter_print(FILE *f, gint *level, TupleEvalContext *ctx, TupleEvalNode *expr);
00109 TupleEvalNode *tuple_formatter_compile(TupleEvalContext *ctx, gchar *expr);
00110 gchar * tuple_formatter_eval (TupleEvalContext * ctx, TupleEvalNode * expr,
00111 const Tuple * tuple);
00112
00113
00114 G_END_DECLS
00115
00116 #endif