X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fliboconfig%2Fparser.y;h=764212f7ee611f5ea8273628f0414c31fef41bfa;hb=10e6e69a60f1722bb0a8a3b25bd5812471f33cfc;hp=49cd139dbd76bd1e4505b3184194d6066a1be11b;hpb=b92c090faa534fd75ab184afe425331e06b74d0b;p=collectd.git diff --git a/src/liboconfig/parser.y b/src/liboconfig/parser.y index 49cd139d..764212f7 100644 --- a/src/liboconfig/parser.y +++ b/src/liboconfig/parser.y @@ -28,6 +28,7 @@ static int yyerror (const char *s); /* Lexer variables */ extern int yylineno; extern char *yytext; +extern int yylex (void); extern oconfig_item_t *ci_root; extern char *c_file; @@ -46,7 +47,7 @@ extern char *c_file; } %token NUMBER -%token TRUE FALSE +%token BTRUE BFALSE %token QUOTED_STRING UNQUOTED_STRING %token SLASH OPENBRAC CLOSEBRAC EOL @@ -76,8 +77,8 @@ string: argument: NUMBER {$$.value.number = $1; $$.type = OCONFIG_TYPE_NUMBER;} - | TRUE {$$.value.boolean = 1; $$.type = OCONFIG_TYPE_BOOLEAN;} - | FALSE {$$.value.boolean = 0; $$.type = OCONFIG_TYPE_BOOLEAN;} + | BTRUE {$$.value.boolean = 1; $$.type = OCONFIG_TYPE_BOOLEAN;} + | BFALSE {$$.value.boolean = 0; $$.type = OCONFIG_TYPE_BOOLEAN;} | string {$$.value.string = $1; $$.type = OCONFIG_TYPE_STRING;} ; @@ -148,6 +149,19 @@ block: $$.children = $2.statement; $$.children_num = $2.statement_num; } + | block_begin block_end + { + if (strcmp ($1.key, $2) != 0) + { + printf ("block_begin = %s; block_end = %s;\n", $1.key, $2); + yyerror ("Block not closed..\n"); + exit (1); + } + free ($2); $2 = NULL; + $$ = $1; + $$.children = NULL; + $$.children_num = 0; + } ; statement: @@ -191,6 +205,13 @@ entire_file: ci_root->children = $1.statement; ci_root->children_num = $1.statement_num; } + | /* epsilon */ + { + ci_root = malloc (sizeof (oconfig_item_t)); + memset (ci_root, '\0', sizeof (oconfig_item_t)); + ci_root->children = NULL; + ci_root->children_num = 0; + } ; %%