%{ #include #include "data.h" int lvl; int gottocode=0; int colno; int lineno; int ignorekw=0; char *A4GL_strip_quotes(char *s); struct s_parser_start *start; %} %start parser %verbose %name-prefix="a4gl_parser_yy" %union { char str[30000]; struct s_section_item *s_section_item; struct s_section_entry *s_section_entry; struct s_section_list *s_section_list; struct s_parse_entry *s_parse_entry; struct s_parser_start *s_parser_start; } %token NAMED INTVAL CHAR_VALUE NUMBER_VALUE CH OPTIONAL PREC ERROR %% parser: parser_start { dumpit($1); } ; parser_start : parse_entry {$$=new_parser_start(NULL, $1);} | parser_start parse_entry {$$=new_parser_start($1,$2);} ; parse_entry: identifier ':' section_list ';' { $$=new_parse_entry($1,$3); } ; section_list : section_entry {$$=new_section_list(NULL, $1);} | section_list '|' section_entry {$$=new_section_list($1,$3);} ; section_entry : section_item {$$=new_section_entry(NULL, $1);} | section_entry section_item {$$=new_section_entry($1,$2);} ; section_item : NAMED {$$=new_section_item__1($1);} | CHAR_VALUE {$$=new_section_item__2($1);} | OPTIONAL {$$=new_section_item__2($1);} | ERROR {$$=NULL;} | PREC NAMED { char buff[100]; sprintf(buff,"%%prec PGKW_%s",$2); $$=new_section_item__2(buff); } | {$$=NULL;} ; identifier : NAMED; %% #include "lex.yy.c"