/* Family Treatement (1996) */ /* */ /* Author : Marie Aimar */ /* File : parser_family.y */ %{ #include #include #include #include "generic.h" #include "list.h" #include "family.h" #include "file.h" static int no_error_line=1; jmp_buf ENVIRONMENT_BUFFER ; char *name; %} %union { char *t_nom; float t_float; } %start set_of_family %token IDENT %token RATIONAL %token FAMILY %token END_LINE %type family_number %type number_of_members %type identification %type parent1 %type parent2 %type sexe %type age %type proband %type family_id %type env_fact %type q1 %type q2 %type q3 %type q4 %type q5 %% set_of_family : /*empty */ | set_of_family family | error {yyerrok;} ; family : /* empty */ | FAMILY END_LINE family_number END_LINE number_of_members { no_error_line++;no_error_line++; new_family($3,$5); } END_LINE { no_error_line++;}rest_of_family ; family_number : IDENT { name = (char *)malloc(1+strlen($1)); strcpy(name,$1); $$=name; } ; number_of_members : IDENT { name = (char *)malloc(1+strlen($1)); strcpy(name,$1);$$=name;} ; rest_of_family : /* empty */ | rest_of_family line ; line : /* rien */ END_LINE { no_error_line++; } | family_id identification parent1 parent2 sexe age proband proband END_LINE { no_error_line++; add_member($2,$3,$4,$5,$6,$7,$8,0.0,0.0,0.0,0.0,0.0,0.0);} | family_id identification parent1 parent2 sexe age proband env_fact q1 q2 q3 q4 q5 END_LINE { no_error_line++; add_member($2,$3,$4,$5,$6,NULL, $7,NULL,$8,$9,$10,$11,$12,$13); } | family_id identification parent1 parent2 sexe age proband proband env_fact q1 q2 q3 q4 q5 END_LINE { no_error_line++; add_member($2,$3,$4,$5,$6,NULL,$7,$8,$9,$10,$11,$12,$13,$14);} ; identification : IDENT{name = (char *)malloc(1+strlen($1)); strcpy(name,$1); $$=name; } ; parent1 : IDENT{name = (char *)malloc(1+strlen($1)); strcpy(name,$1);$$=name; } ; parent2 : IDENT{name = (char *)malloc(1+strlen($1)); strcpy(name,$1);$$=name; }; family_id : IDENT{}; age : IDENT{$$=atoi($1);}; proband : IDENT{name = (char *)malloc(1+strlen($1)); strcpy(name,$1);$$=name; } ; sexe : IDENT { $$=atoi($1);} ; env_fact : RATIONAL{$$=$1;} ; q1 : RATIONAL{$$=$1;} ; q2 : RATIONAL{$$=$1;} ; q3 : RATIONAL{$$=$1;} ; q4 : RATIONAL{$$=$1;} ; q5 : RATIONAL{$$=$1;} ; %% #include "lex.family.c" int yyerror(char *s){printf("%s %d nb_ligne\n",s,no_error_line);}; void error_in_parsing_file(char *s){;} void read_file (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."); } }