X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom.y;h=5416d50b67527e7193bbedb9159ee81dd5f9e86e;hb=fdcc3ac19960afc4ee198a82cb397afa34ca6a67;hp=389a8d8620a2984755ffb9e2cb28df299ff3a936;hpb=be41e74e82065afc92849a2ce5a1c51f69ded908;p=gedcom-parse.git diff --git a/gedcom.y b/gedcom.y index 389a8d8..5416d50 100644 --- a/gedcom.y +++ b/gedcom.y @@ -1,3 +1,12 @@ +/* This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + + (C) 2001 by The Genes Development Team + Original author: Peter Verthez (Peter.Verthez@advalvas.be) +*/ + /* $Id$ */ /* $Name$ */ @@ -122,9 +131,21 @@ %{ #include "gedcom.h" - -int count_level=0; -MECHANISM curr_mechanism=FAIL_PARSE; +#include "multilex.h" +#include "encoding.h" + +int count_level = 0; +int fail = 0; +int compat_enabled = 1; +int gedcom_high_level_debug = 0; +int compatibility = 0; +MECHANISM error_mechanism=IMMED_FAIL; +char string_buf[MAXGEDCLINELEN*4+1]; +char *string_buf_ptr; + +enum _COMPAT { + C_FTREE = 0x01 +}; /* These are defined at the bottom of the file */ void push_countarray(); @@ -133,8 +154,24 @@ char* get_parenttag(); void pop_countarray(); int count_tag(int tag); int check_occurrence(int tag); +void set_compatibility(char* program); +int compat_mode(int flags); + +#define CLEAR_BUFFER(BUF) { memset(BUF, 0, sizeof(BUF)); } -#define OPEN(PARENTTAG) \ +#define HANDLE_ERROR \ + { \ + if (error_mechanism == IMMED_FAIL) { \ + YYABORT; \ + } \ + else if (error_mechanism == DEFER_FAIL) { \ + yyerrok; fail = 1; \ + } \ + else if (error_mechanism == IGNORE_ERRORS) { \ + yyerrok; \ + } \ + } +#define START(PARENTTAG) \ { ++count_level; \ set_parenttag(#PARENTTAG); \ push_countarray(); \ @@ -142,9 +179,9 @@ int check_occurrence(int tag); #define CHK(TAG) \ { if (!check_occurrence(TAG_##TAG)) { \ char* parenttag = get_parenttag(); \ - gedcom_error("The tag '%s' is mandatory within '%s'", \ + gedcom_error("The tag '%s' is mandatory within '%s', but missing", \ #TAG, parenttag); \ - YYERROR; \ + HANDLE_ERROR; \ } \ } #define POP \ @@ -167,174 +204,182 @@ int check_occurrence(int tag); gedcom_error("The tag '%s' can maximally occur %d " \ "time(s) within '%s'", \ #CHILDTAG, MAX, parenttag); \ - YYERROR; \ + HANDLE_ERROR; \ } \ } #define INVALID_TAG(CHILDTAG) \ { char* parenttag = get_parenttag(); \ gedcom_error("The tag '%s' is not a valid tag within '%s'", \ CHILDTAG, parenttag); \ - YYERROR; \ + HANDLE_ERROR; \ } #define INVALID_TOP_TAG(CHILDTAG) \ { gedcom_error("The tag '%s' is not a valid top-level tag", \ CHILDTAG); \ - YYERROR; \ + HANDLE_ERROR; \ } %} %union { + int level; + char *pointer; + char *tag; char *string; } %token_table +%expect 300 %token BADTOKEN -%token OPEN +%token OPEN %token CLOSE %token ESCAPE %token DELIM %token ANYCHAR -%token POINTER -%token USERTAG -%token TAG_ABBR -%token TAG_ADDR -%token TAG_ADR1 -%token TAG_ADR2 -%token TAG_ADOP -%token TAG_AFN -%token TAG_AGE -%token TAG_AGNC -%token TAG_ALIA -%token TAG_ANCE -%token TAG_ANCI -%token TAG_ANUL -%token TAG_ASSO -%token TAG_AUTH -%token TAG_BAPL -%token TAG_BAPM -%token TAG_BARM -%token TAG_BASM -%token TAG_BIRT -%token TAG_BLES -%token TAG_BLOB -%token TAG_BURI -%token TAG_CALN -%token TAG_CAST -%token TAG_CAUS -%token TAG_CENS -%token TAG_CHAN -%token TAG_CHAR -%token TAG_CHIL -%token TAG_CHR -%token TAG_CHRA -%token TAG_CITY -%token TAG_CONC -%token TAG_CONF -%token TAG_CONL -%token TAG_CONT -%token TAG_COPR -%token TAG_CORP -%token TAG_CREM -%token TAG_CTRY -%token TAG_DATA -%token TAG_DATE -%token TAG_DEAT -%token TAG_DESC -%token TAG_DESI -%token TAG_DEST -%token TAG_DIV -%token TAG_DIVF -%token TAG_DSCR -%token TAG_EDUC -%token TAG_EMIG -%token TAG_ENDL -%token TAG_ENGA -%token TAG_EVEN -%token TAG_FAM -%token TAG_FAMC -%token TAG_FAMF -%token TAG_FAMS -%token TAG_FCOM -%token TAG_FILE -%token TAG_FORM -%token TAG_GEDC -%token TAG_GIVN -%token TAG_GRAD -%token TAG_HEAD -%token TAG_HUSB -%token TAG_IDNO -%token TAG_IMMI -%token TAG_INDI -%token TAG_LANG -%token TAG_LEGA -%token TAG_MARB -%token TAG_MARC -%token TAG_MARL -%token TAG_MARR -%token TAG_MARS -%token TAG_MEDI -%token TAG_NAME -%token TAG_NATI -%token TAG_NATU -%token TAG_NCHI -%token TAG_NICK -%token TAG_NMR -%token TAG_NOTE -%token TAG_NPFX -%token TAG_NSFX -%token TAG_OBJE -%token TAG_OCCU -%token TAG_ORDI -%token TAG_ORDN -%token TAG_PAGE -%token TAG_PEDI -%token TAG_PHON -%token TAG_PLAC -%token TAG_POST -%token TAG_PROB -%token TAG_PROP -%token TAG_PUBL -%token TAG_QUAY -%token TAG_REFN -%token TAG_RELA -%token TAG_RELI -%token TAG_REPO -%token TAG_RESI -%token TAG_RESN -%token TAG_RETI -%token TAG_RFN -%token TAG_RIN -%token TAG_ROLE -%token TAG_SEX -%token TAG_SLGC -%token TAG_SLGS -%token TAG_SOUR -%token TAG_SPFX -%token TAG_SSN -%token TAG_STAE -%token TAG_STAT -%token TAG_SUBM -%token TAG_SUBN -%token TAG_SURN -%token TAG_TEMP -%token TAG_TEXT -%token TAG_TIME -%token TAG_TITL -%token TAG_TRLR -%token TAG_TYPE -%token TAG_VERS -%token TAG_WIFE -%token TAG_WILL - -/* -%type anytag -*/ +%token POINTER +%token USERTAG +%token TAG_ABBR +%token TAG_ADDR +%token TAG_ADR1 +%token TAG_ADR2 +%token TAG_ADOP +%token TAG_AFN +%token TAG_AGE +%token TAG_AGNC +%token TAG_ALIA +%token TAG_ANCE +%token TAG_ANCI +%token TAG_ANUL +%token TAG_ASSO +%token TAG_AUTH +%token TAG_BAPL +%token TAG_BAPM +%token TAG_BARM +%token TAG_BASM +%token TAG_BIRT +%token TAG_BLES +%token TAG_BLOB +%token TAG_BURI +%token TAG_CALN +%token TAG_CAST +%token TAG_CAUS +%token TAG_CENS +%token TAG_CHAN +%token TAG_CHAR +%token TAG_CHIL +%token TAG_CHR +%token TAG_CHRA +%token TAG_CITY +%token TAG_CONC +%token TAG_CONF +%token TAG_CONL +%token TAG_CONT +%token TAG_COPR +%token TAG_CORP +%token TAG_CREM +%token TAG_CTRY +%token TAG_DATA +%token TAG_DATE +%token TAG_DEAT +%token TAG_DESC +%token TAG_DESI +%token TAG_DEST +%token TAG_DIV +%token TAG_DIVF +%token TAG_DSCR +%token TAG_EDUC +%token TAG_EMIG +%token TAG_ENDL +%token TAG_ENGA +%token TAG_EVEN +%token TAG_FAM +%token TAG_FAMC +%token TAG_FAMF +%token TAG_FAMS +%token TAG_FCOM +%token TAG_FILE +%token TAG_FORM +%token TAG_GEDC +%token TAG_GIVN +%token TAG_GRAD +%token TAG_HEAD +%token TAG_HUSB +%token TAG_IDNO +%token TAG_IMMI +%token TAG_INDI +%token TAG_LANG +%token TAG_LEGA +%token TAG_MARB +%token TAG_MARC +%token TAG_MARL +%token TAG_MARR +%token TAG_MARS +%token TAG_MEDI +%token TAG_NAME +%token TAG_NATI +%token TAG_NATU +%token TAG_NCHI +%token TAG_NICK +%token TAG_NMR +%token TAG_NOTE +%token TAG_NPFX +%token TAG_NSFX +%token TAG_OBJE +%token TAG_OCCU +%token TAG_ORDI +%token TAG_ORDN +%token TAG_PAGE +%token TAG_PEDI +%token TAG_PHON +%token TAG_PLAC +%token TAG_POST +%token TAG_PROB +%token TAG_PROP +%token TAG_PUBL +%token TAG_QUAY +%token TAG_REFN +%token TAG_RELA +%token TAG_RELI +%token TAG_REPO +%token TAG_RESI +%token TAG_RESN +%token TAG_RETI +%token TAG_RFN +%token TAG_RIN +%token TAG_ROLE +%token TAG_SEX +%token TAG_SLGC +%token TAG_SLGS +%token TAG_SOUR +%token TAG_SPFX +%token TAG_SSN +%token TAG_STAE +%token TAG_STAT +%token TAG_SUBM +%token TAG_SUBN +%token TAG_SURN +%token TAG_TEMP +%token TAG_TEXT +%token TAG_TIME +%token TAG_TITL +%token TAG_TRLR +%token TAG_TYPE +%token TAG_VERS +%token TAG_WIFE +%token TAG_WILL + +%type anystdtag +%type anytoptag +%type line_item +%type mand_line_item +%type note_line_item +%type anychar %% -file : head_sect records trlr_sect { } +file : head_sect records trlr_sect + { if (fail == 1) YYABORT; } ; records : /* empty */ @@ -349,16 +394,20 @@ record : fam_rec | source_rec | submis_rec | submit_rec - | user_sect /* 0:M */ - ; + | no_std_rec + ; /*********************************************************************/ /**** Header ****/ /*********************************************************************/ head_sect : OPEN DELIM TAG_HEAD - { OPEN(HEAD) } + { START(HEAD) } head_subs - { CHECK4(SOUR, SUBM, GEDC, CHAR) } + { if (compat_mode(C_FTREE)) + CHECK3(SOUR, GEDC, CHAR) + else + CHECK4(SOUR, SUBM, GEDC, CHAR) + } CLOSE { } ; @@ -378,16 +427,18 @@ head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) } | head_lang_sect { OCCUR2(LANG, 0, 1) } | head_plac_sect { OCCUR2(PLAC, 0, 1) } | head_note_sect { OCCUR2(NOTE, 0, 1) } - | user_sect /* 0:M */ + | no_std_sub ; /* HEAD.SOUR */ -head_sour_sect : OPEN DELIM TAG_SOUR DELIM line_item - { OPEN(SOUR) } +head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item + { set_compatibility($4); + gedcom_debug_print("===Source: '%s'\n", $4); + START(SOUR) + } head_sour_subs { CHECK0 } CLOSE - { } ; head_sour_subs : /* empty */ @@ -398,15 +449,22 @@ head_sour_sub : head_sour_vers_sect { OCCUR2(VERS, 0, 1) } | head_sour_name_sect { OCCUR2(NAME, 0, 1) } | head_sour_corp_sect { OCCUR2(CORP, 0, 1) } | head_sour_data_sect { OCCUR2(DATA, 0, 1) } + | no_std_sub ; -head_sour_vers_sect : OPEN DELIM TAG_VERS DELIM line_item CLOSE - { } + +head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item + { START(VERS)} no_std_subs { CHECK0 } CLOSE + { gedcom_debug_print("===Source version: '%s'\n", $4); + } ; -head_sour_name_sect : OPEN DELIM TAG_NAME DELIM line_item CLOSE - { } +head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item + { START(NAME) } no_std_subs { CHECK0 } CLOSE + { gedcom_debug_print("===Source name: '%s'\n", $4); + } ; -head_sour_corp_sect : OPEN DELIM TAG_CORP DELIM line_item - { OPEN(CORP) } +head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item + { gedcom_debug_print("===Source corp name: '%s'\n", $4); + START(CORP) } head_sour_corp_subs { CHECK0 } CLOSE @@ -418,10 +476,11 @@ head_sour_corp_subs : /* empty */ ; head_sour_corp_sub : addr_struc_sub /* 0:1 */ + | no_std_sub ; -head_sour_data_sect : OPEN DELIM TAG_DATA DELIM line_item - { OPEN(DATA) } +head_sour_data_sect : OPEN DELIM TAG_DATA mand_line_item + { START(DATA) } head_sour_data_subs { CHECK0 } CLOSE @@ -434,23 +493,27 @@ head_sour_data_subs : /* empty */ head_sour_data_sub : head_sour_data_date_sect { OCCUR2(DATE, 0, 1) } | head_sour_data_copr_sect { OCCUR2(COPR, 0, 1) } + | no_std_sub ; -head_sour_data_date_sect : OPEN DELIM TAG_DATE DELIM line_item CLOSE +head_sour_data_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } no_std_subs { CHECK0 } CLOSE { } ; -head_sour_data_copr_sect : OPEN DELIM TAG_COPR DELIM line_item CLOSE +head_sour_data_copr_sect : OPEN DELIM TAG_COPR mand_line_item + { START(COPR) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.DEST */ -head_dest_sect : OPEN DELIM TAG_DEST DELIM line_item CLOSE +head_dest_sect : OPEN DELIM TAG_DEST mand_line_item + { START(DEST) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.DATE */ -head_date_sect : OPEN DELIM TAG_DATE DELIM line_item - { OPEN(DATE) } +head_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } head_date_subs { CHECK0 } CLOSE @@ -462,31 +525,37 @@ head_date_subs : /* empty */ ; head_date_sub : head_date_time_sect { OCCUR2(TIME, 0, 1) } + | no_std_sub ; -head_date_time_sect : OPEN DELIM TAG_TIME DELIM line_item CLOSE +head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item + { START(TIME) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.SUBM */ -head_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER CLOSE +head_subm_sect : OPEN DELIM TAG_SUBM mand_pointer + { START(SUBM) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.SUBN */ -head_subn_sect : OPEN DELIM TAG_SUBN DELIM POINTER CLOSE +head_subn_sect : OPEN DELIM TAG_SUBN mand_pointer + { START(SUBN) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.FILE */ -head_file_sect : OPEN DELIM TAG_FILE DELIM line_item CLOSE +head_file_sect : OPEN DELIM TAG_FILE mand_line_item + { START(FILE) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.COPR */ -head_copr_sect : OPEN DELIM TAG_COPR DELIM line_item CLOSE +head_copr_sect : OPEN DELIM TAG_COPR mand_line_item + { START(COPR) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.GEDC */ head_gedc_sect : OPEN DELIM TAG_GEDC - { OPEN(GEDC) } + { START(GEDC) } head_gedc_subs { CHECK2(VERS, FORM) } CLOSE @@ -499,17 +568,21 @@ head_gedc_subs : /* empty */ head_gedc_sub : head_gedc_vers_sect { OCCUR2(VERS, 1, 1) } | head_gedc_form_sect { OCCUR2(FORM, 1, 1) } + | no_std_sub ; -head_gedc_vers_sect : OPEN DELIM TAG_VERS DELIM line_item CLOSE +head_gedc_vers_sect : OPEN DELIM TAG_VERS mand_line_item + { START(VERS) } no_std_subs { CHECK0 } CLOSE { } ; -head_gedc_form_sect : OPEN DELIM TAG_FORM DELIM line_item CLOSE +head_gedc_form_sect : OPEN DELIM TAG_FORM mand_line_item + { START(FORM) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.CHAR */ -head_char_sect : OPEN DELIM TAG_CHAR DELIM line_item - { OPEN(CHAR) } +head_char_sect : OPEN DELIM TAG_CHAR mand_line_item + { if (open_conv_to_internal($4) == 0) YYERROR; + START(CHAR) } head_char_subs { CHECK0 } CLOSE @@ -521,18 +594,21 @@ head_char_subs : /* empty */ ; head_char_sub : head_char_vers_sect { OCCUR2(VERS, 0, 1) } + | no_std_sub ; -head_char_vers_sect : OPEN DELIM TAG_VERS DELIM line_item CLOSE +head_char_vers_sect : OPEN DELIM TAG_VERS mand_line_item + { START(VERS) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.LANG */ -head_lang_sect : OPEN DELIM TAG_LANG DELIM line_item CLOSE +head_lang_sect : OPEN DELIM TAG_LANG mand_line_item + { START(LANG) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.PLAC */ head_plac_sect : OPEN DELIM TAG_PLAC - { OPEN(PLAC) } + { START(PLAC) } head_plac_subs { CHECK1(FORM) } CLOSE @@ -544,14 +620,16 @@ head_plac_subs : /* empty */ ; head_plac_sub : head_plac_form_sect { OCCUR2(FORM, 1, 1) } + | no_std_sub ; -head_plac_form_sect : OPEN DELIM TAG_FORM DELIM line_item CLOSE +head_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item + { START(FORM) } no_std_subs { CHECK0 } CLOSE { } ; /* HEAD.NOTE */ -head_note_sect : OPEN DELIM TAG_NOTE DELIM line_item - { OPEN(NOTE) } +head_note_sect : OPEN DELIM TAG_NOTE mand_line_item + { START(NOTE) } head_note_subs { CHECK0 } CLOSE @@ -563,6 +641,7 @@ head_note_subs : /* empty */ ; head_note_sub : continuation_sub /* 0:M */ + | no_std_sub ; /*********************************************************************/ @@ -575,7 +654,7 @@ trlr_sect : OPEN DELIM TAG_TRLR CLOSE { } /**** Family record ****/ /*********************************************************************/ fam_rec : OPEN DELIM POINTER DELIM TAG_FAM - { OPEN(FAM) } + { START(FAM) } fam_subs { CHECK0 } CLOSE { } @@ -597,31 +676,36 @@ fam_sub : fam_event_struc_sub /* 0:M */ | note_struc_sub /* 0:M */ | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | no_std_sub ; /* FAM.HUSB */ -fam_husb_sect : OPEN DELIM TAG_HUSB DELIM POINTER CLOSE +fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer + { START(HUSB) } no_std_subs { CHECK0 } CLOSE { } ; /* FAM.WIFE */ -fam_wife_sect : OPEN DELIM TAG_WIFE DELIM POINTER CLOSE +fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer + { START(WIFE) } no_std_subs { CHECK0 } CLOSE { } ; /* FAM.CHIL */ -fam_chil_sect : OPEN DELIM TAG_CHIL DELIM POINTER CLOSE +fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer + { START(CHIL) } no_std_subs { CHECK0 } CLOSE { } ; /* FAM.NCHI */ -fam_nchi_sect : OPEN DELIM TAG_NCHI DELIM line_item CLOSE +fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item + { START(NCHI) } no_std_subs { CHECK0 } CLOSE { } ; /* FAM.SUBM */ -fam_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER CLOSE +fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer + { START(SUBM) } no_std_subs { CHECK0 } CLOSE { } ; @@ -629,7 +713,7 @@ fam_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER CLOSE /**** Individual record ****/ /*********************************************************************/ indiv_rec : OPEN DELIM POINTER DELIM TAG_INDI - { OPEN(INDI) } + { START(INDI) } indi_subs { CHECK0 } CLOSE { } @@ -659,46 +743,61 @@ indi_sub : indi_resn_sect { OCCUR2(RESN, 0, 1) } | indi_afn_sect /* 0:M */ | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | ftree_addr_sect { if (!compat_mode(C_FTREE)) + INVALID_TAG("ADDR"); + } + | no_std_sub ; /* INDI.RESN */ -indi_resn_sect : OPEN DELIM TAG_RESN DELIM line_item CLOSE { } +indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item + { START(RESN) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.SEX */ -indi_sex_sect : OPEN DELIM TAG_SEX DELIM line_item CLOSE { } +indi_sex_sect : OPEN DELIM TAG_SEX mand_line_item + { START(SEX) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.SUBM */ -indi_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER CLOSE { } +indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer + { START(SUBM) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.ALIA */ -indi_alia_sect : OPEN DELIM TAG_ALIA DELIM POINTER CLOSE { } +indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer + { START(ALIA) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.ANCI */ -indi_anci_sect : OPEN DELIM TAG_ANCI DELIM POINTER CLOSE { } +indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer + { START(ANCI) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.DESI */ -indi_desi_sect : OPEN DELIM TAG_DESI DELIM POINTER CLOSE { } +indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer + { START(DESI) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.RFN */ -indi_rfn_sect : OPEN DELIM TAG_RFN DELIM line_item CLOSE { } +indi_rfn_sect : OPEN DELIM TAG_RFN mand_line_item + { START(RFN) } no_std_subs { CHECK0 } CLOSE { } ; /* INDI.AFN */ -indi_afn_sect : OPEN DELIM TAG_AFN DELIM line_item CLOSE { } +indi_afn_sect : OPEN DELIM TAG_AFN mand_line_item + { START(AFN) } no_std_subs { CHECK0 } CLOSE { } ; +/* INDI.ADDR (Only for 'ftree' compatibility) */ +ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item + { START(ADDR) } no_std_subs { CHECK0 } CLOSE { } + /*********************************************************************/ /**** Multimedia record ****/ /*********************************************************************/ multim_rec : OPEN DELIM POINTER DELIM TAG_OBJE - { OPEN(OBJE) } + { START(OBJE) } obje_subs { CHECK2(FORM, BLOB) } CLOSE { } @@ -715,20 +814,22 @@ obje_sub : obje_form_sect { OCCUR2(FORM, 1, 1) } | obje_obje_sect { OCCUR2(OBJE, 0, 1) } | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | no_std_sub ; /* OBJE.FORM */ -obje_form_sect : OPEN DELIM TAG_FORM DELIM line_item CLOSE { } +obje_form_sect : OPEN DELIM TAG_FORM mand_line_item + { START(FORM) } no_std_subs { CHECK0 } CLOSE { } ; /* OBJE.TITL */ -obje_titl_sect : OPEN DELIM TAG_TITL DELIM line_item CLOSE { } +obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item + { START(TITL) } no_std_subs { CHECK0 } CLOSE { } ; /* OBJE.BLOB */ obje_blob_sect : OPEN DELIM TAG_BLOB - { OPEN(BLOB) } + { START(BLOB) } obje_blob_subs { CHECK1(CONT) } CLOSE { } @@ -739,25 +840,38 @@ obje_blob_subs : /* empty */ ; obje_blob_sub : obje_blob_cont_sect { OCCUR1(CONT, 1) } + | no_std_sub ; -obje_blob_cont_sect : OPEN DELIM TAG_CONT DELIM line_item CLOSE { } +obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item + { START(CONT) } no_std_subs { CHECK0 } CLOSE { } ; /* OBJE.OBJE */ -obje_obje_sect : OPEN DELIM TAG_OBJE DELIM POINTER CLOSE { } +obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer + { START(OBJE) } no_std_subs { CHECK0 } CLOSE { } ; /*********************************************************************/ /**** Note record ****/ /*********************************************************************/ -note_rec : OPEN DELIM POINTER DELIM TAG_NOTE DELIM line_item - { OPEN(NOTE) } +note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item + { START(NOTE) } note_subs { CHECK0 } CLOSE { } ; +note_line_item : /* empty */ + { if (!compat_mode(C_FTREE)) { + gedcom_error("Missing value"); YYERROR; + } + } + | DELIM line_item + { gedcom_debug_print("==Val: %s==\n", $2); + $$ = $2; } + ; + note_subs : /* empty */ | note_subs note_sub ; @@ -766,14 +880,14 @@ note_sub : continuation_sub /* 0:M */ | source_cit_sub /* 0:M */ | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | no_std_sub ; /*********************************************************************/ /**** Repository record ****/ /*********************************************************************/ repos_rec : OPEN DELIM POINTER DELIM TAG_REPO - { OPEN(REPO) } + { START(REPO) } repo_subs { CHECK0 } CLOSE { } @@ -788,18 +902,19 @@ repo_sub : repo_name_sect { OCCUR2(NAME, 0, 1) } | note_struc_sub /* 0:M */ | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | no_std_sub ; /* REPO.NAME */ -repo_name_sect : OPEN DELIM TAG_NAME DELIM line_item CLOSE {} +repo_name_sect : OPEN DELIM TAG_NAME mand_line_item + { START(NAME) } no_std_subs { CHECK0 } CLOSE {} ; /*********************************************************************/ /**** Source record ****/ /*********************************************************************/ source_rec : OPEN DELIM POINTER DELIM TAG_SOUR - { OPEN(SOUR) } + { START(SOUR) } sour_subs { CHECK0 } CLOSE { } @@ -820,12 +935,12 @@ sour_sub : sour_data_sect { OCCUR2(DATA, 0, 1) } | note_struc_sub /* 0:M */ | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | no_std_sub ; /* SOUR.DATA */ sour_data_sect : OPEN DELIM TAG_DATA - { OPEN(DATA) } + { START(DATA) } sour_data_subs { CHECK0 } CLOSE { } @@ -838,10 +953,11 @@ sour_data_subs : /* empty */ sour_data_sub : sour_data_even_sect /* 0:M */ | sour_data_agnc_sect { OCCUR2(AGNC, 0, 1) } | note_struc_sub /* 0:M */ + | no_std_sub ; -sour_data_even_sect : OPEN DELIM TAG_EVEN DELIM line_item - { OPEN(EVEN) } +sour_data_even_sect : OPEN DELIM TAG_EVEN mand_line_item + { START(EVEN) } sour_data_even_subs { CHECK0 } CLOSE { } @@ -853,20 +969,24 @@ sour_data_even_subs : /* empty */ sour_data_even_sub : sour_data_even_date_sect { OCCUR2(DATE, 0, 1) } | sour_data_even_plac_sect { OCCUR2(PLAC, 0, 1) } + | no_std_sub ; -sour_data_even_date_sect : OPEN DELIM TAG_DATE DELIM line_item CLOSE { } +sour_data_even_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } no_std_subs { CHECK0 } CLOSE { } ; -sour_data_even_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item CLOSE { } +sour_data_even_plac_sect : OPEN DELIM TAG_PLAC mand_line_item + { START(PLAC) } no_std_subs { CHECK0 } CLOSE { } ; -sour_data_agnc_sect : OPEN DELIM TAG_AGNC DELIM line_item CLOSE { } +sour_data_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item + { START(AGNC) } no_std_subs { CHECK0 } CLOSE { } ; /* SOUR.AUTH */ -sour_auth_sect : OPEN DELIM TAG_AUTH DELIM line_item - { OPEN(AUTH) } +sour_auth_sect : OPEN DELIM TAG_AUTH mand_line_item + { START(AUTH) } sour_auth_subs { CHECK0 } CLOSE { } @@ -877,11 +997,12 @@ sour_auth_subs : /* empty */ ; sour_auth_sub : continuation_sub /* 0:M */ + | no_std_sub ; /* SOUR.TITL */ -sour_titl_sect : OPEN DELIM TAG_TITL DELIM line_item - { OPEN(TITL) } +sour_titl_sect : OPEN DELIM TAG_TITL mand_line_item + { START(TITL) } sour_titl_subs { CHECK0 } CLOSE { } @@ -892,15 +1013,17 @@ sour_titl_subs : /* empty */ ; sour_titl_sub : continuation_sub /* 0:M */ + | no_std_sub ; /* SOUR.ABBR */ -sour_abbr_sect : OPEN DELIM TAG_ABBR DELIM line_item CLOSE { } +sour_abbr_sect : OPEN DELIM TAG_ABBR mand_line_item + { START(ABBR) } no_std_subs { CHECK0 } CLOSE { } ; /* SOUR.PUBL */ -sour_publ_sect : OPEN DELIM TAG_PUBL DELIM line_item - { OPEN(PUBL) } +sour_publ_sect : OPEN DELIM TAG_PUBL mand_line_item + { START(PUBL) } sour_publ_subs { CHECK0 } CLOSE { } @@ -911,11 +1034,12 @@ sour_publ_subs : /* empty */ ; sour_publ_sub : continuation_sub /* 0:M */ + | no_std_sub ; /* SOUR.TEXT */ -sour_text_sect : OPEN DELIM TAG_TEXT DELIM line_item - { OPEN(TEXT) } +sour_text_sect : OPEN DELIM TAG_TEXT mand_line_item + { START(TEXT) } sour_text_subs { CHECK0 } CLOSE { } @@ -926,13 +1050,14 @@ sour_text_subs : /* empty */ ; sour_text_sub : continuation_sub /* 0:M */ + | no_std_sub ; /*********************************************************************/ /**** Submission record ****/ /*********************************************************************/ submis_rec : OPEN DELIM POINTER DELIM TAG_SUBN - { OPEN(SUBN) } + { START(SUBN) } subn_subs { CHECK0 } CLOSE { } @@ -949,42 +1074,49 @@ subn_sub : subn_subm_sect { OCCUR2(SUBM, 0, 1) } | subn_desc_sect { OCCUR2(DESC, 0, 1) } | subn_ordi_sect { OCCUR2(ORDI, 0, 1) } | subn_rin_sect { OCCUR2(RIN, 0, 1) } - | user_sect /* 0:M */ + | no_std_sub ; /* SUBN.SUBM */ -subn_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER CLOSE { } +subn_subm_sect : OPEN DELIM TAG_SUBM mand_pointer + { START(SUBM) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBN.FAMF */ -subn_famf_sect : OPEN DELIM TAG_FAMF DELIM line_item CLOSE { } +subn_famf_sect : OPEN DELIM TAG_FAMF mand_line_item + { START(FAMF) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBN.TEMP */ -subn_temp_sect : OPEN DELIM TAG_TEMP DELIM line_item CLOSE { } +subn_temp_sect : OPEN DELIM TAG_TEMP mand_line_item + { START(TEMP) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBN.ANCE */ -subn_ance_sect : OPEN DELIM TAG_ANCE DELIM line_item CLOSE { } +subn_ance_sect : OPEN DELIM TAG_ANCE mand_line_item + { START(ANCE) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBN.DESC */ -subn_desc_sect : OPEN DELIM TAG_DESC DELIM line_item CLOSE { } +subn_desc_sect : OPEN DELIM TAG_DESC mand_line_item + { START(DESC) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBN.ORDI */ -subn_ordi_sect : OPEN DELIM TAG_ORDI DELIM line_item CLOSE { } +subn_ordi_sect : OPEN DELIM TAG_ORDI mand_line_item + { START(ORDI) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBN.RIN */ -subn_rin_sect : OPEN DELIM TAG_RIN DELIM line_item CLOSE { } +subn_rin_sect : OPEN DELIM TAG_RIN mand_line_item + { START(RIN) } no_std_subs { CHECK0 } CLOSE { } ; /*********************************************************************/ /**** Submitter record ****/ /*********************************************************************/ submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM - { OPEN(SUBM) } + { START(SUBM) } subm_subs { CHECK1(NAME) } CLOSE { } @@ -1001,23 +1133,27 @@ subm_sub : subm_name_sect { OCCUR2(NAME, 0, 1) } | subm_rfn_sect { OCCUR2(RFN, 0, 1) } | subm_rin_sect { OCCUR2(RIN, 0, 1) } | change_date_sub /* 0:1 */ - | user_sect /* 0:M */ + | no_std_sub ; /* SUBM.NAME */ -subm_name_sect : OPEN DELIM TAG_NAME DELIM line_item CLOSE { } +subm_name_sect : OPEN DELIM TAG_NAME mand_line_item + { START(NAME) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBM.LANG */ -subm_lang_sect : OPEN DELIM TAG_LANG DELIM line_item CLOSE { } +subm_lang_sect : OPEN DELIM TAG_LANG mand_line_item + { START(LANG) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBM.RFN */ -subm_rfn_sect : OPEN DELIM TAG_RFN DELIM line_item CLOSE { } +subm_rfn_sect : OPEN DELIM TAG_RFN mand_line_item + { START(RFN) } no_std_subs { CHECK0 } CLOSE { } ; /* SUBM.RIN */ -subm_rin_sect : OPEN DELIM TAG_RIN DELIM line_item CLOSE { } +subm_rin_sect : OPEN DELIM TAG_RIN mand_line_item + { START(RIN) } no_std_subs { CHECK0 } CLOSE { } ; /*********************************************************************/ @@ -1029,8 +1165,8 @@ addr_struc_sub : addr_sect { OCCUR2(ADDR, 0, 1) } | phon_sect { OCCUR2(PHON, 0, 3) } ; -addr_sect : OPEN DELIM TAG_ADDR DELIM line_item - { OPEN(ADDR) } +addr_sect : OPEN DELIM TAG_ADDR mand_line_item + { START(ADDR) } addr_subs { CHECK0 } CLOSE { } @@ -1047,32 +1183,41 @@ addr_sub : addr_cont_sect /* 0:M */ | addr_stae_sect { OCCUR2(STAE, 0, 1) } | addr_post_sect { OCCUR2(POST, 0, 1) } | addr_ctry_sect { OCCUR2(CTRY, 0, 1) } + | no_std_sub ; -addr_cont_sect : OPEN DELIM TAG_CONT DELIM line_item CLOSE { } +addr_cont_sect : OPEN DELIM TAG_CONT mand_line_item + { START(CONT) } no_std_subs { CHECK0 } CLOSE { } ; -addr_adr1_sect : OPEN DELIM TAG_ADR1 DELIM line_item CLOSE { } +addr_adr1_sect : OPEN DELIM TAG_ADR1 mand_line_item + { START(ADR1) } no_std_subs { CHECK0 } CLOSE { } ; -addr_adr2_sect : OPEN DELIM TAG_ADR2 DELIM line_item CLOSE { } +addr_adr2_sect : OPEN DELIM TAG_ADR2 mand_line_item + { START(ADR2) } no_std_subs { CHECK0 } CLOSE { } ; -addr_city_sect : OPEN DELIM TAG_CITY DELIM line_item CLOSE { } +addr_city_sect : OPEN DELIM TAG_CITY mand_line_item + { START(CITY) } no_std_subs { CHECK0 } CLOSE { } ; -addr_stae_sect : OPEN DELIM TAG_STAE DELIM line_item CLOSE { } +addr_stae_sect : OPEN DELIM TAG_STAE mand_line_item + { START(STAE) } no_std_subs { CHECK0 } CLOSE { } ; -addr_post_sect : OPEN DELIM TAG_POST DELIM line_item CLOSE { } +addr_post_sect : OPEN DELIM TAG_POST mand_line_item + { START(POST) } no_std_subs { CHECK0 } CLOSE { } ; -addr_ctry_sect : OPEN DELIM TAG_CTRY DELIM line_item CLOSE { } +addr_ctry_sect : OPEN DELIM TAG_CTRY mand_line_item + { START(CTRY) } no_std_subs { CHECK0 } CLOSE { } ; -phon_sect : OPEN DELIM TAG_PHON DELIM line_item CLOSE { } +phon_sect : OPEN DELIM TAG_PHON mand_line_item + { START(PHON) } no_std_subs { CHECK0 } CLOSE { } ; /* ASSOCIATION STRUCTURE */ assoc_struc_sub : asso_sect /* 0:M */ ; -asso_sect : OPEN DELIM TAG_ASSO DELIM POINTER - { OPEN(ASSO) } +asso_sect : OPEN DELIM TAG_ASSO mand_pointer + { START(ASSO) } asso_subs { CHECK2(TYPE,RELA) } CLOSE { } @@ -1083,12 +1228,15 @@ asso_subs : /* empty */ | asso_rela_sect { OCCUR2(RELA, 1, 1) } | note_struc_sub | source_cit_sub + | no_std_sub ; -asso_type_sect : OPEN DELIM TAG_TYPE DELIM line_item CLOSE { } +asso_type_sect : OPEN DELIM TAG_TYPE mand_line_item + { START(TYPE) } no_std_subs { CHECK0 } CLOSE { } ; -asso_rela_sect : OPEN DELIM TAG_RELA DELIM line_item CLOSE { } +asso_rela_sect : OPEN DELIM TAG_RELA mand_line_item + { START(RELA) } no_std_subs { CHECK0 } CLOSE { } ; /* CHANGE DATE */ @@ -1096,7 +1244,7 @@ change_date_sub : change_date_chan_sect { OCCUR2(CHAN, 0, 1) } ; change_date_chan_sect : OPEN DELIM TAG_CHAN - { OPEN(CHAN) } + { START(CHAN) } change_date_chan_subs { CHECK1(DATE) } CLOSE { } @@ -1108,10 +1256,11 @@ change_date_chan_subs : /* empty */ change_date_chan_sub : change_date_date_sect { OCCUR2(DATE, 1, 1) } | note_struc_sub + | no_std_sub ; -change_date_date_sect : OPEN DELIM TAG_DATE DELIM line_item - { OPEN(DATE) } +change_date_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } change_date_date_subs { CHECK0 } CLOSE { } @@ -1122,17 +1271,19 @@ change_date_date_subs : /* empty */ ; change_date_date_sub : change_date_date_time_sect { OCCUR2(TIME, 0, 1) } + | no_std_sub ; -change_date_date_time_sect : OPEN DELIM TAG_TIME DELIM line_item CLOSE { } +change_date_date_time_sect : OPEN DELIM TAG_TIME mand_line_item + { START(TIME) } no_std_subs { CHECK0 } CLOSE { } ; /* CHILD TO FAMILY LINK */ chi_fam_link_sub : famc_sect /* 0:M */ ; -famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER - { OPEN(FAMC) } +famc_sect : OPEN DELIM TAG_FAMC mand_pointer + { START(FAMC) } famc_subs { CHECK0 } CLOSE { } @@ -1144,9 +1295,11 @@ famc_subs : /* empty */ famc_sub : famc_pedi_sect /* 0:M */ | note_struc_sub + | no_std_sub ; -famc_pedi_sect : OPEN DELIM TAG_PEDI DELIM line_item CLOSE { } +famc_pedi_sect : OPEN DELIM TAG_PEDI mand_line_item + { START(PEDI) } no_std_subs { CHECK0 } CLOSE { } ; /* CONTINUATION SUBSECTIONS */ @@ -1154,10 +1307,12 @@ continuation_sub : cont_sect /* 0:M */ | conc_sect /* 0:M */ ; -cont_sect : OPEN DELIM TAG_CONT DELIM line_item CLOSE { } +cont_sect : OPEN DELIM TAG_CONT mand_line_item + { START(CONT) } no_std_subs { CHECK0 } CLOSE { } ; -conc_sect : OPEN DELIM TAG_CONC DELIM line_item CLOSE { } +conc_sect : OPEN DELIM TAG_CONC mand_line_item + { START(CONC) } no_std_subs { CHECK0 } CLOSE { } ; /* EVENT DETAIL */ @@ -1173,15 +1328,20 @@ event_detail_sub : event_detail_type_sect { OCCUR2(TYPE, 0, 1) } | note_struc_sub ; -event_detail_type_sect : OPEN DELIM TAG_TYPE DELIM line_item CLOSE { } +event_detail_type_sect : OPEN DELIM TAG_TYPE mand_line_item + { START(TYPE) } no_std_subs { CHECK0 } CLOSE { } ; -event_detail_date_sect : OPEN DELIM TAG_DATE DELIM line_item CLOSE { } +event_detail_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } no_std_subs { CHECK0 } CLOSE { } ; -event_detail_age_sect : OPEN DELIM TAG_AGE DELIM line_item CLOSE { } +event_detail_age_sect : OPEN DELIM TAG_AGE mand_line_item + { START(AGE) } no_std_subs { CHECK0 } CLOSE { } ; -event_detail_agnc_sect : OPEN DELIM TAG_AGNC DELIM line_item CLOSE { } +event_detail_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item + { START(AGNC) } no_std_subs { CHECK0 } CLOSE { } ; -event_detail_caus_sect : OPEN DELIM TAG_CAUS DELIM line_item CLOSE { } +event_detail_caus_sect : OPEN DELIM TAG_CAUS mand_line_item + { START(CAUS) } no_std_subs { CHECK0 } CLOSE { } ; /* FAMILY EVENT STRUCTURE */ @@ -1194,16 +1354,16 @@ fam_event_sect : OPEN DELIM fam_event_tag opt_value fam_event_subs CLOSE { } ; -fam_event_tag : TAG_ANUL { OPEN(ANUL) } - | TAG_CENS { OPEN(CENS) } - | TAG_DIV { OPEN(DIV) } - | TAG_DIVF { OPEN(DIVF) } - | TAG_ENGA { OPEN(ENGA) } - | TAG_MARR { OPEN(MARR) } - | TAG_MARB { OPEN(MARB) } - | TAG_MARC { OPEN(MARC) } - | TAG_MARL { OPEN(MARL) } - | TAG_MARS { OPEN(MARS) } +fam_event_tag : TAG_ANUL { START(ANUL) } + | TAG_CENS { START(CENS) } + | TAG_DIV { START(DIV) } + | TAG_DIVF { START(DIVF) } + | TAG_ENGA { START(ENGA) } + | TAG_MARR { START(MARR) } + | TAG_MARB { START(MARB) } + | TAG_MARC { START(MARC) } + | TAG_MARL { START(MARL) } + | TAG_MARS { START(MARS) } ; fam_event_subs : /* empty */ @@ -1213,10 +1373,11 @@ fam_event_subs : /* empty */ fam_event_sub : event_detail_sub | fam_even_husb_sect { OCCUR2(HUSB, 0, 1) } | fam_even_wife_sect { OCCUR2(WIFE, 0, 1) } + | no_std_sub ; fam_even_husb_sect : OPEN DELIM TAG_HUSB - { OPEN(HUSB) } + { START(HUSB) } fam_even_husb_subs { CHECK1(AGE) } CLOSE { } @@ -1227,20 +1388,22 @@ fam_even_husb_subs : /* empty */ ; fam_even_husb_sub : fam_even_husb_age_sect { OCCUR2(AGE, 1, 1) } + | no_std_sub ; -fam_even_husb_age_sect : OPEN DELIM TAG_AGE DELIM line_item CLOSE { } +fam_even_husb_age_sect : OPEN DELIM TAG_AGE mand_line_item + { START(AGE) } no_std_subs { CHECK0 } CLOSE { } ; fam_even_wife_sect : OPEN DELIM TAG_WIFE - { OPEN(HUSB) } + { START(HUSB) } fam_even_husb_subs { CHECK1(AGE) } CLOSE { } ; fam_gen_even_sect : OPEN DELIM TAG_EVEN - { OPEN(EVEN) } + { START(EVEN) } fam_gen_even_subs { CHECK0 } CLOSE { } @@ -1253,6 +1416,7 @@ fam_gen_even_subs : /* empty */ fam_gen_even_sub : event_detail_sub | fam_even_husb_sect { OCCUR2(HUSB, 0, 1) } | fam_even_wife_sect { OCCUR2(WIFE, 0, 1) } + | no_std_sub ; /* IDENTIFICATION STRUCTURE */ @@ -1260,8 +1424,8 @@ ident_struc_sub : ident_refn_sect /* 0:M */ | ident_rin_sect { OCCUR2(RIN, 0, 1) } ; -ident_refn_sect : OPEN DELIM TAG_REFN DELIM line_item - { OPEN(REFN) } +ident_refn_sect : OPEN DELIM TAG_REFN mand_line_item + { START(REFN) } ident_refn_subs { CHECK0 } CLOSE { } @@ -1272,12 +1436,15 @@ ident_refn_subs : /* empty */ ; ident_refn_sub : ident_refn_type_sect { OCCUR2(TYPE, 0, 1) } + | no_std_sub ; -ident_refn_type_sect : OPEN DELIM TAG_TYPE DELIM line_item CLOSE { } +ident_refn_type_sect : OPEN DELIM TAG_TYPE mand_line_item + { START(TYPE) } no_std_subs { CHECK0 } CLOSE { } ; -ident_rin_sect : OPEN DELIM TAG_RIN DELIM line_item CLOSE { } +ident_rin_sect : OPEN DELIM TAG_RIN mand_line_item + { START(RIN) } no_std_subs { CHECK0 } CLOSE { } ; /* INDIVIDUAL ATTRIBUTE STRUCTURE */ @@ -1296,80 +1463,80 @@ indiv_attr_struc_sub : indiv_cast_sect /* 0:M */ | indiv_titl_sect /* 0:M */ ; -indiv_cast_sect : OPEN DELIM TAG_CAST DELIM line_item - { OPEN(CAST) } +indiv_cast_sect : OPEN DELIM TAG_CAST mand_line_item + { START(CAST) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_dscr_sect : OPEN DELIM TAG_DSCR DELIM line_item - { OPEN(DSCR) } +indiv_dscr_sect : OPEN DELIM TAG_DSCR mand_line_item + { START(DSCR) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_educ_sect : OPEN DELIM TAG_EDUC DELIM line_item - { OPEN(EDUC) } +indiv_educ_sect : OPEN DELIM TAG_EDUC mand_line_item + { START(EDUC) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_idno_sect : OPEN DELIM TAG_IDNO DELIM line_item - { OPEN(IDNO) } +indiv_idno_sect : OPEN DELIM TAG_IDNO mand_line_item + { START(IDNO) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_nati_sect : OPEN DELIM TAG_NATI DELIM line_item - { OPEN(NATI) } +indiv_nati_sect : OPEN DELIM TAG_NATI mand_line_item + { START(NATI) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_nchi_sect : OPEN DELIM TAG_NCHI DELIM line_item - { OPEN(NCHI) } +indiv_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item + { START(NCHI) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_nmr_sect : OPEN DELIM TAG_NMR DELIM line_item - { OPEN(NMR) } +indiv_nmr_sect : OPEN DELIM TAG_NMR mand_line_item + { START(NMR) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_occu_sect : OPEN DELIM TAG_OCCU DELIM line_item - { OPEN(OCCU) } +indiv_occu_sect : OPEN DELIM TAG_OCCU mand_line_item + { START(OCCU) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_prop_sect : OPEN DELIM TAG_PROP DELIM line_item - { OPEN(PROP) } +indiv_prop_sect : OPEN DELIM TAG_PROP mand_line_item + { START(PROP) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_reli_sect : OPEN DELIM TAG_RELI DELIM line_item - { OPEN(RELI) } +indiv_reli_sect : OPEN DELIM TAG_RELI mand_line_item + { START(RELI) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; indiv_resi_sect : OPEN DELIM TAG_RESI - { OPEN(RESI) } + { START(RESI) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_ssn_sect : OPEN DELIM TAG_SSN DELIM line_item - { OPEN(SSN) } +indiv_ssn_sect : OPEN DELIM TAG_SSN mand_line_item + { START(SSN) } indiv_attr_event_subs { CHECK0 } CLOSE { } ; -indiv_titl_sect : OPEN DELIM TAG_TITL DELIM line_item - { OPEN(TITL) } +indiv_titl_sect : OPEN DELIM TAG_TITL mand_line_item + { START(TITL) } indiv_attr_event_subs { CHECK0 } CLOSE { } @@ -1380,6 +1547,7 @@ indiv_attr_event_subs : /* empty */ ; indiv_attr_event_sub : event_detail_sub + | no_std_sub ; /* INDIVIDUAL EVENT STRUCTURE */ @@ -1394,8 +1562,8 @@ indiv_birt_sect : OPEN DELIM indiv_birt_tag opt_value indiv_birt_subs CLOSE { } ; -indiv_birt_tag : TAG_BIRT { OPEN(BIRT) } - | TAG_CHR { OPEN(CHR) } +indiv_birt_tag : TAG_BIRT { START(BIRT) } + | TAG_CHR { START(CHR) } ; indiv_birt_subs : /* empty */ @@ -1404,9 +1572,11 @@ indiv_birt_subs : /* empty */ indiv_birt_sub : event_detail_sub | indiv_birt_famc_sect { OCCUR2(FAMC,0, 1) } + | no_std_sub ; -indiv_birt_famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER CLOSE { } +indiv_birt_famc_sect : OPEN DELIM TAG_FAMC mand_pointer + { START(FAMC) } no_std_subs { CHECK0 } CLOSE { } ; indiv_gen_sect : OPEN DELIM indiv_gen_tag opt_value indiv_gen_subs @@ -1414,25 +1584,25 @@ indiv_gen_sect : OPEN DELIM indiv_gen_tag opt_value indiv_gen_subs CLOSE { } ; -indiv_gen_tag : TAG_DEAT { OPEN(DEAT) } - | TAG_BURI { OPEN(BURI) } - | TAG_CREM { OPEN(CREM) } - | TAG_BAPM { OPEN(BAPM) } - | TAG_BARM { OPEN(BARM) } - | TAG_BASM { OPEN(BASM) } - | TAG_BLES { OPEN(BLES) } - | TAG_CHRA { OPEN(CHRA) } - | TAG_CONF { OPEN(CONF) } - | TAG_FCOM { OPEN(FCOM) } - | TAG_ORDN { OPEN(ORDN) } - | TAG_NATU { OPEN(NATU) } - | TAG_EMIG { OPEN(EMIG) } - | TAG_IMMI { OPEN(IMMI) } - | TAG_CENS { OPEN(CENS) } - | TAG_PROB { OPEN(PROB) } - | TAG_WILL { OPEN(WILL) } - | TAG_GRAD { OPEN(GRAD) } - | TAG_RETI { OPEN(RETI) } +indiv_gen_tag : TAG_DEAT { START(DEAT) } + | TAG_BURI { START(BURI) } + | TAG_CREM { START(CREM) } + | TAG_BAPM { START(BAPM) } + | TAG_BARM { START(BARM) } + | TAG_BASM { START(BASM) } + | TAG_BLES { START(BLES) } + | TAG_CHRA { START(CHRA) } + | TAG_CONF { START(CONF) } + | TAG_FCOM { START(FCOM) } + | TAG_ORDN { START(ORDN) } + | TAG_NATU { START(NATU) } + | TAG_EMIG { START(EMIG) } + | TAG_IMMI { START(IMMI) } + | TAG_CENS { START(CENS) } + | TAG_PROB { START(PROB) } + | TAG_WILL { START(WILL) } + | TAG_GRAD { START(GRAD) } + | TAG_RETI { START(RETI) } ; indiv_gen_subs : /* empty */ @@ -1440,10 +1610,11 @@ indiv_gen_subs : /* empty */ ; indiv_gen_sub : event_detail_sub + | no_std_sub ; indiv_adop_sect : OPEN DELIM TAG_ADOP opt_value - { OPEN(ADOP) } + { START(ADOP) } indiv_adop_subs { CHECK0 } CLOSE { } @@ -1455,10 +1626,11 @@ indiv_adop_subs : /* empty */ indiv_adop_sub : event_detail_sub | indiv_adop_famc_sect { OCCUR2(FAMC,0, 1) } + | no_std_sub ; -indiv_adop_famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER - { OPEN(FAMC) } +indiv_adop_famc_sect : OPEN DELIM TAG_FAMC mand_pointer + { START(FAMC) } indiv_adop_famc_subs { CHECK0 } CLOSE { } @@ -1469,13 +1641,15 @@ indiv_adop_famc_subs : /* empty */ ; indiv_adop_famc_sub : indiv_adop_famc_adop_sect { OCCUR2(ADOP,0, 1) } + | no_std_sub ; -indiv_adop_famc_adop_sect : OPEN DELIM TAG_ADOP DELIM line_item CLOSE { } +indiv_adop_famc_adop_sect : OPEN DELIM TAG_ADOP mand_line_item + { START(ADOP) } no_std_subs { CHECK0 } CLOSE { } ; indiv_even_sect : OPEN DELIM TAG_EVEN - { OPEN(EVEN) } + { START(EVEN) } indiv_gen_subs { CHECK0 } CLOSE { } @@ -1491,9 +1665,9 @@ lio_bapl_sect : OPEN DELIM lio_bapl_tag lio_bapl_subs CLOSE { } ; -lio_bapl_tag : TAG_BAPL { OPEN(BAPL) } - | TAG_CONL { OPEN(CONL) } - | TAG_ENDL { OPEN(ENDL) } +lio_bapl_tag : TAG_BAPL { START(BAPL) } + | TAG_CONL { START(CONL) } + | TAG_ENDL { START(ENDL) } ; lio_bapl_subs : /* empty */ @@ -1506,19 +1680,24 @@ lio_bapl_sub : lio_bapl_stat_sect { OCCUR2(STAT, 0, 1) } | lio_bapl_plac_sect { OCCUR2(PLAC, 0, 1) } | source_cit_sub | note_struc_sub + | no_std_sub ; -lio_bapl_stat_sect : OPEN DELIM TAG_STAT DELIM line_item CLOSE { } +lio_bapl_stat_sect : OPEN DELIM TAG_STAT mand_line_item + { START(STAT) } no_std_subs { CHECK0 } CLOSE { } ; -lio_bapl_date_sect : OPEN DELIM TAG_DATE DELIM line_item CLOSE { } +lio_bapl_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } no_std_subs { CHECK0 } CLOSE { } ; -lio_bapl_temp_sect : OPEN DELIM TAG_TEMP DELIM line_item CLOSE { } +lio_bapl_temp_sect : OPEN DELIM TAG_TEMP mand_line_item + { START(TEMP) } no_std_subs { CHECK0 } CLOSE { } ; -lio_bapl_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item CLOSE { } +lio_bapl_plac_sect : OPEN DELIM TAG_PLAC mand_line_item + { START(PLAC) } no_std_subs { CHECK0 } CLOSE { } ; lio_slgc_sect : OPEN DELIM TAG_SLGC - { OPEN(SLGC) } + { START(SLGC) } lio_slgc_subs { CHECK1(FAMC) } CLOSE { } @@ -1532,7 +1711,8 @@ lio_slgc_sub : lio_bapl_sub | lio_slgc_famc_sect { OCCUR2(FAMC, 1, 1) } ; -lio_slgc_famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER CLOSE { } +lio_slgc_famc_sect : OPEN DELIM TAG_FAMC mand_pointer + { START(FAMC) } no_std_subs { CHECK0 } CLOSE { } ; /* LDS SPOUSE SEALING */ @@ -1540,7 +1720,7 @@ lds_spouse_seal_sub : lss_slgs_sect ; lss_slgs_sect : OPEN DELIM TAG_SLGS - { OPEN(SLGS) } + { START(SLGS) } lss_slgs_subs { CHECK0 } CLOSE { } @@ -1556,15 +1736,20 @@ lss_slgs_sub : lss_slgs_stat_sect { OCCUR2(STAT, 0, 1) } | lss_slgs_plac_sect { OCCUR2(PLAC, 0, 1) } | source_cit_sub | note_struc_sub + | no_std_sub ; -lss_slgs_stat_sect : OPEN DELIM TAG_STAT DELIM line_item CLOSE { } +lss_slgs_stat_sect : OPEN DELIM TAG_STAT mand_line_item + { START(STAT) } no_std_subs { CHECK0 } CLOSE { } ; -lss_slgs_date_sect : OPEN DELIM TAG_DATE DELIM line_item CLOSE { } +lss_slgs_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } no_std_subs { CHECK0 } CLOSE { } ; -lss_slgs_temp_sect : OPEN DELIM TAG_TEMP DELIM line_item CLOSE { } +lss_slgs_temp_sect : OPEN DELIM TAG_TEMP mand_line_item + { START(TEMP) } no_std_subs { CHECK0 } CLOSE { } ; -lss_slgs_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item CLOSE { } +lss_slgs_plac_sect : OPEN DELIM TAG_PLAC mand_line_item + { START(PLAC) } no_std_subs { CHECK0 } CLOSE { } ; /* MULTIMEDIA LINK */ @@ -1572,11 +1757,12 @@ multim_link_sub : multim_obje_link_sect | multim_obje_emb_sect ; -multim_obje_link_sect : OPEN DELIM TAG_OBJE DELIM POINTER CLOSE { } +multim_obje_link_sect : OPEN DELIM TAG_OBJE DELIM POINTER + { START(OBJE) } no_std_subs { CHECK0 } CLOSE { } ; multim_obje_emb_sect : OPEN DELIM TAG_OBJE - { OPEN(OBJE) } + { START(OBJE) } multim_obje_emb_subs { CHECK2(FORM,FILE) } CLOSE { } @@ -1590,13 +1776,17 @@ multim_obje_emb_sub : multim_obje_form_sect { OCCUR2(FORM, 1, 1) } | multim_obje_titl_sect { OCCUR2(TITL, 0, 1) } | multim_obje_file_sect { OCCUR2(FILE, 1, 1) } | note_struc_sub + | no_std_sub ; -multim_obje_form_sect : OPEN DELIM TAG_FORM DELIM line_item CLOSE { } +multim_obje_form_sect : OPEN DELIM TAG_FORM mand_line_item + { START(FORM) } no_std_subs { CHECK0 } CLOSE { } ; -multim_obje_titl_sect : OPEN DELIM TAG_TITL DELIM line_item CLOSE { } +multim_obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item + { START(TITL) } no_std_subs { CHECK0 } CLOSE { } ; -multim_obje_file_sect : OPEN DELIM TAG_FILE DELIM line_item CLOSE { } +multim_obje_file_sect : OPEN DELIM TAG_FILE mand_line_item + { START(FILE) } no_std_subs { CHECK0 } CLOSE { } ; /* NOTE STRUCTURE */ @@ -1605,7 +1795,7 @@ note_struc_sub : note_struc_link_sect /* 0:M */ ; note_struc_link_sect : OPEN DELIM TAG_NOTE DELIM POINTER - { OPEN(NOTE) } + { START(NOTE) } note_struc_link_subs { CHECK0 } CLOSE { } @@ -1616,10 +1806,11 @@ note_struc_link_subs : /* empty */ ; note_struc_link_sub : source_cit_sub + | no_std_sub ; note_struc_emb_sect : OPEN DELIM TAG_NOTE opt_line_item - { OPEN(NOTE) } + { START(NOTE) } note_struc_emb_subs { CHECK0 } CLOSE { } @@ -1631,14 +1822,15 @@ note_struc_emb_subs : /* empty */ note_struc_emb_sub : continuation_sub | source_cit_sub + | no_std_sub ; /* PERSONAL NAME STRUCTURE */ pers_name_struc_sub : pers_name_sect /* 0:M */ ; -pers_name_sect : OPEN DELIM TAG_NAME DELIM line_item - { OPEN(NAME) } +pers_name_sect : OPEN DELIM TAG_NAME mand_line_item + { START(NAME) } pers_name_subs { CHECK0 } CLOSE { } @@ -1656,27 +1848,34 @@ pers_name_sub : pers_name_npfx_sect { OCCUR2(NPFX, 0, 1) } | pers_name_nsfx_sect { OCCUR2(NSFX, 0, 1) } | source_cit_sub | note_struc_sub + | no_std_sub ; -pers_name_npfx_sect : OPEN DELIM TAG_NPFX DELIM line_item CLOSE { } +pers_name_npfx_sect : OPEN DELIM TAG_NPFX mand_line_item + { START(NPFX) } no_std_subs { CHECK0 } CLOSE { } ; -pers_name_givn_sect : OPEN DELIM TAG_GIVN DELIM line_item CLOSE { } +pers_name_givn_sect : OPEN DELIM TAG_GIVN mand_line_item + { START(GIVN) } no_std_subs { CHECK0 } CLOSE { } ; -pers_name_nick_sect : OPEN DELIM TAG_NICK DELIM line_item CLOSE { } +pers_name_nick_sect : OPEN DELIM TAG_NICK mand_line_item + { START(NICK) } no_std_subs { CHECK0 } CLOSE { } ; -pers_name_spfx_sect : OPEN DELIM TAG_SPFX DELIM line_item CLOSE { } +pers_name_spfx_sect : OPEN DELIM TAG_SPFX mand_line_item + { START(SPFX) } no_std_subs { CHECK0 } CLOSE { } ; -pers_name_surn_sect : OPEN DELIM TAG_SURN DELIM line_item CLOSE { } +pers_name_surn_sect : OPEN DELIM TAG_SURN mand_line_item + { START(SURN) } no_std_subs { CHECK0 } CLOSE { } ; -pers_name_nsfx_sect : OPEN DELIM TAG_NSFX DELIM line_item CLOSE { } +pers_name_nsfx_sect : OPEN DELIM TAG_NSFX mand_line_item + { START(NSFX) } no_std_subs { CHECK0 } CLOSE { } ; /* PLACE STRUCTURE */ place_struc_sub : place_struc_plac_sect /* 0:M */ ; -place_struc_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item - { OPEN(PLAC) } +place_struc_plac_sect : OPEN DELIM TAG_PLAC mand_line_item + { START(PLAC) } place_struc_plac_subs { CHECK0 } CLOSE { } @@ -1689,9 +1888,11 @@ place_struc_plac_subs : /* empty */ place_struc_plac_sub : place_plac_form_sect { OCCUR2(FORM, 0, 1) } | source_cit_sub | note_struc_sub + | no_std_sub ; -place_plac_form_sect : OPEN DELIM TAG_FORM DELIM line_item CLOSE { } +place_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item + { START(FORM) } no_std_subs { CHECK0 } CLOSE { } ; /* SOURCE_CITATION */ @@ -1700,7 +1901,7 @@ source_cit_sub : source_cit_link_sect /* 0:M */ ; source_cit_link_sect : OPEN DELIM TAG_SOUR DELIM POINTER - { OPEN(SOUR) } + { START(SOUR) } source_cit_link_subs { CHECK0 } CLOSE { } @@ -1716,13 +1917,15 @@ source_cit_link_sub : source_cit_page_sect { OCCUR2(PAGE, 0, 1) } | source_cit_quay_sect { OCCUR2(QUAY, 0, 1) } | multim_link_sub | note_struc_sub + | no_std_sub ; -source_cit_page_sect : OPEN DELIM TAG_PAGE DELIM line_item CLOSE { } +source_cit_page_sect : OPEN DELIM TAG_PAGE mand_line_item + { START(PAGE) } no_std_subs { CHECK0 } CLOSE { } ; -source_cit_even_sect : OPEN DELIM TAG_EVEN DELIM line_item - { OPEN(EVEN) } +source_cit_even_sect : OPEN DELIM TAG_EVEN mand_line_item + { START(EVEN) } source_cit_even_subs { CHECK0 } CLOSE { } @@ -1733,13 +1936,15 @@ source_cit_even_subs : /* empty */ ; source_cit_even_sub : source_cit_even_role_sect { OCCUR2(ROLE, 0, 1) } + | no_std_sub ; -source_cit_even_role_sect : OPEN DELIM TAG_ROLE DELIM line_item CLOSE { } +source_cit_even_role_sect : OPEN DELIM TAG_ROLE mand_line_item + { START(ROLE) } no_std_subs { CHECK0 } CLOSE { } ; source_cit_data_sect : OPEN DELIM TAG_DATA - { OPEN(DATA) } + { START(DATA) } source_cit_data_subs { CHECK0 } CLOSE { } @@ -1751,13 +1956,15 @@ source_cit_data_subs : /* empty */ source_cit_data_sub : source_cit_data_date_sect { OCCUR2(DATE, 0, 1) } | source_cit_text_sect /* 0:M */ + | no_std_sub ; -source_cit_data_date_sect : OPEN DELIM TAG_DATE DELIM line_item CLOSE { } +source_cit_data_date_sect : OPEN DELIM TAG_DATE mand_line_item + { START(DATE) } no_std_subs { CHECK0 } CLOSE { } ; -source_cit_text_sect : OPEN DELIM TAG_TEXT DELIM line_item - { OPEN(TEXT) } +source_cit_text_sect : OPEN DELIM TAG_TEXT mand_line_item + { START(TEXT) } source_cit_text_subs { CHECK0 } CLOSE { } @@ -1768,13 +1975,15 @@ source_cit_text_subs : /* empty */ ; source_cit_text_sub : continuation_sub + | no_std_sub ; -source_cit_quay_sect : OPEN DELIM TAG_QUAY DELIM line_item CLOSE { } +source_cit_quay_sect : OPEN DELIM TAG_QUAY mand_line_item + { START(QUAY) } no_std_subs { CHECK0 } CLOSE { } ; -source_cit_emb_sect : OPEN DELIM TAG_SOUR DELIM line_item - { OPEN(SOUR) } +source_cit_emb_sect : OPEN DELIM TAG_SOUR mand_line_item + { START(SOUR) } source_cit_emb_subs { CHECK0 } CLOSE { } @@ -1787,14 +1996,15 @@ source_cit_emb_subs : /* empty */ source_cit_emb_sub : continuation_sub | source_cit_text_sect /* 0:M */ | note_struc_sub + | no_std_sub ; /* SOURCE REPOSITORY CITATION */ source_repos_cit_sub : source_repos_repo_sect { OCCUR2(REPO, 0, 1) } ; -source_repos_repo_sect : OPEN DELIM TAG_REPO DELIM POINTER - { OPEN(REPO) } +source_repos_repo_sect : OPEN DELIM TAG_REPO mand_pointer + { START(REPO) } source_repos_repo_subs { CHECK0 } CLOSE { } @@ -1806,10 +2016,11 @@ source_repos_repo_subs : /* empty */ source_repos_repo_sub : note_struc_sub | caln_sect /* 0:M */ + | no_std_sub ; -caln_sect : OPEN DELIM TAG_CALN DELIM line_item - { OPEN(CALN) } +caln_sect : OPEN DELIM TAG_CALN mand_line_item + { START(CALN) } caln_subs { CHECK0 } CLOSE { } @@ -1820,17 +2031,19 @@ caln_subs : /* empty */ ; caln_sub : caln_medi_sect { OCCUR2(MEDI, 0, 1) } + | no_std_sub ; -caln_medi_sect : OPEN DELIM TAG_MEDI DELIM line_item CLOSE { } +caln_medi_sect : OPEN DELIM TAG_MEDI mand_line_item + { START(MEDI) } no_std_subs { CHECK0 } CLOSE { } ; /* SPOUSE TO FAMILY LINK */ spou_fam_link_sub : spou_fam_fams_sect /* 0:M */ ; -spou_fam_fams_sect : OPEN DELIM TAG_FAMS DELIM POINTER - { OPEN(FAMS) } +spou_fam_fams_sect : OPEN DELIM TAG_FAMS mand_pointer + { START(FAMS) } spou_fam_fams_subs { CHECK0 } CLOSE { } @@ -1841,12 +2054,37 @@ spou_fam_fams_subs : /* empty */ ; spou_fam_fams_sub : note_struc_sub + | no_std_sub ; /*********************************************************************/ /**** General ****/ /*********************************************************************/ +no_std_subs : /* empty */ + | no_std_subs no_std_sub + ; + +no_std_sub : user_sect /* 0:M */ + | gen_sect + | error error_subs CLOSE { HANDLE_ERROR } + ; + +no_std_rec : user_rec /* 0:M */ + | gen_rec + | error error_subs CLOSE { HANDLE_ERROR } + ; + +user_rec : OPEN DELIM opt_xref USERTAG + { if ($4[0] != '_') { + gedcom_error("Undefined tag (and not a valid user tag): %s", + $4); + YYERROR; + } + } + opt_value user_sects CLOSE { } + ; + user_sect : OPEN DELIM opt_xref USERTAG { if ($4[0] != '_') { gedcom_error("Undefined tag (and not a valid user tag): %s", @@ -1873,38 +2111,108 @@ line_value : POINTER { } | line_item { } ; +mand_pointer : /* empty */ { gedcom_error("Missing pointer"); YYERROR; } + | DELIM POINTER { } + ; + +mand_line_item : /* empty */ { gedcom_error("Missing value"); YYERROR; } + | DELIM line_item { gedcom_debug_print("==Val: %s==\n", $2); + $$ = $2; } + ; + opt_line_item : /* empty */ { } | DELIM line_item { } ; -line_item : anychar { } - | ESCAPE { } - | line_item anychar { } - | line_item ESCAPE { } +line_item : anychar { size_t i; + CLEAR_BUFFER(string_buf); + string_buf_ptr = string_buf; + /* The following also takes care of '@@' */ + if (!strncmp($1, "@@", 3)) + *string_buf_ptr++ = '@'; + else + for (i=0; i < strlen($1); i++) + *string_buf_ptr++ = $1[i]; + $$ = string_buf; + } + | ESCAPE { CLEAR_BUFFER(string_buf); + string_buf_ptr = string_buf; + /* For now, ignore escapes */ + $$ = string_buf; + } + | line_item anychar + { if (strlen(string_buf) >= MAXGEDCLINELEN) { + gedcom_error("Line too long"); + YYERROR; + } + else { + size_t i; + /* The following also takes care of '@@' */ + if (!strncmp($2, "@@", 3)) + *string_buf_ptr++ = '@'; + else + for (i=0; i < strlen($2); i++) + *string_buf_ptr++ = $2[i]; + $$ = string_buf; + } + } + | line_item ESCAPE + { /* For now, ignore escapes */ + $$ = string_buf; + } ; anychar : ANYCHAR { } | DELIM { } ; -/* -gen_sect : OPEN DELIM opt_xref anytag +error_subs : /* empty */ + | error_subs error_sect + ; + +error_sect : OPEN DELIM opt_xref anytag opt_value error_subs CLOSE { } + +gen_sect : OPEN DELIM opt_xref anystdtag { INVALID_TAG($4); } opt_value opt_sects CLOSE { } ; -gen_rec : OPEN DELIM opt_xref anytag - { INVALID_TOP_TAG($4) } +gen_rec : gen_rec_top + | gen_rec_norm + ; + +gen_rec_norm : OPEN DELIM opt_xref anystdtag + { INVALID_TOP_TAG($4) } + opt_value opt_sects CLOSE + { } + ; + +gen_rec_top : OPEN DELIM anytoptag + { gedcom_error("Missing cross-reference"); YYERROR; } opt_value opt_sects CLOSE - { } + { } ; -opt_sects : { } +opt_sects : /* empty */ { } | opt_sects gen_sect { } ; -anytag : TAG_ABBR +anytag : USERTAG { } + | anystdtag { } + ; + +anytoptag : TAG_FAM + | TAG_INDI + | TAG_OBJE + | TAG_NOTE + | TAG_REPO + | TAG_SOUR + | TAG_SUBN + | TAG_SUBM + ; + +anystdtag : TAG_ABBR | TAG_ADDR | TAG_ADR1 | TAG_ADR2 { } @@ -2031,25 +2339,24 @@ anytag : TAG_ABBR | TAG_VERS { } | TAG_WIFE { } | TAG_WILL { } -*/ + %% /* Functions that handle the counting of subtags */ -int* count_arrays[MAXGEDCOMLEVEL+1]; -char tag_stack[MAXGEDCOMLEVEL+1][MAXSTDTAGLENGTH+1]; +int* count_arrays[MAXGEDCLEVEL+1]; +char tag_stack[MAXGEDCLEVEL+1][MAXSTDTAGLENGTH+1]; void push_countarray() { int *count = NULL; - if (count_level > MAXGEDCOMLEVEL) { + if (count_level > MAXGEDCLEVEL) { gedcom_error("Internal error: count array overflow"); exit(1); } else { count = (int *)calloc(YYNTOKENS, sizeof(int)); - if (count == NULL) { int *count = count_arrays[count_level]; - + if (count == NULL) { gedcom_error("Internal error: count array calloc error"); exit(1); } @@ -2096,18 +2403,62 @@ void pop_countarray() } /* Enabling debug mode */ - -void gedcom_enable_debug() +/* level 0: no debugging */ +/* level 1: only internal */ +/* level 2: also bison */ +void gedcom_set_debug_level(int level) { + if (level > 0) { + gedcom_high_level_debug = 1; + } + if (level > 1) { #if YYDEBUG != 0 - gedcom_debug = 1; + gedcom_debug = 1; #endif + } } -/* Setting the error mechanism */ +int gedcom_debug_print(char* s, ...) +{ + int res; + if (gedcom_high_level_debug) { + va_list ap; + va_start(ap, s); + res = vfprintf(stderr, s, ap); + va_end(ap); + } + return(res); +} +/* Setting the error mechanism */ void gedcom_set_error_handling(MECHANISM mechanism) { - curr_mechanism = mechanism; + error_mechanism = mechanism; +} + +/* Compatibility handling */ + +void gedcom_set_compat_handling(int enable_compat) +{ + compat_enabled = enable_compat; +} + +void set_compatibility(char* program) +{ + if (compat_enabled) { + gedcom_debug_print("==== Program: %s\n", program); + if (! strncmp(program, "ftree", 6)) { + gedcom_warning("Enabling compatibility with 'ftree'"); + compatibility = C_FTREE; + } + else { + compatibility = 0; + } + } +} + +int compat_mode(int compat_flags) +{ + return (compat_flags & compatibility); }