/*-----------------------------------------------------------------------*/ /* Generic Dictionary (1994) */ /* -------------------------------------------- */ /* */ /* Author : Marie Aimar */ /* Medical Computer Laboratory */ /* University of Bordeaux II */ /* */ /* File : parser_gen.y */ /* */ /*-----------------------------------------------------------------------*/ %{ #include #include #include "generic.h" #include "list.h" #include "family.h" #include "file.h" #include "parser_gen.h" #include "list.h" static int no_error_line=1; jmp_buf ENVIRONMENT_BUFFER ; char *name; t_genlist list; %} %union { char *t_nom; float t_float; t_genlist t_glist; } %start set_of_element %token IDENT %token RATIONAL %token FAMILY %token END_LINE %type ident_family %type identification %type gen %type list_gen %% set_of_element : /* empty */ | set_of_element element | error {yyerrok;} ; element : ident_family identification list_gen END_LINE {no_error_line++; add_in_info($2,$3);} ; ident_family : IDENT { name = (char *)malloc(1+strlen($1)); strcpy(name,$1); if (cmp_name(name,current_family)) change_family(name); } ; list_gen : /*empty*/{list = create_genlist(); }; | list_gen gen { add_in_list(list,$2); $$=list;} ; identification : IDENT { name = (char *)malloc(1+strlen($1)); strcpy(name,$1); $$=name; } ; gen : IDENT { name = (char *)malloc(1+strlen($1)); strcpy(name,$1); $$=name; } ; %% #include "lex.gen.c" int yyerror(char *s){printf("%s \n",s);}; void read_file_gen (FILE *fic_input, void(*parsing_error)(char *)) { yyin=fic_input; if (setjmp(ENVIRONMENT_BUFFER)==0) yyparse(); else { fclose(fic_input); parsing_error("Loading file error."); } }