12 #include "conffile_internal.h"
14 #define YYERROR_VERBOSE
16 static struct p_node *node(uint32_t type, struct p_node *l, struct p_node *r);
18 static struct p_node *result;
20 static void yyerror(char *s);
26 input: assignments { result = $1; $$=result; }
29 assignments: assignments assignment { $$=node(T_ALIST, $2, $1); }
30 | assignment { $$=node(T_ALIST, $1, NULL); }
33 searchpath: /* empty */ { $$ = NULL; }
34 | '<' list '>' { $$ = $2; }
37 dict: searchpath '{' assignments '}'
38 { $$ = node(T_DICT, $3, $1); }
39 | searchpath '{' '}' { $$ = node(T_DICT, NULL, $1); }
42 path: '/' pathelements { $$ = node(T_ABSPATH, NULL, $2); }
43 | pathelements { $$ = node(T_RELPATH, NULL, $1); }
46 pathelements: pathelements '/' TOK_KEY { $$ = node(T_PATHELEM, $3, $1); }
47 | TOK_KEY { $$ = node(T_PATHELEM, $1, NULL); }
50 exec: item '(' list ')' { $$ = node(T_EXEC, $1, $3); }
51 | item '(' ')' { $$ = node(T_EXEC, $1, NULL); }
53 { $$ = node(T_EXEC, $1, node(T_LISTITEM, $2, NULL)); }
56 list: list ',' item { $$ = node(T_LISTITEM, $3, $1); }
57 | item { $$ = node(T_LISTITEM, $1, NULL); }
60 assignment: TOK_KEY '=' list ';' { $$ = node(T_ASSIGNMENT, $1, $3); }
61 | TOK_KEY list ';' { $$ = node(T_ASSIGNMENT, $1, $2); }
62 | error ';' { $$ = node(T_ERROR, NULL, NULL); }
63 | error '}' { $$ = node(T_ERROR, NULL, NULL); }
64 | error ')' { $$ = node(T_ERROR, NULL, NULL); }
76 static void yyerror(char *s)
78 Message(M_FATAL,"config file %s line %d: %s\n",config_file,
82 struct p_node *parse_conffile(FILE *conffile)
86 fatal("Configuration file parsing failed\n");
89 fatal("%d error%s encountered in configuration file\n",
90 yynerrs,yynerrs==1?"":"s");
95 static struct p_node *node(uint32_t type, struct p_node *l, struct p_node *r)
99 rv=safe_malloc(sizeof(*rv),"p_node");
101 rv->loc.file=config_file;
102 rv->loc.line=config_lineno;