summaryrefslogtreecommitdiffstats
path: root/grammar
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-07-04 16:06:50 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-07-04 16:06:50 +0200
commit3d08f4e0f2dcc0f2216e11104ec43507eab22078 (patch)
tree869a5c77517bc16ce452350d3b65f2cc10857125 /grammar
parent460010068b1d46c23829e7106380ffb8527df949 (diff)
downloadrsyslog-3d08f4e0f2dcc0f2216e11104ec43507eab22078.tar.gz
rsyslog-3d08f4e0f2dcc0f2216e11104ec43507eab22078.tar.xz
rsyslog-3d08f4e0f2dcc0f2216e11104ec43507eab22078.zip
cleanup
Diffstat (limited to 'grammar')
-rw-r--r--grammar/rscript.l13
-rw-r--r--grammar/rscript.y37
2 files changed, 20 insertions, 30 deletions
diff --git a/grammar/rscript.l b/grammar/rscript.l
index 37f08f66..a0ed3b0c 100644
--- a/grammar/rscript.l
+++ b/grammar/rscript.l
@@ -1,4 +1,4 @@
- /* lex file for rsyslog config format v2.
+ /* Lex file for rsyslog config format v2 (RainerScript).
* Please note: this file introduces the new config format, but maintains
* backward compatibility. In order to do so, the grammar is not 100% clean,
* but IMHO still sufficiently easy both to understand for programmers
@@ -106,10 +106,7 @@ char *currfn; /* name of currently processed file */
<INCL>.|\n
<INCL>[^ \t\n]+ { if(cnfSetLexFile(yytext) != 0)
yyterminate();
- BEGIN INITIAL;
- }
-
-
+ BEGIN INITIAL; }
"global"[ \n\t]*"(" { yylval.objType = CNFOBJ_GLOBAL;
BEGIN INOBJ; return BEGINOBJ; }
"input"[ \n\t]*"(" { yylval.objType = CNFOBJ_INPUT;
@@ -119,9 +116,7 @@ char *currfn; /* name of currently processed file */
"action"[ \n\t]*"(" { BEGIN INOBJ; return BEGIN_ACTION; }
^[ \t]*:\$?[a-z]+[ ]*,[ ]*!?[a-z]+[ ]*,[ ]*\".*\" {
yylval.s = strdup(yytext); return PROPFILT; }
-
^[ \t]*[,\*a-z]+\.[,!=;\.\*a-z]+ { yylval.s = strdup(yytext); return PRIFILT; }
-
"*" |
\-\/[^*][^\n]* |
\/[^*][^\n]* |
@@ -141,11 +136,9 @@ char *currfn; /* name of currently processed file */
<EXPR>"/*" { preCommentState = YY_START; BEGIN COMMENT; }
<COMMENT>"*/" { BEGIN preCommentState; }
<COMMENT>([^*]|\n)+|.
-
<INOBJ>#.*$ /* skip comments in input */
<INOBJ>[ \n\t]
<INOBJ>. { printf("INOBJ: invalid char '%s'\n", yytext); }
-
\$[a-z]+.*$ { /* see common on $IncludeConfig above */
if(!strncasecmp(yytext, "$includeconfig ", 14)) {
yyless(14);
@@ -159,12 +152,10 @@ char *currfn; /* name of currently processed file */
[+-]\*[ \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 */
. { printf("invalid char: %s\n", yytext);
}
-
<<EOF>> { if(popfile() != 0) yyterminate(); }
%%
diff --git a/grammar/rscript.y b/grammar/rscript.y
index 281a1775..75fce49d 100644
--- a/grammar/rscript.y
+++ b/grammar/rscript.y
@@ -1,3 +1,17 @@
+ /* Bison file for rsyslog config format v2 (RainerScript).
+ * Please note: this file introduces the new config format, but maintains
+ * backward compatibility. In order to do so, the grammar is not 100% clean,
+ * but IMHO still sufficiently easy both to understand for programmers
+ * maitaining the code as well as users writing the config file. Users are,
+ * of course, encouraged to use new constructs only. But it needs to be noted
+ * that some of the legacy constructs (specifically the in-front-of-action
+ * PRI filter) are very hard to beat in ease of use, at least for simpler
+ * cases. So while we hope that cfsysline support can be dropped some time in
+ * the future, we will probably keep these useful constructs.
+ *
+ * Copyright (C) 2011 by Rainer Gerhards and Adiscon GmbH
+ * Released under the GNU GPL v3. For details see LICENSE file.
+ */
%{
#include <stdio.h>
@@ -92,40 +106,25 @@ conf: /* empty (to end recursion) */
obj: BEGINOBJ nvlst ENDOBJ { $$ = cnfobjNew($1, $2); }
| BEGIN_ACTION nvlst ENDOBJ { $$ = cnfobjNew(CNFOBJ_ACTION, $2); }
cfsysline: CFSYSLINE { $$ = $1 }
-
nvlst: { $$ = NULL; }
| nvlst nv { $2->next = $1; $$ = $2; }
-nv: NAME '=' VALUE { $$ = nvlstNew($1, $3); }
-
+nv: NAME '=' VALUE { $$ = nvlstNew($1, $3); }
rule: PRIFILT actlst { $$ = cnfruleNew(CNFFILT_PRI, $2); $$->filt.s = $1; }
| PROPFILT actlst { $$ = cnfruleNew(CNFFILT_PROP, $2); $$->filt.s = $1; }
| scriptfilt { $$ = $1; }
scriptfilt: IF expr THEN actlst { $$ = cnfruleNew(CNFFILT_SCRIPT, $4);
- $$->filt.expr = $2;
- //struct exprret r;
- //cnfexprEval($2, &r);
- // printf("eval result: %lld\n", r.d.n);
- }
-
-/* note: we can do some limited block-structuring with the v6 engine. In that case,
- * we must not support additonal filters inside the blocks, so they must consist of
- * "act", only. We can implement that via the "&" actlist logic.
- */
+ $$->filt.expr = $2; }
block: actlst { $$ = $1; }
| block actlst { $2->next = $1; $$ = $2; }
/* v7: | actlst
- v7: | block rule */
-
+ v7: | block rule */ /* v7 extensions require new rule engine capabilities! */
actlst: act { $$=$1; }
| actlst '&' act { $3->next = $1; $$ = $3; }
| actlst cfsysline { $$ = cnfactlstAddSysline($1, $2); }
| '{' block '}' { $$ = $2; }
-
act: BEGIN_ACTION nvlst ENDOBJ { $$ = cnfactlstNew(CNFACT_V2, $2, NULL); }
- | LEGACY_ACTION { //printf("legacy action: '%s'\n", $1);
- $$ = cnfactlstNew(CNFACT_LEGACY, NULL, $1); }
-
+ | LEGACY_ACTION { $$ = cnfactlstNew(CNFACT_LEGACY, NULL, $1); }
expr: expr AND expr { $$ = cnfexprNew(AND, $1, $3); }
| expr OR expr { $$ = cnfexprNew(OR, $1, $3); }
| NOT expr { $$ = cnfexprNew(NOT, NULL, $2); }