X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fgedcom.y;h=b94f7fa37c612217c3d1c036e5084375037f4bd0;hb=d41803b9c1bcafabf115a188e3b4a489103bbdca;hp=9eadd4424ed5e7840effb35ac197d68fd22b882c;hpb=6190c7618fa60d3827fe7414925a66c694ca2047;p=gedcom-parse.git diff --git a/gedcom/gedcom.y b/gedcom/gedcom.y index 9eadd44..b94f7fa 100644 --- a/gedcom/gedcom.y +++ b/gedcom/gedcom.y @@ -185,6 +185,7 @@ void clean_up(); clean_up(); YYABORT; \ } \ else if (error_mechanism == DEFER_FAIL) { \ + gedcom_debug_print("Fail on line %d", line_no); \ yyerrok; fail = 1; \ } \ else if (error_mechanism == IGNORE_ERRORS) { \ @@ -261,7 +262,7 @@ void clean_up(); } %token_table -%expect 309 +%expect 317 %token BADTOKEN %token OPEN @@ -1550,6 +1551,24 @@ sour_sub : sour_data_sect { OCCUR2(DATA, 0, 1) } | sour_abbr_sect { OCCUR2(ABBR, 0, 1) } | sour_publ_sect { OCCUR2(PUBL, 0, 1) } | sour_text_sect { OCCUR2(TEXT, 0, 1) } + | sour_type_sect { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("TYPE"); + OCCUR2(TYPE, 0, 1) } + | sour_file_sect { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("FILE"); + OCCUR2(FILE, 0, 1) } + | sour_plac_sect { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("PLAC"); + OCCUR2(PLAC, 0, 1) } + | sour_date_sect { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("DATE"); + OCCUR2(DATE, 0, 1) } + | sour_medi_sect { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("MEDI"); + OCCUR2(MEDI, 0, 1) } + | sour_page_sect { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("PAGE"); + OCCUR2(PAGE, 0, 1) } | source_repos_cit_sub /* 0:1 */ | multim_link_sub /* 0:M */ | note_struc_sub /* 0:M */ @@ -1770,6 +1789,90 @@ sour_text_sub : continuation_sub /* 0:M */ | no_std_sub ; +/* Only for compatibility */ +sour_type_sect : OPEN DELIM TAG_TYPE opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + +/* Only for compatibility */ +sour_file_sect : OPEN DELIM TAG_FILE opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + +/* Only for compatibility */ +sour_plac_sect : OPEN DELIM TAG_PLAC opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + +/* Only for compatibility */ +sour_date_sect : OPEN DELIM TAG_DATE opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + +/* Only for compatibility */ +sour_medi_sect : OPEN DELIM TAG_MEDI opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + +/* Only for compatibility */ +sour_page_sect : OPEN DELIM TAG_PAGE opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + /*********************************************************************/ /**** Submission record ****/ /*********************************************************************/ @@ -1919,11 +2022,14 @@ submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM $$ = start_record(REC_SUBM, $1, GEDCOM_MAKE_XREF_PTR(val1, xr), $5, NULL, GEDCOM_MAKE_NULL(val2)); - START(SUBM, $1, $$) } + START(SUBM, $1, $$) } subm_subs { CHECK1(NAME) } CLOSE - { end_record(REC_SUBM, $6, GEDCOM_MAKE_NULL(val1)); } + { end_record(REC_SUBM, $6, GEDCOM_MAKE_NULL(val1)); + if (compat_mode(C_SUBM_CTRY)) + compat_free_ctry_parent_context(); + } ; subm_subs : /* empty */ @@ -1937,6 +2043,9 @@ subm_sub : subm_name_sect { OCCUR2(NAME, 1, 1) } | subm_rfn_sect { OCCUR2(RFN, 0, 1) } | subm_rin_sect { OCCUR2(RIN, 0, 1) } | change_date_sub /* 0:1 */ + | subm_ctry_sect { if (!compat_mode(C_SUBM_CTRY)) + INVALID_TAG("CTRY"); + OCCUR2(CTRY, 0, 1) } | no_std_sub ; @@ -2000,6 +2109,19 @@ subm_rin_sect : OPEN DELIM TAG_RIN mand_line_item } ; +/* SUBM.CTRY (Only for compatibility) */ +subm_ctry_sect : OPEN DELIM TAG_CTRY opt_line_item + { if (compat_mode(C_SUBM_CTRY)) { + $$ = compat_generate_addr_ctry_start($1, $3, $4); + } + } + CLOSE + { if (compat_mode (C_SUBM_CTRY)) { + compat_generate_addr_ctry_end($5); + } + } + ; + /*********************************************************************/ /**** Substructures ****/ /*********************************************************************/ @@ -2015,7 +2137,9 @@ addr_sect : OPEN DELIM TAG_ADDR mand_line_item GEDCOM_MAKE_STRING(val1, $4)); reset_buffer(&concat_buffer); safe_buf_append(&concat_buffer, $4); - START(ADDR, $1, $$) + START(ADDR, $1, $$); + if (compat_mode(C_SUBM_CTRY)) + compat_save_ctry_parent_context($$); } addr_subs { CHECK0 } @@ -2327,7 +2451,7 @@ cont_sect : OPEN DELIM TAG_CONT opt_line_item safe_buf_append(&concat_buffer, $4); START(CONT, $1, $$) } - no_std_subs + cont_conc_subs { CHECK0 } CLOSE { end_element(ELT_SUB_CONT, PARENT, $5, @@ -2345,7 +2469,7 @@ conc_sect : OPEN DELIM TAG_CONC mand_line_item safe_buf_append(&concat_buffer, $4); START(CONC, $1, $$) } - no_std_subs + cont_conc_subs { CHECK0 } CLOSE { end_element(ELT_SUB_CONC, PARENT, $5, @@ -2353,6 +2477,33 @@ conc_sect : OPEN DELIM TAG_CONC mand_line_item } ; +cont_conc_subs : /* empty */ + | cont_conc_subs cont_conc_sub + ; + +cont_conc_sub : cont_conc_sour_sect { if (!compat_mode(C_NOTE_CONC_SOUR)) + INVALID_TAG("SOUR"); + OCCUR2(SOUR, 0, 1) } + | no_std_sub + ; + +/* Only for compatibility */ +cont_conc_sour_sect : OPEN DELIM TAG_SOUR DELIM POINTER + { if (compat_mode(C_NOTE_CONC_SOUR)) { + $$ + = compat_generate_note_sour_start(GRANDPARENT(1), + $1, $3, $5); + if ($$ == (void*)-1) HANDLE_ERROR; + } + } + no_std_subs + CLOSE + { if (compat_mode(C_NOTE_CONC_SOUR)) { + compat_generate_note_sour_end($6); + } + } + ; + /* EVENT DETAIL */ event_detail_sub : event_detail_type_sect { OCCUR2(TYPE, 0, 1) } | event_detail_date_sect { OCCUR2(DATE, 0, 1) } @@ -3189,14 +3340,19 @@ note_struc_link_sub : source_cit_sub ; note_struc_emb_sect : OPEN DELIM TAG_NOTE opt_line_item - { $$ + { char* str = $4; + if (compat_mode(C_NOTE_TOO_LONG)) + str = compat_long_line_get_prefix($4); + $$ = start_element(ELT_SUB_NOTE, - PARENT, $1, $3, $4, - GEDCOM_MAKE_NULL_OR_STRING(val1, $4)); + PARENT, $1, $3, str, + GEDCOM_MAKE_NULL_OR_STRING(val1, str)); reset_buffer(&concat_buffer); if ($4) safe_buf_append(&concat_buffer, $4); - START(NOTE, $1, $$) + START(NOTE, $1, $$); + if (compat_mode(C_NOTE_TOO_LONG)) + compat_long_line_finish($$, $1); } note_struc_emb_subs { CHECK0 } @@ -3573,22 +3729,41 @@ source_cit_emb_sub : continuation_sub /* SOURCE REPOSITORY CITATION */ source_repos_cit_sub : source_repos_repo_sect { OCCUR2(REPO, 0, 1) } + | source_repos_repo_txt_sect + { if (!compat_mode(C_NONSTD_SOUR_TAGS)) + INVALID_TAG("REPO"); + OCCUR2(REPO, 0, 1) + } ; -source_repos_repo_sect : OPEN DELIM TAG_REPO mand_pointer +/* Only for compatibility */ +source_repos_repo_txt_sect : OPEN DELIM TAG_REPO opt_line_item + { if (compat_mode(C_NONSTD_SOUR_TAGS)) { + $$ = + compat_generate_nonstd_sour_start(PARENT, $1, $3, $4, + &usertag_buffer); + } + } + CLOSE + { if (compat_mode(C_NONSTD_SOUR_TAGS)) + compat_generate_nonstd_sour_end(PARENT, $5); + } + ; + +source_repos_repo_sect : OPEN DELIM TAG_REPO DELIM POINTER { struct xref_value *xr - = gedcom_parse_xref($4, XREF_USED, XREF_REPO); - if (xr == NULL) HANDLE_ERROR; + = gedcom_parse_xref($5, XREF_USED, XREF_REPO); + if (xr == NULL) HANDLE_ERROR; $$ = start_element(ELT_SUB_REPO, - PARENT, $1, $3, $4, + PARENT, $1, $3, $5, GEDCOM_MAKE_XREF_PTR(val1, xr)); - START(REPO, $1, $$) - } + START(REPO, $1, $$); + } source_repos_repo_subs { CHECK0 } CLOSE - { end_element(ELT_SUB_REPO, PARENT, $5, + { end_element(ELT_SUB_REPO, PARENT, $6, GEDCOM_MAKE_NULL(val1)); } ; @@ -3690,8 +3865,11 @@ no_std_rec : user_rec /* 0:M */ user_rec : OPEN DELIM opt_xref USERTAG { if ($4.string[0] != '_') { - if (compat_mode(C_551_TAGS) - && compat_check_551_tag($4.string, &usertag_buffer)) { + if ((compat_mode(C_551_TAGS) + && compat_check_551_tag($4.string, &usertag_buffer)) + || + (compat_mode(C_NONSTD_SOUR_TAGS) + && compat_check_sour_tag($4.string, &usertag_buffer))) { $4.string = get_buf_string(&usertag_buffer); } else { @@ -3720,13 +3898,15 @@ user_rec : OPEN DELIM opt_xref USERTAG ; user_sect : OPEN DELIM opt_xref USERTAG { if ($4.string[0] != '_') { - if (compat_mode(C_551_TAGS) - && compat_check_551_tag($4.string, &usertag_buffer)) { - $4.string = get_buf_string(&usertag_buffer); - } - else if (compat_mode(C_SUBM_COMM) && - compat_check_subm_comm($4.string, get_parenttag(0), - &usertag_buffer)) { + if ((compat_mode(C_551_TAGS) + && compat_check_551_tag($4.string, &usertag_buffer)) + || + (compat_mode(C_SUBM_COMM) + && compat_check_subm_comm($4.string, get_parenttag(0), + &usertag_buffer)) + || + (compat_mode(C_NONSTD_SOUR_TAGS) + && compat_check_sour_tag($4.string, &usertag_buffer))) { $4.string = get_buf_string(&usertag_buffer); } else {