This is just a naming change.
definition:
DEFINE CF_SYM_VOID '=' term ';' {
struct f_val *val = cfg_alloc(sizeof(struct f_val));
- if (f_eval(f_postfixify($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error");
+ if (f_eval(f_linearize($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error");
cf_define_symbol($2, SYM_CONSTANT | val->type, val, val);
}
;
expr:
NUM
- | '(' term ')' { $$ = f_eval_int(f_postfixify($2)); }
+ | '(' term ')' { $$ = f_eval_int(f_linearize($2)); }
| CF_SYM_KNOWN {
if ($1->class != (SYM_CONSTANT | T_INT)) cf_error("Number constant expected");
$$ = SYM_VAL($1).i; }
conf: filter_eval ;
filter_eval:
- EVAL term { f_eval_int(f_postfixify($2)); }
+ EVAL term { f_eval_int(f_linearize($2)); }
;
conf: custom_attr ;
function_body:
decls '{' cmds '}' {
- $$ = f_postfixify($3);
+ $$ = f_linearize($3);
$$->vars = decls_count;
}
;
| VPN_RD { $$.type = T_RD; $$.val.ec = $1; }
| ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); }
| '(' term ')' {
- if (f_eval(f_postfixify($2), cfg_mem, &($$)) > F_RETURN) cf_error("Runtime error");
+ if (f_eval(f_linearize($2), cfg_mem, &($$)) > F_RETURN) cf_error("Runtime error");
if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type");
}
| CF_SYM_KNOWN {
switch_atom:
NUM { $$.type = T_INT; $$.val.i = $1; }
- | '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int(f_postfixify($2)); }
+ | '(' term ')' { $$.type = T_INT; $$.val.i = f_eval_int(f_linearize($2)); }
| fipa { $$ = $1; }
| ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); }
;
cnum:
- term { $$ = f_eval_int(f_postfixify($1)); }
+ term { $$ = f_eval_int(f_linearize($1)); }
pair_item:
'(' cnum ',' cnum ')' { $$ = f_new_pair_item($2, $2, $4, $4); }
| switch_body switch_items ':' cmds {
/* Fill data fields */
struct f_tree *t;
- struct f_line *line = f_postfixify($4);
+ struct f_line *line = f_linearize($4);
for (t = $2; t; t = t->left)
t->data = line;
$$ = f_merge_items($1, $2);
struct f_tree *t = f_new_tree();
t->from.type = t->to.type = T_VOID;
t->right = t;
- t->data = f_postfixify($3);
+ t->data = f_linearize($3);
$$ = f_merge_items($1, t);
}
;
# 5 enum fi_code to string
# 6 dump line item
# 7 dump line item callers
-# 8 postfixify
+# 8 linearize
# 9 same (filter comparator)
# 1 union in struct f_inst
# 3 constructors
# 102 constructor arguments
# 103 constructor body
# 104 dump line item content
-# 105 postfixify body
+# 105 linearize body
# 106 comparator body
# 107 struct f_line_item content
# 108 interpreter body
m4_define(FID_ENUM_STR, `FID_ZONE(5, Code enum to string)')
m4_define(FID_DUMP, `FID_ZONE(6, Dump line)')
m4_define(FID_DUMP_CALLER, `FID_ZONE(7, Dump line caller)')
-m4_define(FID_POSTFIXIFY, `FID_ZONE(8, Postfixify)')
+m4_define(FID_LINEARIZE, `FID_ZONE(8, Linearize)')
m4_define(FID_SAME, `FID_ZONE(9, Comparison)')
m4_define(FID_INTERPRET, `FID_ZONE(10, Interpret)')
m4_define(FID_NEW_ARGS, `m4_divert(102)')
m4_define(FID_NEW_BODY, `m4_divert(103)')
m4_define(FID_DUMP_BODY, `m4_divert(104)m4_define([[FID_DUMP_BODY_EXISTS]])')
-m4_define(FID_POSTFIXIFY_BODY, `m4_divert(105)m4_define([[FID_POSTFIXIFY_BODY_EXISTS]])')
+m4_define(FID_LINEARIZE_BODY, `m4_divert(105)m4_define([[FID_LINEARIZE_BODY_EXISTS]])')
m4_define(FID_SAME_BODY, `m4_divert(106)')
m4_define(FID_LINE_IN, `m4_divert(107)')
m4_define(FID_INTERPRET_BODY, `m4_divert(108)')
}
FID_ALL_TARGETS
-FID_POSTFIXIFY
+FID_LINEARIZE
case INST_NAME(): {
#define what (&(what_->i_]]INST_NAME()[[))
#define item (&(dest->items[pos].i_]]INST_NAME()[[))
dest->items[pos].lineno = what_->lineno;
break;
}
-m4_undefine([[FID_POSTFIXIFY_BODY_EXISTS]])
+m4_undefine([[FID_LINEARIZE_BODY_EXISTS]])
FID_SAME
case INST_NAME():
FID_NEW_BODY
what->$2 = $2;
m4_ifelse($3,,,[[
-FID_POSTFIXIFY_BODY
+FID_LINEARIZE_BODY
item->$3 = what->$2;
]])
m4_ifelse($4,,,[[
FID_NEW_BODY
what->f$1 = f$1;
for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size;
-FID_POSTFIXIFY_BODY
-pos = postfixify(dest, what->f$1, pos);m4_dnl
+FID_LINEARIZE_BODY
+pos = linearize(dest, what->f$1, pos);m4_dnl
FID_ALL()')
m4_define(ARG, `ARG_ANY($1)
what->f$1 = f$1;
FID_DUMP_BODY
f_dump_line(item->fl$1, indent + 1);
-FID_POSTFIXIFY_BODY
-item->fl$1 = f_postfixify(what->f$1);
+FID_LINEARIZE_BODY
+item->fl$1 = f_linearize(what->f$1);
FID_SAME_BODY
if (!f_same(f1->fl$1, f2->fl$1)) return 0;
FID_INTERPRET_BODY
debug("%sFilter line %p dump done\n", INDENT, dest);
}
-/* Postfixify */
+/* Linearize */
static uint
-postfixify(struct f_line *dest, const struct f_inst *what_, uint pos)
+linearize(struct f_line *dest, const struct f_inst *what_, uint pos)
{
for ( ; what_; what_ = what_->next) {
switch (what_->fi_code) {
}
struct f_line *
-f_postfixify_concat(const struct f_inst * const inst[], uint count)
+f_linearize_concat(const struct f_inst * const inst[], uint count)
{
uint len = 0;
for (uint i=0; i<count; i++)
struct f_line *out = cfg_allocz(sizeof(struct f_line) + sizeof(struct f_line_item)*len);
for (uint i=0; i<count; i++)
- out->len = postfixify(out, inst[i], out->len);
+ out->len = linearize(out, inst[i], out->len);
#if DEBUGGING
f_dump_line(out, 0);
, const struct f_val val
FID_NEW_BODY
what->val = val;
- FID_POSTFIXIFY_BODY
+ FID_LINEARIZE_BODY
item->val = what->val;
FID_SAME_BODY
if (!val_same(&(f1->val), &(f2->val))) return 0;
, const struct symbol *sym
FID_NEW_BODY
what->sym = sym;
- FID_POSTFIXIFY_BODY
+ FID_LINEARIZE_BODY
item->valp = (item->sym = what->sym)->val;
FID_SAME_BODY
if (strcmp(f1->sym->name, f2->sym->name) || !val_same(f1->sym->val, f2->sym->val)) return 0;
LINE(3,1);
}
INST(FI_PRINT_AND_DIE, 0, 0) {
- FID_POSTFIXIFY_BODY
+ FID_LINEARIZE_BODY
{
uint opos = pos;
FID_ALL
ARG_ANY(1);
- FID_POSTFIXIFY_BODY
+ FID_LINEARIZE_BODY
if (opos < pos)
dest->items[pos].flags |= FIF_PRINTED;
}
* translates into f_new_inst_FI_code(...) and the types are checked in
* compile time.
*
- * 2 Postfixify before interpreting
+ * 2 Linearize before interpreting
* The infix tree is always interpreted in the same order. Therefore we
* sort the instructions one after another into struct f_line. Results
* and arguments of these instructions are implicitly put on a value
};
/* Convert the f_inst infix tree to the f_line structures */
-struct f_line *f_postfixify_concat(const struct f_inst * const inst[], uint count);
-static inline struct f_line *f_postfixify(const struct f_inst *root)
-{ return f_postfixify_concat(&root, 1); }
+struct f_line *f_linearize_concat(const struct f_inst * const inst[], uint count);
+static inline struct f_line *f_linearize(const struct f_inst *root)
+{ return f_linearize_concat(&root, 1); }
void f_dump_line(const struct f_line *, uint indent);
};
struct filter *f = cfg_allocz(sizeof(struct filter));
- f->root = f_postfixify(&i);
+ f->root = f_linearize(&i);
return f;
}
idval:
NUM { $$ = $1; }
- | '(' term ')' { $$ = f_eval_int(f_postfixify($2)); }
+ | '(' term ')' { $$ = f_eval_int(f_linearize($2)); }
| IP4 { $$ = ip4_to_u32($1); }
| CF_SYM_KNOWN {
if ($1->class == (SYM_CONSTANT | T_INT) || $1->class == (SYM_CONSTANT | T_QUAD))
{ protos_dump_all(); cli_msg(0, ""); } ;
CF_CLI(EVAL, term, <expr>, [[Evaluate an expression]])
-{ cmd_eval(f_postfixify($2)); } ;
+{ cmd_eval(f_linearize($2)); } ;
CF_CLI_HELP(ECHO, ..., [[Control echoing of log messages]])
CF_CLI(ECHO, echo_mask echo_size, (all | off | { debug|trace|info|remote|warning|error|auth [, ...] }) [<buffer-size>], [[Control echoing of log messages]]) {
if (net_type_match(this_srt->net, NB_DEST) == !this_srt->dest)
cf_error("Unexpected or missing nexthop/type");
- this_srt->cmds = f_postfixify(this_srt_cmds);
+ this_srt->cmds = f_linearize(this_srt_cmds);
}
CF_DECLS