/* $Id: conf_tbl.y,v 1.1 2004/03/26 02:19:03 jmuelmen Exp $ */ %{ #include #include #include #include "conf_int.h" extern char *conf_yytext; int conf_yylex (); void conf_yyerror (const char *s); static char _conf_strings[2][STRLEN]; static int i = 0; %} %token STRING NEWLINE EQ %start declaration_list %% string : STRING { $$ = (unsigned long)strncpy(_conf_strings[i], conf_yytext, STRLEN); _conf_strings[i][STRLEN - 1] = 0; ++i; i %= 2; } ; declaration : string EQ string NEWLINE { conf_set((const char *)$1, (const char *)$3); } | NEWLINE ; declaration_list : /* empty */ | declaration declaration_list ; %% void conf_yyerror (const char *s) { printf("%s\n", s); }