1 %{ 2 #include "config_internal.h" 3 #include <stdio.h> 4 5 int yylex(); 6 void yyerror(const char *); 7 8 %} 9 %token <str>TOK_IDENTIFIER 10 %token <str>TOK_STRING 11 %token TOK_FALSE 12 %token TOK_TRUE 13 %token TOK_WHITE 14 %token TOK_EOL 15 %token TOK_UNKNOWN 16 %token <i>TOK_INTEGER 17 18 %union { 19 char *str; 20 int i; 21 } 22 23 %% 24 25 config 26 : /* Empty */ 27 | config lws TOK_EOL 28 | config lws directive TOK_EOL 29 | error TOK_EOL { printf("Expected configuration directive\n"); } 30 ; 31 32 directive 33 : TOK_IDENTIFIER lws TOK_INTEGER lws { set_config_int($1,$3); } 34 | TOK_IDENTIFIER lws TOK_STRING lws { set_config_str($1,$3); } 35 | TOK_IDENTIFIER lws TOK_TRUE lws { set_config_int($1,1); } 36 | TOK_IDENTIFIER lws TOK_FALSE lws { set_config_int($1,0); } 37 ; 38 39 lws 40 : /* empty */ 41 | lws TOK_WHITE { } 42 ; 43 44