Path and path matching seem to work, now.
This commit is contained in:
parent
1ed2fe9609
commit
e399b6f6ad
3 changed files with 21 additions and 9 deletions
|
@ -72,7 +72,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN,
|
||||||
LEN,
|
LEN,
|
||||||
DEFINED,
|
DEFINED,
|
||||||
ADD, DELETE, CONTAINS, RESET,
|
ADD, DELETE, CONTAINS, RESET,
|
||||||
APPEND, MATCH,
|
PREPEND, MATCH,
|
||||||
EMPTY,
|
EMPTY,
|
||||||
FILTER, WHERE)
|
FILTER, WHERE)
|
||||||
|
|
||||||
|
@ -388,6 +388,7 @@ term:
|
||||||
case SYM_VARIABLE | T_PREFIX:
|
case SYM_VARIABLE | T_PREFIX:
|
||||||
case SYM_VARIABLE | T_IP:
|
case SYM_VARIABLE | T_IP:
|
||||||
case SYM_VARIABLE | T_PATH_MASK:
|
case SYM_VARIABLE | T_PATH_MASK:
|
||||||
|
case SYM_VARIABLE | T_PATH:
|
||||||
$$->code = 'C';
|
$$->code = 'C';
|
||||||
$$->a1.p = $1->aux2;
|
$$->a1.p = $1->aux2;
|
||||||
break;
|
break;
|
||||||
|
@ -417,10 +418,11 @@ term:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Paths */
|
/* Paths */
|
||||||
| term '.' APPEND '(' term ')' { }
|
| term '.' PREPEND '(' term ')' { }
|
||||||
| term '.' RESET { }
|
| term '.' RESET { }
|
||||||
|
|
||||||
| EMPTY { $$ = f_new_inst(); $$->code = 'E'; $$->aux = T_PATH; }
|
| '+' EMPTY '+' { $$ = f_new_inst(); $$->code = 'E'; $$->aux = T_PATH; }
|
||||||
|
| PREPEND '(' term ',' term ')' { $$ = f_new_inst(); $$->code = P('A','p'); $$->a1.p = $3; $$->a2.p = $5; }
|
||||||
|
|
||||||
/* | term '.' LEN { $$->code = P('P','l'); } */
|
/* | term '.' LEN { $$->code = P('P','l'); } */
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,8 @@ interpret(struct f_inst *what)
|
||||||
case T_IP:
|
case T_IP:
|
||||||
case T_PREFIX:
|
case T_PREFIX:
|
||||||
case T_PAIR:
|
case T_PAIR:
|
||||||
|
case T_PATH:
|
||||||
|
case T_CLIST:
|
||||||
case T_PATH_MASK:
|
case T_PATH_MASK:
|
||||||
if (sym->class != (SYM_VARIABLE | v2.type))
|
if (sym->class != (SYM_VARIABLE | v2.type))
|
||||||
runtime( "Variable of bad type" );
|
runtime( "Variable of bad type" );
|
||||||
|
@ -584,6 +586,7 @@ filters_postconfig(void)
|
||||||
struct f_val res;
|
struct f_val res;
|
||||||
if (startup_func) {
|
if (startup_func) {
|
||||||
debug( "Launching startup function...\n" );
|
debug( "Launching startup function...\n" );
|
||||||
|
f_pool = lp_new(&root_pool, 1024);
|
||||||
res = interpret(startup_func);
|
res = interpret(startup_func);
|
||||||
if (res.type == F_ERROR)
|
if (res.type == F_ERROR)
|
||||||
die( "Startup function resulted in error." );
|
die( "Startup function resulted in error." );
|
||||||
|
@ -674,10 +677,9 @@ path_format(u8 *p, int len)
|
||||||
#define PM_END -1
|
#define PM_END -1
|
||||||
#define PM_ASTERIX -2
|
#define PM_ASTERIX -2
|
||||||
|
|
||||||
#define MASK_PLUS do { mask = mask->next; if (mask->val == PM_END) return next == q; \
|
#define MASK_PLUS do { mask = mask->next; if (!mask) return next == q; \
|
||||||
asterix = (mask->val == PM_ASTERIX); \
|
asterix = (mask->val == PM_ASTERIX); \
|
||||||
printf( "Asterix now %d\n", asterix ); \
|
if (asterix) { mask = mask->next; if (!mask) { return 1; } } \
|
||||||
if (asterix) { mask = mask->next; if (mask->val == PM_END) { printf( "Quick exit\n" ); return 1; } } \
|
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -31,10 +31,18 @@ function fifteen()
|
||||||
|
|
||||||
function paths()
|
function paths()
|
||||||
bgpmask p;
|
bgpmask p;
|
||||||
|
bgppath p2;
|
||||||
{
|
{
|
||||||
print "Testing paths";
|
p = / 4 3 2 1 /;
|
||||||
p = / 1 2 3 4 /;
|
print "Testing path masks: ", p;
|
||||||
print p;
|
p2 = prepend( + empty +, 1 );
|
||||||
|
p2 = prepend( p2, 2 );
|
||||||
|
p2 = prepend( p2, 3 );
|
||||||
|
p2 = prepend( p2, 4 );
|
||||||
|
print "Testing paths: ", p2;
|
||||||
|
print "Should be true: ", p2 ~ p;
|
||||||
|
p2 = prepend( p2, 5 );
|
||||||
|
print "Should be false: ", p2 ~ p;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startup()
|
function startup()
|
||||||
|
|
Loading…
Reference in a new issue