From 3613f7e1bf0e5eb06d2049eaebb0f39afb71d153 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 4 Jul 2011 12:22:48 +0200 Subject: milestone: PROPFILT added to grammar --- grammar/debian.conf | 1 - grammar/rscript.l | 14 ++++++++------ grammar/rscript.y | 14 ++++++++------ 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'grammar') diff --git a/grammar/debian.conf b/grammar/debian.conf index 91a67307..166cde52 100644 --- a/grammar/debian.conf +++ b/grammar/debian.conf @@ -118,6 +118,5 @@ daemon.*;mail.*;\ news.err;\ *.=debug;*.=info;\ *.=notice;*.=warn |/dev/xconsole - # samples added to get full "flavor" of what we need to support... :msg, contains, "error" /var/log/somelog diff --git a/grammar/rscript.l b/grammar/rscript.l index a4c37c81..6472ca13 100644 --- a/grammar/rscript.l +++ b/grammar/rscript.l @@ -117,6 +117,7 @@ char *currfn; /* name of currently processed file */ "action"[ \n\t]*"(" { BEGIN INOBJ; return BEGIN_ACTION; } ^[ \t]*:\$?[a-z]+[ ]*,[ ]*!?[a-z]+[ ]*,[ ]*\".*\" { printf("PROP-FILT: '%s'\n", yytext); + return PROPFILT; } ^[ \t]*[,\*a-z]+\.[,!=;\.\*a-z]+ { printf("token prifilt '%s'\n", yytext); yylval.s = strdup(yytext); return PRIFILT; } @@ -124,8 +125,9 @@ char *currfn; /* name of currently processed file */ "*" | \-\/[^*][^\n]* | \/[^*][^\n]* | -[\|\.\-\@:~][^\n]+ | -[a-z0-9_][a-z0-9_\-\+]* { yylval.s = strdup(yytext); printf("LEGACY_ACT: '%s'\n", yytext);return LEGACY_ACTION; } +:[a-z0-9]+:[^\n]* | +[\|\.\-\@~][^\n]+ | +[a-z0-9_][a-z0-9_\-\+]* { yylval.s = strdup(yytext); printf("LEGA ACT: '%s'\n", yytext);return LEGACY_ACTION; } ")" { BEGIN INITIAL; return ENDOBJ; } [a-z][a-z0-9_\.]* { yylval.estr = es_newStrFromCStr(yytext, yyleng); return NAME; } @@ -151,10 +153,10 @@ char *currfn; /* name of currently processed file */ return CFSYSLINE; } } -![^ \t\n]+[ \t]*$ { printf("BSD TAG '%s'\n", yytext); yylval.s = strdup(yytext); return BSD_TAG_SELECTOR; } -[+-]\*[ \t\n]*#.*$ { printf("BSD HOST '%s'\n", yytext); yylval.s = strdup(yytext); return BSD_HOST_SELECTOR; } -[+-]\*[ \t\n]*$ { printf("BSD HOST '%s'\n", yytext); yylval.s = strdup(yytext); return BSD_HOST_SELECTOR; } -^[ \t]*[+-][a-z0-9.:-]+[ \t]*$ { printf("BSD HOST '%s'\n", yytext); yylval.s = strdup(yytext); return BSD_HOST_SELECTOR; } +![^ \t\n]+[ \t]*$ { yylval.s = strdup(yytext); return BSD_TAG_SELECTOR; } +[+-]\*[ \t\n]*#.*$ { yylval.s = strdup(yytext); return BSD_HOST_SELECTOR; } +[+-]\*[ \t\n]*$ { yylval.s = strdup(yytext); return BSD_HOST_SELECTOR; } +^[ \t]*[+-][a-z0-9.:-]+[ \t]*$ { yylval.s = strdup(yytext); return BSD_HOST_SELECTOR; } \#.*\n /* skip comments in input */ [\n\t ] /* drop whitespace */ diff --git a/grammar/rscript.y b/grammar/rscript.y index 186d0981..8dc00620 100644 --- a/grammar/rscript.y +++ b/grammar/rscript.y @@ -75,10 +75,10 @@ extern int yylineno; %% conf: /* empty (to end recursion) */ | obj conf - | rule conf - | cfsysline conf - | BSD_TAG_SELECTOR conf - | BSD_HOST_SELECTOR conf + | rule conf { printf("RULE processed, back in main\n"); } + | cfsysline conf { printf("cfsysline: %s\n", $1); } + | BSD_TAG_SELECTOR conf { printf("BSD tag '%s'\n", $1); } + | BSD_HOST_SELECTOR conf { printf("BSD host '%s'\n", $1); } obj: BEGINOBJ nvlst ENDOBJ { $$ = cnfobjNew($1, $2); cnfobjPrint($$); @@ -89,7 +89,7 @@ obj: BEGINOBJ nvlst ENDOBJ { $$ = cnfobjNew($1, $2); cnfobjDestruct(t); printf("XXXX: this is an new-style action!\n"); } -cfsysline: CFSYSLINE { printf("XXXX: processing CFSYSLINE: %s\n", $1); } +cfsysline: CFSYSLINE { printf("XXXX: processing CFSYSLINE: %s\n", $1);$$ = $1 } nvlst: { $$ = NULL; } | nvlst nv { $2->next = $1; $$ = $2; } @@ -98,7 +98,9 @@ nv: NAME '=' VALUE { $$ = nvlstNew($1, $3); } rule: PRIFILT actlst { printf("PRIFILT: %s\n", $1); free($1); $2 = cnfactlstReverse($2); cnfactlstPrint($2); } - | PROPFILT actlst + | PROPFILT actlst { printf("PROPFILT: %s\n", $1); free($1); + $2 = cnfactlstReverse($2); + cnfactlstPrint($2); } | scriptfilt scriptfilt: IF expr THEN actlst { printf("if filter detected, expr:\n"); cnfexprPrint($2,0); -- cgit