From: Peter Verthez Date: Sat, 8 Dec 2001 21:26:51 +0000 (+0000) Subject: Header fully covered with callbacks. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=c881bdbd69886d7f37055a9f2802a2e106e50fdb;p=gedcom-parse.git Header fully covered with callbacks. --- diff --git a/gedcom.y b/gedcom.y index b1b7bb9..886ad89 100644 --- a/gedcom.y +++ b/gedcom.y @@ -378,9 +378,13 @@ int compat_mode(int flags); %type anystdtag %type anytoptag %type line_item +%type line_value %type mand_line_item +%type mand_pointer %type note_line_item %type anychar +%type opt_xref +%type opt_value %type head_sect %% @@ -408,7 +412,7 @@ record : fam_rec /**** Header ****/ /*********************************************************************/ head_sect : OPEN DELIM TAG_HEAD - { $$ = start_record(REC_HEAD, NULL); + { $$ = start_record(REC_HEAD, $1, NULL, $3); START(HEAD, $$) } head_subs { if (compat_mode(C_FTREE)) @@ -449,7 +453,7 @@ head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item head_sour_subs { CHECK0 } CLOSE - { end_element(PARENT, $5); } + { end_element(ELT_HEAD_SOUR, PARENT, $5, NULL); } ; head_sour_subs : /* empty */ @@ -471,20 +475,33 @@ head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item no_std_subs { CHECK0 } CLOSE - { end_element(PARENT, $5); } + { end_element(ELT_HEAD_SOUR_VERS, + PARENT, $5, NULL); + } ; head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item - { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE - { gedcom_debug_print("===Source name: '%s'\n", $4); + { $$ = start_element(ELT_HEAD_SOUR_NAME, PARENT, + $1, $3, $4, $4); + START(NAME, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_SOUR_NAME, + PARENT, $5, NULL); } ; head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item - { gedcom_debug_print("===Source corp name: '%s'\n", $4); - START(CORP, NULL) } + { $$ = start_element(ELT_HEAD_SOUR_CORP, PARENT, + $1, $3, $4, $4); + START(CORP, $$) + } head_sour_corp_subs { CHECK0 } CLOSE - { } + { end_element(ELT_HEAD_SOUR_CORP, + PARENT, $5, NULL); + } ; head_sour_corp_subs : /* empty */ @@ -496,11 +513,16 @@ head_sour_corp_sub : addr_struc_sub /* 0:1 */ ; head_sour_data_sect : OPEN DELIM TAG_DATA mand_line_item - { START(DATA, NULL) } + { $$ = start_element(ELT_HEAD_SOUR_DATA, PARENT, + $1, $3, $4, $4); + START(DATA, $$) + } head_sour_data_subs { CHECK0 } CLOSE - { } + { end_element(ELT_HEAD_SOUR_DATA, + PARENT, $5, NULL); + } ; head_sour_data_subs : /* empty */ @@ -513,27 +535,56 @@ head_sour_data_sub : head_sour_data_date_sect { OCCUR2(DATE, 0, 1) } ; head_sour_data_date_sect : OPEN DELIM TAG_DATE mand_line_item - { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_SOUR_DATA_DATE, + PARENT, $1, $3, $4, $4); + START(DATE, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_SOUR_DATA_DATE, + PARENT, $5, NULL); + } ; head_sour_data_copr_sect : OPEN DELIM TAG_COPR mand_line_item - { START(COPR, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_SOUR_DATA_COPR, + PARENT, $1, $3, $4, $4); + START(COPR, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_SOUR_DATA_COPR, + PARENT, $5, NULL); + } ; /* HEAD.DEST */ head_dest_sect : OPEN DELIM TAG_DEST mand_line_item - { START(DEST, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_DEST, + PARENT, $1, $3, $4, $4); + START(DEST, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_DEST, + PARENT, $5, NULL); + } ; /* HEAD.DATE */ head_date_sect : OPEN DELIM TAG_DATE mand_line_item - { START(DATE, NULL) } + { $$ = start_element(ELT_HEAD_DATE, + PARENT, $1, $3, $4, $4); + START(DATE, $$) + } head_date_subs { CHECK0 } CLOSE - { } + { end_element(ELT_HEAD_DATE, + PARENT, $5, NULL); + } ; head_date_subs : /* empty */ @@ -545,37 +596,79 @@ head_date_sub : head_date_time_sect { OCCUR2(TIME, 0, 1) } ; head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item - { START(TIME, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_DATE_TIME, + PARENT, $1, $3, $4, $4); + START(TIME, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_DATE_TIME, + PARENT, $5, NULL); + } ; /* HEAD.SUBM */ head_subm_sect : OPEN DELIM TAG_SUBM mand_pointer - { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_SUBM, + PARENT, $1, $3, $4, $4); + START(SUBM, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_SUBM, + PARENT, $5, NULL); + } ; /* HEAD.SUBN */ head_subn_sect : OPEN DELIM TAG_SUBN mand_pointer - { START(SUBN, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_SUBN, + PARENT, $1, $3, $4, $4); + START(SUBN, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_SUBN, + PARENT, $5, NULL); + } ; /* HEAD.FILE */ head_file_sect : OPEN DELIM TAG_FILE mand_line_item - { START(FILE, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_FILE, + PARENT, $1, $3, $4, $4); + START(FILE, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_FILE, PARENT, $5, NULL); + } ; /* HEAD.COPR */ head_copr_sect : OPEN DELIM TAG_COPR mand_line_item - { START(COPR, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_COPR, + PARENT, $1, $3, $4, $4); + START(COPR, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_COPR, PARENT, $5, NULL); + } ; /* HEAD.GEDC */ head_gedc_sect : OPEN DELIM TAG_GEDC - { START(GEDC, NULL) } + { $$ = start_element(ELT_HEAD_GEDC, + PARENT, $1, $3, NULL, NULL); + START(GEDC, $$) + } head_gedc_subs { CHECK2(VERS, FORM) } CLOSE - { } + { end_element(ELT_HEAD_GEDC, PARENT, $4, NULL); + } ; head_gedc_subs : /* empty */ @@ -587,22 +680,42 @@ head_gedc_sub : head_gedc_vers_sect { OCCUR2(VERS, 1, 1) } | no_std_sub ; head_gedc_vers_sect : OPEN DELIM TAG_VERS mand_line_item - { START(VERS, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_GEDC_VERS, + PARENT, $1, $3, $4, $4); + START(VERS, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_GEDC_VERS, + PARENT, $5, NULL); + } ; head_gedc_form_sect : OPEN DELIM TAG_FORM mand_line_item - { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_GEDC_FORM, + PARENT, $1, $3, $4, $4); + START(FORM, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_GEDC_FORM, + PARENT, $5, NULL); + } ; /* HEAD.CHAR */ head_char_sect : OPEN DELIM TAG_CHAR mand_line_item { if (open_conv_to_internal($4) == 0) YYERROR; - START(CHAR, NULL) } + $$ = start_element(ELT_HEAD_CHAR, + PARENT, $1, $3, $4, $4); + START(CHAR, $$) + } head_char_subs { CHECK0 } CLOSE - { } + { end_element(ELT_HEAD_CHAR, PARENT, $5, NULL); + } ; head_char_subs : /* empty */ @@ -613,22 +726,41 @@ head_char_sub : head_char_vers_sect { OCCUR2(VERS, 0, 1) } | no_std_sub ; head_char_vers_sect : OPEN DELIM TAG_VERS mand_line_item - { START(VERS, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_CHAR_VERS, + PARENT, $1, $3, $4, $4); + START(VERS, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_CHAR_VERS, + PARENT, $5, NULL); + } ; /* HEAD.LANG */ head_lang_sect : OPEN DELIM TAG_LANG mand_line_item - { START(LANG, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_LANG, + PARENT, $1, $3, $4, $4); + START(LANG, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_LANG, PARENT, $5, NULL); + } ; /* HEAD.PLAC */ head_plac_sect : OPEN DELIM TAG_PLAC - { START(PLAC, NULL) } + { $$ = start_element(ELT_HEAD_PLAC, + PARENT, $1, $3, NULL, NULL); + START(PLAC, $$) + } head_plac_subs { CHECK1(FORM) } CLOSE - { } + { end_element(ELT_HEAD_PLAC, PARENT, $4, NULL); + } ; head_plac_subs : /* empty */ @@ -639,17 +771,29 @@ head_plac_sub : head_plac_form_sect { OCCUR2(FORM, 1, 1) } | no_std_sub ; head_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item - { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE - { } + { $$ = start_element(ELT_HEAD_PLAC_FORM, + PARENT, $1, $3, $4, $4); + START(FORM, $$) + } + no_std_subs + { CHECK0 } + CLOSE + { end_element(ELT_HEAD_PLAC_FORM, + PARENT, $5, NULL); + } ; /* HEAD.NOTE */ head_note_sect : OPEN DELIM TAG_NOTE mand_line_item - { START(NOTE, NULL) } + { $$ = start_element(ELT_HEAD_NOTE, + PARENT, $1, $3, $4, $4); + START(NOTE, $$) + } head_note_subs { CHECK0 } CLOSE - { } + { end_element(ELT_HEAD_NOTE, PARENT, $5, NULL); + } ; head_note_subs : /* empty */ @@ -663,6 +807,7 @@ head_note_sub : continuation_sub /* 0:M */ /*********************************************************************/ /**** Trailer ****/ /*********************************************************************/ +/* Don't need callbacks here, there is no information... */ trlr_sect : OPEN DELIM TAG_TRLR CLOSE { } ; @@ -670,7 +815,7 @@ trlr_sect : OPEN DELIM TAG_TRLR CLOSE { } /**** Family record ****/ /*********************************************************************/ fam_rec : OPEN DELIM POINTER DELIM TAG_FAM - { $$ = start_record(REC_FAM, $3); + { $$ = start_record(REC_FAM, $1, $3, $5); START(FAM, $$) } fam_subs { CHECK0 } @@ -731,10 +876,12 @@ fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer /**** Individual record ****/ /*********************************************************************/ indiv_rec : OPEN DELIM POINTER DELIM TAG_INDI - { START(INDI, NULL) } + { $$ = start_record(REC_INDI, $1, $3, $5); + START(INDI, $$) } indi_subs { CHECK0 } - CLOSE { } + CLOSE + { end_record(REC_INDI, $6); } ; indi_subs : /* empty */ @@ -815,10 +962,12 @@ ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item /**** Multimedia record ****/ /*********************************************************************/ multim_rec : OPEN DELIM POINTER DELIM TAG_OBJE - { START(OBJE, NULL) } + { $$ = start_record(REC_OBJE, $1, $3, $5); + START(OBJE, $$) } obje_subs { CHECK2(FORM, BLOB) } - CLOSE { } + CLOSE + { end_record(REC_OBJE, $6); } ; obje_subs : /* empty */ @@ -874,10 +1023,12 @@ obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer /**** Note record ****/ /*********************************************************************/ note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item - { START(NOTE, NULL) } + { $$ = start_record(REC_NOTE, $1, $3, $5); + START(NOTE, $$) } note_subs { CHECK0 } - CLOSE { } + CLOSE + { end_record(REC_NOTE, $6); } ; note_line_item : /* empty */ @@ -905,10 +1056,12 @@ note_sub : continuation_sub /* 0:M */ /**** Repository record ****/ /*********************************************************************/ repos_rec : OPEN DELIM POINTER DELIM TAG_REPO - { START(REPO, NULL) } + { $$ = start_record(REC_REPO, $1, $3, $5); + START(REPO, $$) } repo_subs { CHECK0 } - CLOSE { } + CLOSE + { end_record(REC_REPO, $6); } ; repo_subs : /* empty */ @@ -932,10 +1085,12 @@ repo_name_sect : OPEN DELIM TAG_NAME mand_line_item /**** Source record ****/ /*********************************************************************/ source_rec : OPEN DELIM POINTER DELIM TAG_SOUR - { START(SOUR, NULL) } + { $$ = start_record(REC_SOUR, $1, $3, $5); + START(SOUR, $$) } sour_subs { CHECK0 } - CLOSE { } + CLOSE + { end_record(REC_SOUR, $6); } ; sour_subs : /* empty */ @@ -1075,10 +1230,12 @@ sour_text_sub : continuation_sub /* 0:M */ /**** Submission record ****/ /*********************************************************************/ submis_rec : OPEN DELIM POINTER DELIM TAG_SUBN - { START(SUBN, NULL) } + { $$ = start_record(REC_SUBN, $1, $3, $5); + START(SUBN, $$) } subn_subs { CHECK0 } - CLOSE { } + CLOSE + { end_record(REC_SUBN, $6); } ; subn_subs : /* empty */ @@ -1134,10 +1291,12 @@ subn_rin_sect : OPEN DELIM TAG_RIN mand_line_item /**** Submitter record ****/ /*********************************************************************/ submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM - { START(SUBM, NULL) } + { $$ = start_record(REC_SUBM, $1, $3, $5); + START(SUBM, $$) } subm_subs { CHECK1(NAME) } - CLOSE { } + CLOSE + { end_record(REC_SUBM, $6); } ; subm_subs : /* empty */ @@ -2100,9 +2259,15 @@ user_rec : OPEN DELIM opt_xref USERTAG YYERROR; } } - opt_value user_sects CLOSE { } + opt_value + { $$ = start_record(REC_USER, $1, $3, $4); + START($4, $$) + } + user_sects + { CHECK0 } + CLOSE + { end_record(REC_USER, $7); } ; - user_sect : OPEN DELIM opt_xref USERTAG { if ($4[0] != '_') { gedcom_error("Undefined tag (and not a valid user tag): %s", @@ -2110,27 +2275,36 @@ user_sect : OPEN DELIM opt_xref USERTAG YYERROR; } } - opt_value user_sects CLOSE { } + opt_value + { $$ = start_element(ELT_USER, PARENT, $1, $4, $6, $6); + START($4, $$); + } + user_sects + { CHECK0 } + CLOSE + { end_element(ELT_USER, PARENT, $7, NULL); + } ; user_sects : /* empty */ { } | user_sects user_sect { } ; -opt_xref : /* empty */ { } - | POINTER DELIM { } +opt_xref : /* empty */ { $$ = NULL; } + | POINTER DELIM { $$ = $1; } ; -opt_value : /* empty */ { } - | DELIM line_value { } +opt_value : /* empty */ { $$ = NULL; } + | DELIM line_value { $$ = $2; } ; -line_value : POINTER { } - | line_item { } +line_value : POINTER { $$ = $1; } + | line_item { $$ = $1; } ; mand_pointer : /* empty */ { gedcom_error("Missing pointer"); YYERROR; } - | DELIM POINTER { } + | DELIM POINTER { gedcom_debug_print("==Ptr: %s==\n", $2); + $$ = $2; } ; mand_line_item : /* empty */ { gedcom_error("Missing value"); YYERROR; }