summaryrefslogtreecommitdiffstats
path: root/grammar
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2012-09-28 11:06:16 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2012-09-28 11:06:16 +0200
commit38cdf1abaddea47aa5e9d11d97fade6a2455b632 (patch)
tree7676ef3216c6f322a47c5a0840a44c3ab0fc3029 /grammar
parentb0764541ab2f2d0448ca79564479bb5865a02ecf (diff)
downloadrsyslog-38cdf1abaddea47aa5e9d11d97fade6a2455b632.tar.gz
rsyslog-38cdf1abaddea47aa5e9d11d97fade6a2455b632.tar.xz
rsyslog-38cdf1abaddea47aa5e9d11d97fade6a2455b632.zip
Implement RainerScript ruleset() statement
Diffstat (limited to 'grammar')
-rw-r--r--grammar/grammar.y5
-rw-r--r--grammar/lexer.l9
-rw-r--r--grammar/parserif.h1
-rw-r--r--grammar/rainerscript.c2
-rw-r--r--grammar/rainerscript.h5
5 files changed, 17 insertions, 5 deletions
diff --git a/grammar/grammar.y b/grammar/grammar.y
index ce749807..fcb9119b 100644
--- a/grammar/grammar.y
+++ b/grammar/grammar.y
@@ -64,6 +64,7 @@ extern int yyerror(char*);
%token BEGIN_PROPERTY
%token BEGIN_CONSTANT
%token BEGIN_TPL
+%token BEGIN_RULESET
%token STOP
%token SET
%token UNSET
@@ -135,6 +136,10 @@ obj: BEGINOBJ nvlst ENDOBJ { $$ = cnfobjNew($1, $2); }
{ $$ = cnfobjNew(CNFOBJ_TPL, $2);
$$->subobjs = $5;
}
+ | BEGIN_RULESET nvlst ENDOBJ '{' stmt '}'
+ { $$ = cnfobjNew(CNFOBJ_RULESET, $2);
+ $$->script = $5;
+ }
propconst: { $$ = NULL; }
| propconst property { $$ = objlstAdd($1, $2); }
| propconst constant { $$ = objlstAdd($1, $2); }
diff --git a/grammar/lexer.l b/grammar/lexer.l
index 38703f25..0fc333e4 100644
--- a/grammar/lexer.l
+++ b/grammar/lexer.l
@@ -142,14 +142,13 @@ int fileno(FILE *stream);
"&" { return '&'; }
"{" { return '{'; }
"}" { return '}'; }
-"ruleset" { dbgprintf("RULESET\n"); }
- /* line number support because the "preprocessor" combines lines and so needs
- * to tell us the real source line.
- */
"stop" { return STOP; }
"else" { return ELSE; }
"set" { BEGIN EXPR; return SET; }
"unset" { BEGIN EXPR; return UNSET; }
+ /* line number support because the "preprocessor" combines lines and so needs
+ * to tell us the real source line.
+ */
"preprocfilelinenumber(" { BEGIN LINENO; }
<LINENO>[0-9]+ { yylineno = atoi(yytext) - 1; }
<LINENO>")" { BEGIN INITIAL; }
@@ -165,6 +164,8 @@ int fileno(FILE *stream);
BEGIN INOBJ; return BEGINOBJ; }
"template"[ \n\t]*"(" { yylval.objType = CNFOBJ_TPL;
BEGIN INOBJ; return BEGIN_TPL; }
+"ruleset"[ \n\t]*"(" { yylval.objType = CNFOBJ_RULESET;
+ BEGIN INOBJ; return BEGIN_RULESET; }
"property"[ \n\t]*"(" { yylval.objType = CNFOBJ_PROPERTY;
BEGIN INOBJ; return BEGIN_PROPERTY; }
"constant"[ \n\t]*"(" { yylval.objType = CNFOBJ_CONSTANT;
diff --git a/grammar/parserif.h b/grammar/parserif.h
index aa271ec4..dbafe067 100644
--- a/grammar/parserif.h
+++ b/grammar/parserif.h
@@ -16,6 +16,7 @@ extern int yylineno;
*/
void cnfDoObj(struct cnfobj *o);
void cnfDoScript(struct cnfstmt *script);
+void cnfDoRuleset(struct cnfstmt *script);
void cnfDoCfsysline(char *ln);
void cnfDoBSDTag(char *ln);
void cnfDoBSDHost(char *ln);
diff --git a/grammar/rainerscript.c b/grammar/rainerscript.c
index 1a14b212..4e484804 100644
--- a/grammar/rainerscript.c
+++ b/grammar/rainerscript.c
@@ -732,7 +732,6 @@ nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
vals = NULL;
}
-dbgprintf("DDDD: vals %p\n", vals);
return vals;
}
@@ -777,6 +776,7 @@ cnfobjNew(enum cnfobjType objType, struct nvlst *lst)
o->objType = objType;
o->nvlst = lst;
o->subobjs = NULL;
+ o->script = NULL;
}
return o;
diff --git a/grammar/rainerscript.h b/grammar/rainerscript.h
index 902ff4c5..6bd1660a 100644
--- a/grammar/rainerscript.h
+++ b/grammar/rainerscript.h
@@ -20,6 +20,7 @@ extern int Debug; /* 1 if in debug mode, 0 otherwise -- to be enhanced */
enum cnfobjType {
CNFOBJ_ACTION,
+ CNFOBJ_RULESET,
CNFOBJ_GLOBAL,
CNFOBJ_INPUT,
CNFOBJ_MODULE,
@@ -36,6 +37,9 @@ cnfobjType2str(enum cnfobjType ot)
case CNFOBJ_ACTION:
return "action";
break;
+ case CNFOBJ_RULESET:
+ return "ruleset";
+ break;
case CNFOBJ_GLOBAL:
return "global";
break;
@@ -81,6 +85,7 @@ struct cnfobj {
enum cnfobjType objType;
struct nvlst *nvlst;
struct objlst *subobjs;
+ struct cnfstmt *script;
};
struct objlst {