diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-04 08:34:13 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2011-07-04 08:34:13 +0200 |
commit | 71003f146cc2dacfa8fc7c084404f3399812b64a (patch) | |
tree | 52a6d19c4a7e7658718542f897ab4489d4360dc3 /grammar/utils.h | |
parent | 849e4aa8e6437cbfb6efbc7379414fcf517e6db9 (diff) | |
download | rsyslog-71003f146cc2dacfa8fc7c084404f3399812b64a.tar.gz rsyslog-71003f146cc2dacfa8fc7c084404f3399812b64a.tar.bz2 rsyslog-71003f146cc2dacfa8fc7c084404f3399812b64a.zip |
milestone: added operations to expr, added evaluation
Diffstat (limited to 'grammar/utils.h')
-rw-r--r-- | grammar/utils.h | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/grammar/utils.h b/grammar/utils.h index a402d4b2..f52bc1e0 100644 --- a/grammar/utils.h +++ b/grammar/utils.h @@ -62,18 +62,18 @@ struct cnfactlst { * be the sole foundation for the AST. */ struct cnfexpr { - int nodetype; + unsigned nodetype; struct cnfexpr *l; struct cnfexpr *r; }; struct cnfnumval { - int nodetype; + unsigned nodetype; long long val; }; struct cnfstringval { - int nodetype; + unsigned nodetype; es_str_t *estr; }; @@ -83,6 +83,16 @@ struct x { }; */ +/* the return value of an expresion evaluation */ +struct exprret { + union { + es_str_t *estr; + long long n; + } d; + char datatype; /* 'N' - number, 'S' - string */ +}; + + void readConfFile(FILE *fp, es_str_t **str); struct nvlst* nvlstNew(es_str_t *name, es_str_t *value); void nvlstDestruct(struct nvlst *lst); @@ -95,8 +105,9 @@ void cnfactlstDestruct(struct cnfactlst *actlst); void cnfactlstPrint(struct cnfactlst *actlst); struct cnfactlst* cnfactlstAddSysline(struct cnfactlst* actlst, char *line); struct cnfactlst* cnfactlstReverse(struct cnfactlst *actlst); -struct cnfexpr* cnfexprNew(int nodetype, struct cnfexpr *l, struct cnfexpr *r); +struct cnfexpr* cnfexprNew(unsigned nodetype, struct cnfexpr *l, struct cnfexpr *r); void cnfexprPrint(struct cnfexpr *expr, int indent); +void cnfexprEval(struct cnfexpr *expr, struct exprret *ret); struct cnfnumval* cnfnumvalNew(long long val); struct cnfstringval* cnfstringvalNew(es_str_t *estr); |