Pass the parsed tag value (integer format) together with the string value
[gedcom-parse.git] / gedcom / gedcom.y
index c8aaed00805bbf9f994914e8ae417f0da9da2ee3..eff626732a8920856544c1e445c45fd0283e195b 100644 (file)
@@ -1,5 +1,5 @@
 /* Parser for Gedcom.
-   Copyright (C) 2001 The Genes Development Team
+   Copyright (C) 2001, 2002 The Genes Development Team
    This file is part of the Gedcom parser library.
    Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
 
 #include "multilex.h"
 #include "encoding.h"
 #include "interface.h"
+#include "date.h"
 
 int  count_level    = 0;
 int  fail           = 0;
@@ -152,6 +153,7 @@ int  compat_enabled = 1;
 int  gedcom_high_level_debug = 0; 
 int  compatibility  = 0; 
 Gedcom_err_mech error_mechanism = IMMED_FAIL;
+Gedcom_val_struct val; 
  
 char line_item_buf[MAXGEDCLINELEN * UTF_FACTOR + 1];
 char *line_item_buf_ptr;
@@ -241,6 +243,7 @@ int  compat_mode(int flags);
 %union {
   int  number;
   char *string;
+  struct tag_struct tag;
   Gedcom_ctxt ctxt;
 }
 
@@ -254,139 +257,144 @@ int  compat_mode(int flags);
 %token <string> DELIM
 %token <string> ANYCHAR
 %token <string> POINTER
-%token <string> USERTAG
-%token <string> TAG_ABBR
-%token <string> TAG_ADDR
-%token <string> TAG_ADR1
-%token <string> TAG_ADR2
-%token <string> TAG_ADOP
-%token <string> TAG_AFN
-%token <string> TAG_AGE
-%token <string> TAG_AGNC
-%token <string> TAG_ALIA
-%token <string> TAG_ANCE
-%token <string> TAG_ANCI
-%token <string> TAG_ANUL
-%token <string> TAG_ASSO
-%token <string> TAG_AUTH
-%token <string> TAG_BAPL
-%token <string> TAG_BAPM
-%token <string> TAG_BARM
-%token <string> TAG_BASM
-%token <string> TAG_BIRT
-%token <string> TAG_BLES
-%token <string> TAG_BLOB
-%token <string> TAG_BURI
-%token <string> TAG_CALN
-%token <string> TAG_CAST
-%token <string> TAG_CAUS
-%token <string> TAG_CENS
-%token <string> TAG_CHAN
-%token <string> TAG_CHAR
-%token <string> TAG_CHIL
-%token <string> TAG_CHR
-%token <string> TAG_CHRA
-%token <string> TAG_CITY
-%token <string> TAG_CONC
-%token <string> TAG_CONF
-%token <string> TAG_CONL
-%token <string> TAG_CONT
-%token <string> TAG_COPR
-%token <string> TAG_CORP
-%token <string> TAG_CREM
-%token <string> TAG_CTRY
-%token <string> TAG_DATA
-%token <string> TAG_DATE
-%token <string> TAG_DEAT
-%token <string> TAG_DESC
-%token <string> TAG_DESI
-%token <string> TAG_DEST
-%token <string> TAG_DIV
-%token <string> TAG_DIVF
-%token <string> TAG_DSCR
-%token <string> TAG_EDUC
-%token <string> TAG_EMIG
-%token <string> TAG_ENDL
-%token <string> TAG_ENGA
-%token <string> TAG_EVEN
-%token <string> TAG_FAM
-%token <string> TAG_FAMC
-%token <string> TAG_FAMF
-%token <string> TAG_FAMS
-%token <string> TAG_FCOM
-%token <string> TAG_FILE
-%token <string> TAG_FORM
-%token <string> TAG_GEDC
-%token <string> TAG_GIVN
-%token <string> TAG_GRAD
-%token <string> TAG_HEAD
-%token <string> TAG_HUSB
-%token <string> TAG_IDNO
-%token <string> TAG_IMMI
-%token <string> TAG_INDI
-%token <string> TAG_LANG
-%token <string> TAG_LEGA
-%token <string> TAG_MARB
-%token <string> TAG_MARC
-%token <string> TAG_MARL
-%token <string> TAG_MARR
-%token <string> TAG_MARS
-%token <string> TAG_MEDI
-%token <string> TAG_NAME
-%token <string> TAG_NATI
-%token <string> TAG_NATU
-%token <string> TAG_NCHI
-%token <string> TAG_NICK
-%token <string> TAG_NMR
-%token <string> TAG_NOTE
-%token <string> TAG_NPFX
-%token <string> TAG_NSFX
-%token <string> TAG_OBJE
-%token <string> TAG_OCCU
-%token <string> TAG_ORDI
-%token <string> TAG_ORDN
-%token <string> TAG_PAGE
-%token <string> TAG_PEDI
-%token <string> TAG_PHON
-%token <string> TAG_PLAC
-%token <string> TAG_POST
-%token <string> TAG_PROB
-%token <string> TAG_PROP
-%token <string> TAG_PUBL
-%token <string> TAG_QUAY
-%token <string> TAG_REFN
-%token <string> TAG_RELA
-%token <string> TAG_RELI
-%token <string> TAG_REPO
-%token <string> TAG_RESI
-%token <string> TAG_RESN
-%token <string> TAG_RETI
-%token <string> TAG_RFN
-%token <string> TAG_RIN
-%token <string> TAG_ROLE
-%token <string> TAG_SEX
-%token <string> TAG_SLGC
-%token <string> TAG_SLGS
-%token <string> TAG_SOUR
-%token <string> TAG_SPFX
-%token <string> TAG_SSN
-%token <string> TAG_STAE
-%token <string> TAG_STAT
-%token <string> TAG_SUBM
-%token <string> TAG_SUBN
-%token <string> TAG_SURN
-%token <string> TAG_TEMP
-%token <string> TAG_TEXT
-%token <string> TAG_TIME
-%token <string> TAG_TITL
-%token <string> TAG_TRLR
-%token <string> TAG_TYPE
-%token <string> TAG_VERS
-%token <string> TAG_WIFE
-%token <string> TAG_WILL
-
-%type <string> anystdtag
-%type <string> anytoptag
+%token <tag> USERTAG
+%token <tag> TAG_ABBR
+%token <tag> TAG_ADDR
+%token <tag> TAG_ADR1
+%token <tag> TAG_ADR2
+%token <tag> TAG_ADOP
+%token <tag> TAG_AFN
+%token <tag> TAG_AGE
+%token <tag> TAG_AGNC
+%token <tag> TAG_ALIA
+%token <tag> TAG_ANCE
+%token <tag> TAG_ANCI
+%token <tag> TAG_ANUL
+%token <tag> TAG_ASSO
+%token <tag> TAG_AUTH
+%token <tag> TAG_BAPL
+%token <tag> TAG_BAPM
+%token <tag> TAG_BARM
+%token <tag> TAG_BASM
+%token <tag> TAG_BIRT
+%token <tag> TAG_BLES
+%token <tag> TAG_BLOB
+%token <tag> TAG_BURI
+%token <tag> TAG_CALN
+%token <tag> TAG_CAST
+%token <tag> TAG_CAUS
+%token <tag> TAG_CENS
+%token <tag> TAG_CHAN
+%token <tag> TAG_CHAR
+%token <tag> TAG_CHIL
+%token <tag> TAG_CHR
+%token <tag> TAG_CHRA
+%token <tag> TAG_CITY
+%token <tag> TAG_CONC
+%token <tag> TAG_CONF
+%token <tag> TAG_CONL
+%token <tag> TAG_CONT
+%token <tag> TAG_COPR
+%token <tag> TAG_CORP
+%token <tag> TAG_CREM
+%token <tag> TAG_CTRY
+%token <tag> TAG_DATA
+%token <tag> TAG_DATE
+%token <tag> TAG_DEAT
+%token <tag> TAG_DESC
+%token <tag> TAG_DESI
+%token <tag> TAG_DEST
+%token <tag> TAG_DIV
+%token <tag> TAG_DIVF
+%token <tag> TAG_DSCR
+%token <tag> TAG_EDUC
+%token <tag> TAG_EMIG
+%token <tag> TAG_ENDL
+%token <tag> TAG_ENGA
+%token <tag> TAG_EVEN
+%token <tag> TAG_FAM
+%token <tag> TAG_FAMC
+%token <tag> TAG_FAMF
+%token <tag> TAG_FAMS
+%token <tag> TAG_FCOM
+%token <tag> TAG_FILE
+%token <tag> TAG_FORM
+%token <tag> TAG_GEDC
+%token <tag> TAG_GIVN
+%token <tag> TAG_GRAD
+%token <tag> TAG_HEAD
+%token <tag> TAG_HUSB
+%token <tag> TAG_IDNO
+%token <tag> TAG_IMMI
+%token <tag> TAG_INDI
+%token <tag> TAG_LANG
+%token <tag> TAG_LEGA
+%token <tag> TAG_MARB
+%token <tag> TAG_MARC
+%token <tag> TAG_MARL
+%token <tag> TAG_MARR
+%token <tag> TAG_MARS
+%token <tag> TAG_MEDI
+%token <tag> TAG_NAME
+%token <tag> TAG_NATI
+%token <tag> TAG_NATU
+%token <tag> TAG_NCHI
+%token <tag> TAG_NICK
+%token <tag> TAG_NMR
+%token <tag> TAG_NOTE
+%token <tag> TAG_NPFX
+%token <tag> TAG_NSFX
+%token <tag> TAG_OBJE
+%token <tag> TAG_OCCU
+%token <tag> TAG_ORDI
+%token <tag> TAG_ORDN
+%token <tag> TAG_PAGE
+%token <tag> TAG_PEDI
+%token <tag> TAG_PHON
+%token <tag> TAG_PLAC
+%token <tag> TAG_POST
+%token <tag> TAG_PROB
+%token <tag> TAG_PROP
+%token <tag> TAG_PUBL
+%token <tag> TAG_QUAY
+%token <tag> TAG_REFN
+%token <tag> TAG_RELA
+%token <tag> TAG_RELI
+%token <tag> TAG_REPO
+%token <tag> TAG_RESI
+%token <tag> TAG_RESN
+%token <tag> TAG_RETI
+%token <tag> TAG_RFN
+%token <tag> TAG_RIN
+%token <tag> TAG_ROLE
+%token <tag> TAG_SEX
+%token <tag> TAG_SLGC
+%token <tag> TAG_SLGS
+%token <tag> TAG_SOUR
+%token <tag> TAG_SPFX
+%token <tag> TAG_SSN
+%token <tag> TAG_STAE
+%token <tag> TAG_STAT
+%token <tag> TAG_SUBM
+%token <tag> TAG_SUBN
+%token <tag> TAG_SURN
+%token <tag> TAG_TEMP
+%token <tag> TAG_TEXT
+%token <tag> TAG_TIME
+%token <tag> TAG_TITL
+%token <tag> TAG_TRLR
+%token <tag> TAG_TYPE
+%token <tag> TAG_VERS
+%token <tag> TAG_WIFE
+%token <tag> TAG_WILL
+
+%type <tag> anystdtag
+%type <tag> anytoptag
+%type <tag> fam_event_tag
+%type <tag> indiv_attr_tag
+%type <tag> indiv_birt_tag
+%type <tag> indiv_gen_tag
+%type <tag> lio_bapl_tag
 %type <string> line_item
 %type <string> line_value
 %type <string> mand_line_item
@@ -395,6 +403,7 @@ int  compat_mode(int flags);
 %type <string> anychar
 %type <string> opt_xref
 %type <string> opt_value
+%type <string> opt_line_item
 %type <ctxt> head_sect
 
 %%
@@ -422,7 +431,7 @@ record      : fam_rec
 /**** Header                                                      ****/
 /*********************************************************************/
 head_sect    : OPEN DELIM TAG_HEAD
-               { $<ctxt>$ = start_record(REC_HEAD, $1, NULL, $3);
+               { $<ctxt>$ = start_record(REC_HEAD, $1, GEDCOM_MAKE_NULL(), $3);
                 START(HEAD, $<ctxt>$) }
                head_subs
                { if (compat_mode(C_FTREE))
@@ -457,7 +466,8 @@ head_sub     : head_sour_sect  { OCCUR2(SOUR, 1, 1) }
 head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item 
                  { set_compatibility($4);
                   $<ctxt>$ = start_element(ELT_HEAD_SOUR, PARENT,
-                                           $1, $3, $4, $4);
+                                           $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(SOUR, $<ctxt>$)
                 }
                  head_sour_subs
@@ -479,7 +489,8 @@ head_sour_sub : head_sour_vers_sect  { OCCUR2(VERS, 0, 1) }
 
 head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item
                       { $<ctxt>$ = start_element(ELT_HEAD_SOUR_VERS, PARENT,
-                                                $1, $3, $4, $4);
+                                                $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(VERS, $<ctxt>$)
                      }
                       no_std_subs
@@ -491,7 +502,8 @@ head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item
                     ;
 head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item
                       { $<ctxt>$ = start_element(ELT_HEAD_SOUR_NAME, PARENT,
-                                                $1, $3, $4, $4);
+                                                $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(NAME, $<ctxt>$)
                      }
                       no_std_subs
@@ -503,7 +515,8 @@ head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item
                     ;
 head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item 
                       { $<ctxt>$ = start_element(ELT_HEAD_SOUR_CORP, PARENT,
-                                                $1, $3, $4, $4);
+                                                $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(CORP, $<ctxt>$)
                      }
                       head_sour_corp_subs
@@ -524,7 +537,8 @@ head_sour_corp_sub : addr_struc_sub  /* 0:1 */
 
 head_sour_data_sect : OPEN DELIM TAG_DATA mand_line_item 
                       { $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA, PARENT,
-                                                $1, $3, $4, $4);
+                                                $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(DATA, $<ctxt>$)
                      }
                       head_sour_data_subs
@@ -545,8 +559,10 @@ 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
-                           { $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA_DATE,
-                                                     PARENT, $1, $3, $4, $4);
+                           { struct date_value dv = gedcom_parse_date($4);
+                            $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA_DATE,
+                                                     PARENT, $1, $3, $4,
+                                                     GEDCOM_MAKE_DATE(dv));
                             START(DATE, $<ctxt>$)
                           }
                            no_std_subs
@@ -558,7 +574,8 @@ head_sour_data_date_sect : OPEN DELIM TAG_DATE mand_line_item
                          ;
 head_sour_data_copr_sect : OPEN DELIM TAG_COPR mand_line_item
                            { $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA_COPR,
-                                                     PARENT, $1, $3, $4, $4);
+                                                     PARENT, $1, $3, $4,
+                                                     GEDCOM_MAKE_STRING($4));
                             START(COPR, $<ctxt>$)
                           }
                            no_std_subs
@@ -572,7 +589,8 @@ head_sour_data_copr_sect : OPEN DELIM TAG_COPR mand_line_item
 /* HEAD.DEST */
 head_dest_sect : OPEN DELIM TAG_DEST mand_line_item
                  { $<ctxt>$ = start_element(ELT_HEAD_DEST,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(DEST, $<ctxt>$)
                 }
                  no_std_subs
@@ -585,8 +603,10 @@ head_dest_sect : OPEN DELIM TAG_DEST mand_line_item
 
 /* HEAD.DATE */
 head_date_sect : OPEN DELIM TAG_DATE mand_line_item 
-                 { $<ctxt>$ = start_element(ELT_HEAD_DATE,
-                                           PARENT, $1, $3, $4, $4);
+                 { struct date_value dv = gedcom_parse_date($4);
+                  $<ctxt>$ = start_element(ELT_HEAD_DATE,
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_DATE(dv));
                   START(DATE, $<ctxt>$)
                 }
                  head_date_subs
@@ -607,7 +627,8 @@ head_date_sub  : head_date_time_sect  { OCCUR2(TIME, 0, 1) }
 
 head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
                       { $<ctxt>$ = start_element(ELT_HEAD_DATE_TIME,
-                                                PARENT, $1, $3, $4, $4);
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(TIME, $<ctxt>$)
                      }
                       no_std_subs
@@ -621,7 +642,8 @@ head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
 /* HEAD.SUBM */
 head_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
                  { $<ctxt>$ = start_element(ELT_HEAD_SUBM,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(SUBM, $<ctxt>$)
                 }
                  no_std_subs
@@ -634,7 +656,8 @@ head_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
 /* HEAD.SUBN */
 head_subn_sect : OPEN DELIM TAG_SUBN mand_pointer 
                  { $<ctxt>$ = start_element(ELT_HEAD_SUBN,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(SUBN, $<ctxt>$)
                 }
                  no_std_subs
@@ -647,7 +670,8 @@ head_subn_sect : OPEN DELIM TAG_SUBN mand_pointer
 /* HEAD.FILE */
 head_file_sect : OPEN DELIM TAG_FILE mand_line_item 
                  { $<ctxt>$ = start_element(ELT_HEAD_FILE,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(FILE, $<ctxt>$)
                 }
                  no_std_subs
@@ -659,7 +683,8 @@ head_file_sect : OPEN DELIM TAG_FILE mand_line_item
 /* HEAD.COPR */
 head_copr_sect : OPEN DELIM TAG_COPR mand_line_item 
                  { $<ctxt>$ = start_element(ELT_HEAD_COPR,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(COPR, $<ctxt>$)
                 }
                  no_std_subs
@@ -671,7 +696,8 @@ head_copr_sect : OPEN DELIM TAG_COPR mand_line_item
 /* HEAD.GEDC */
 head_gedc_sect : OPEN DELIM TAG_GEDC
                  { $<ctxt>$ = start_element(ELT_HEAD_GEDC,
-                                           PARENT, $1, $3, NULL, NULL);
+                                           PARENT, $1, $3, NULL,
+                                           GEDCOM_MAKE_NULL());
                   START(GEDC, $<ctxt>$)
                 }
                  head_gedc_subs
@@ -691,7 +717,8 @@ head_gedc_sub  : head_gedc_vers_sect  { OCCUR2(VERS, 1, 1) }
                ;
 head_gedc_vers_sect : OPEN DELIM TAG_VERS mand_line_item  
                       { $<ctxt>$ = start_element(ELT_HEAD_GEDC_VERS,
-                                                PARENT, $1, $3, $4, $4);
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(VERS, $<ctxt>$)
                      }
                       no_std_subs
@@ -703,7 +730,8 @@ head_gedc_vers_sect : OPEN DELIM TAG_VERS mand_line_item
                     ;
 head_gedc_form_sect : OPEN DELIM TAG_FORM mand_line_item   
                       { $<ctxt>$ = start_element(ELT_HEAD_GEDC_FORM,
-                                                PARENT, $1, $3, $4, $4);
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(FORM, $<ctxt>$)
                      }
                       no_std_subs
@@ -718,7 +746,8 @@ head_gedc_form_sect : OPEN DELIM TAG_FORM mand_line_item
 head_char_sect : OPEN DELIM TAG_CHAR mand_line_item 
                  { if (open_conv_to_internal($4) == 0) YYERROR;
                   $<ctxt>$ = start_element(ELT_HEAD_CHAR,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(CHAR, $<ctxt>$)
                 }
                  head_char_subs
@@ -737,7 +766,8 @@ head_char_sub  : head_char_vers_sect  { OCCUR2(VERS, 0, 1) }
                ;
 head_char_vers_sect : OPEN DELIM TAG_VERS mand_line_item   
                       { $<ctxt>$ = start_element(ELT_HEAD_CHAR_VERS,
-                                                PARENT, $1, $3, $4, $4);
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
                        START(VERS, $<ctxt>$)
                      }
                       no_std_subs
@@ -751,7 +781,8 @@ head_char_vers_sect : OPEN DELIM TAG_VERS mand_line_item
 /* HEAD.LANG */
 head_lang_sect : OPEN DELIM TAG_LANG mand_line_item   
                  { $<ctxt>$ = start_element(ELT_HEAD_LANG,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
                   START(LANG, $<ctxt>$)
                 }
                  no_std_subs
@@ -763,7 +794,8 @@ head_lang_sect : OPEN DELIM TAG_LANG mand_line_item
 /* HEAD.PLAC */
 head_plac_sect : OPEN DELIM TAG_PLAC
                  { $<ctxt>$ = start_element(ELT_HEAD_PLAC,
-                                           PARENT, $1, $3, NULL, NULL);
+                                           PARENT, $1, $3, NULL,
+                                           GEDCOM_MAKE_NULL());
                   START(PLAC, $<ctxt>$)
                 }
                  head_plac_subs
@@ -782,7 +814,8 @@ head_plac_sub  : head_plac_form_sect  { OCCUR2(FORM, 1, 1) }
                ;
 head_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item   
                       { $<ctxt>$ = start_element(ELT_HEAD_PLAC_FORM,
-                                                PARENT, $1, $3, $4, $4);
+                                                PARENT, $1, $3, $4, 
+                                                GEDCOM_MAKE_STRING($4));
                        START(FORM, $<ctxt>$)
                      }
                       no_std_subs
@@ -796,7 +829,8 @@ head_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item
 /* HEAD.NOTE */
 head_note_sect : OPEN DELIM TAG_NOTE mand_line_item 
                  { $<ctxt>$ = start_element(ELT_HEAD_NOTE,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(NOTE, $<ctxt>$)
                 }
                  head_note_subs
@@ -825,7 +859,8 @@ trlr_sect   : OPEN DELIM TAG_TRLR CLOSE { }
 /**** Family record                                               ****/
 /*********************************************************************/
 fam_rec      : OPEN DELIM POINTER DELIM TAG_FAM
-               { $<ctxt>$ = start_record(REC_FAM, $1, $3, $5);
+               { $<ctxt>$ = start_record(REC_FAM,
+                                        $1, GEDCOM_MAKE_STRING($3), $5);
                 START(FAM, $<ctxt>$) }
                fam_subs
               { CHECK0 }
@@ -855,7 +890,8 @@ fam_sub      : fam_event_struc_sub  /* 0:M */
 /* FAM.HUSB */
 fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer    
                 { $<ctxt>$ = start_element(ELT_FAM_HUSB,
-                                          PARENT, $1, $3, $4, $4);
+                                          PARENT, $1, $3, $4, 
+                                          GEDCOM_MAKE_STRING($4));
                  START(HUSB, $<ctxt>$)
                }
                 no_std_subs
@@ -868,7 +904,8 @@ fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer
 /* FAM.WIFE */
 fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer 
                 { $<ctxt>$ = start_element(ELT_FAM_WIFE,
-                                          PARENT, $1, $3, $4, $4);
+                                          PARENT, $1, $3, $4, 
+                                          GEDCOM_MAKE_STRING($4));
                  START(WIFE, $<ctxt>$)
                }
                 no_std_subs
@@ -881,7 +918,8 @@ fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer
 /* FAM.CHIL */
 fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer
                 { $<ctxt>$ = start_element(ELT_FAM_CHIL,
-                                          PARENT, $1, $3, $4, $4);
+                                          PARENT, $1, $3, $4, 
+                                          GEDCOM_MAKE_STRING($4));
                  START(CHIL, $<ctxt>$) 
                } 
                no_std_subs 
@@ -894,7 +932,8 @@ fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer
 /* FAM.NCHI */
 fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item    
                 { $<ctxt>$ = start_element(ELT_FAM_NCHI,
-                                          PARENT, $1, $3, $4, $4);
+                                          PARENT, $1, $3, $4, 
+                                          GEDCOM_MAKE_STRING($4));
                  START(NCHI, $<ctxt>$)  
                }  
                no_std_subs  
@@ -907,7 +946,8 @@ fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
 /* FAM.SUBM */
 fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
                 { $<ctxt>$ = start_element(ELT_FAM_SUBM,
-                                          PARENT, $1, $3, $4, $4);
+                                          PARENT, $1, $3, $4, 
+                                          GEDCOM_MAKE_STRING($4));
                  START(SUBM, $<ctxt>$)   
                }   
                no_std_subs   
@@ -921,7 +961,8 @@ fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
 /**** Individual record                                           ****/
 /*********************************************************************/
 indiv_rec   : OPEN DELIM POINTER DELIM TAG_INDI
-              { $<ctxt>$ = start_record(REC_INDI, $1, $3, $5);
+              { $<ctxt>$ = start_record(REC_INDI,
+                                       $1, GEDCOM_MAKE_STRING($3), $5);
                START(INDI, $<ctxt>$) }
               indi_subs
              { CHECK0 }
@@ -962,7 +1003,8 @@ indi_sub    : indi_resn_sect  { OCCUR2(RESN, 0, 1) }
 /* INDI.RESN */
 indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item     
                  { $<ctxt>$ = start_element(ELT_INDI_RESN,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(RESN, $<ctxt>$)    
                 }    
                 no_std_subs     
@@ -975,7 +1017,8 @@ indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item
 /* INDI.SEX */
 indi_sex_sect  : OPEN DELIM TAG_SEX mand_line_item     
                  { $<ctxt>$ = start_element(ELT_INDI_SEX,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(SEX, $<ctxt>$)     
                 }     
                 no_std_subs     
@@ -988,7 +1031,8 @@ indi_sex_sect  : OPEN DELIM TAG_SEX mand_line_item
 /* INDI.SUBM */
 indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer 
                  { $<ctxt>$ = start_element(ELT_INDI_SUBM,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(SUBM, $<ctxt>$)      
                 }      
                 no_std_subs      
@@ -1001,7 +1045,8 @@ indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
 /* INDI.ALIA */
 indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer
                  { $<ctxt>$ = start_element(ELT_INDI_ALIA,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(ALIA, $<ctxt>$)       
                 }       
                 no_std_subs       
@@ -1014,7 +1059,8 @@ indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer
 /* INDI.ANCI */
 indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer
                  { $<ctxt>$ = start_element(ELT_INDI_ANCI,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(ANCI, $<ctxt>$)        
                 }        
                 no_std_subs        
@@ -1027,7 +1073,8 @@ indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer
 /* INDI.DESI */
 indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer
                  { $<ctxt>$ = start_element(ELT_INDI_DESI,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(DESI, $<ctxt>$)         
                 }         
                 no_std_subs         
@@ -1040,7 +1087,8 @@ indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer
 /* INDI.RFN */
 indi_rfn_sect  : OPEN DELIM TAG_RFN mand_line_item     
                  { $<ctxt>$ = start_element(ELT_INDI_RFN,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(RFN, $<ctxt>$)          
                 }          
                 no_std_subs          
@@ -1053,7 +1101,8 @@ indi_rfn_sect  : OPEN DELIM TAG_RFN mand_line_item
 /* INDI.AFN */
 indi_afn_sect  : OPEN DELIM TAG_AFN mand_line_item      
                  { $<ctxt>$ = start_element(ELT_INDI_AFN,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(AFN, $<ctxt>$)           
                 }           
                 no_std_subs           
@@ -1071,7 +1120,8 @@ ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item
 /**** Multimedia record                                           ****/
 /*********************************************************************/
 multim_rec  : OPEN DELIM POINTER DELIM TAG_OBJE
-              { $<ctxt>$ = start_record(REC_OBJE, $1, $3, $5);
+              { $<ctxt>$ = start_record(REC_OBJE,
+                                       $1, GEDCOM_MAKE_STRING($3), $5);
                START(OBJE, $<ctxt>$) }
               obje_subs
              { CHECK2(FORM, BLOB) }
@@ -1096,7 +1146,8 @@ obje_sub    : obje_form_sect  { OCCUR2(FORM, 1, 1) }
 /* OBJE.FORM */
 obje_form_sect : OPEN DELIM TAG_FORM mand_line_item       
                  { $<ctxt>$ = start_element(ELT_OBJE_FORM,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(FORM, $<ctxt>$)            
                 }            
                 no_std_subs            
@@ -1109,7 +1160,8 @@ obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
 /* OBJE.TITL */
 obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item       
                  { $<ctxt>$ = start_element(ELT_OBJE_TITL,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(TITL, $<ctxt>$)             
                 }             
                 no_std_subs             
@@ -1122,7 +1174,8 @@ obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
 /* OBJE.BLOB */
 obje_blob_sect : OPEN DELIM TAG_BLOB
                  { $<ctxt>$ = start_element(ELT_OBJE_BLOB,
-                                           PARENT, $1, $3, NULL, NULL);
+                                           PARENT, $1, $3, NULL,
+                                           GEDCOM_MAKE_NULL());
                   START(BLOB, $<ctxt>$)              
                 }
                  obje_blob_subs
@@ -1142,7 +1195,8 @@ obje_blob_sub  : obje_blob_cont_sect  { OCCUR1(CONT, 1) }
 
 obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item        
                       { $<ctxt>$ = start_element(ELT_OBJE_BLOB_CONT,
-                                                PARENT, $1, $3, $4, $4);
+                                                PARENT, $1, $3, $4, 
+                                                GEDCOM_MAKE_STRING($4));
                        START(CONT, $<ctxt>$)               
                      }                
                      no_std_subs                
@@ -1156,7 +1210,8 @@ obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item
 /* OBJE.OBJE */
 obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer 
                  { $<ctxt>$ = start_element(ELT_OBJE_OBJE,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(OBJE, $<ctxt>$)  
                  }  
                  no_std_subs  
@@ -1170,7 +1225,8 @@ obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer
 /**** Note record                                                 ****/
 /*********************************************************************/
 note_rec    : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item
-              { $<ctxt>$ = start_record(REC_NOTE, $1, $3, $5);
+              { $<ctxt>$ = start_record(REC_NOTE,
+                                       $1, GEDCOM_MAKE_STRING($3), $5);
                START(NOTE, $<ctxt>$) }
               note_subs
              { CHECK0 }
@@ -1203,7 +1259,8 @@ note_sub    : continuation_sub  /* 0:M */
 /**** Repository record                                           ****/
 /*********************************************************************/
 repos_rec   : OPEN DELIM POINTER DELIM TAG_REPO
-              { $<ctxt>$ = start_record(REC_REPO, $1, $3, $5);
+              { $<ctxt>$ = start_record(REC_REPO,
+                                       $1, GEDCOM_MAKE_STRING($3), $5);
                START(REPO, $<ctxt>$) }
               repo_subs
              { CHECK0 }
@@ -1226,7 +1283,8 @@ repo_sub    : repo_name_sect  { OCCUR2(NAME, 0, 1) }
 /* REPO.NAME */
 repo_name_sect : OPEN DELIM TAG_NAME mand_line_item         
                  { $<ctxt>$ = start_element(ELT_REPO_NAME,
-                                           PARENT, $1, $3, $4, $4);
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
                   START(NAME, $<ctxt>$)          
                  }          
                  no_std_subs          
@@ -1240,7 +1298,8 @@ repo_name_sect : OPEN DELIM TAG_NAME mand_line_item
 /**** Source record                                               ****/
 /*********************************************************************/
 source_rec  : OPEN DELIM POINTER DELIM TAG_SOUR
-              { $<ctxt>$ = start_record(REC_SOUR, $1, $3, $5);
+              { $<ctxt>$ = start_record(REC_SOUR,
+                                       $1, GEDCOM_MAKE_STRING($3), $5);
                START(SOUR, $<ctxt>$) }
               sour_subs
              { CHECK0 }
@@ -1268,10 +1327,16 @@ sour_sub    : sour_data_sect  { OCCUR2(DATA, 0, 1) }
 
 /* SOUR.DATA */
 sour_data_sect : OPEN DELIM TAG_DATA
-                 { START(DATA, NULL) }
+                 { $<ctxt>$ = start_element(ELT_SOUR_DATA,
+                                           PARENT, $1, $3, NULL,
+                                           GEDCOM_MAKE_NULL());
+                  START(DATA, $<ctxt>$) 
+                 }
                  sour_data_subs
                 { CHECK0 }
-                 CLOSE { }
+                 CLOSE 
+                 { end_element(ELT_SOUR_DATA, PARENT, $<ctxt>4, NULL);
+                }
                ;
 
 sour_data_subs : /* empty */
@@ -1285,10 +1350,17 @@ sour_data_sub  : sour_data_even_sect  /* 0:M */
                ;
 
 sour_data_even_sect : OPEN DELIM TAG_EVEN mand_line_item 
-                      { START(EVEN, NULL) }
+                      { $<ctxt>$ = start_element(ELT_SOUR_DATA_EVEN,
+                                                PARENT, $1, $3, $4, 
+                                                GEDCOM_MAKE_STRING($4));
+                       START(EVEN, $<ctxt>$)  
+                      }
                       sour_data_even_subs
                      { CHECK0 }
-                      CLOSE { }
+                      CLOSE  
+                      { end_element(ELT_SOUR_DATA_EVEN, PARENT,
+                                   $<ctxt>5, NULL);
+                     }
                     ;
 
 sour_data_even_subs : /* empty */
@@ -1301,23 +1373,60 @@ sour_data_even_sub  : sour_data_even_date_sect { OCCUR2(DATE, 0, 1) }
                     ;
 
 sour_data_even_date_sect : OPEN DELIM TAG_DATE mand_line_item          
-                           { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                           { struct date_value dv = gedcom_parse_date($4);
+                            $<ctxt>$ = start_element(ELT_SOUR_DATA_EVEN_DATE,
+                                                     PARENT, $1, $3, $4, 
+                                                     GEDCOM_MAKE_DATE(dv));
+                            START(DATE, $<ctxt>$)           
+                           }           
+                           no_std_subs           
+                           { CHECK0 }           
+                           CLOSE           
+                           { end_element(ELT_SOUR_DATA_EVEN_DATE, PARENT,
+                                        $<ctxt>5, NULL);
+                          }
                          ;
 
 sour_data_even_plac_sect : OPEN DELIM TAG_PLAC mand_line_item          
-                           { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                           { $<ctxt>$ = start_element(ELT_SOUR_DATA_EVEN_PLAC,
+                                                     PARENT, $1, $3, $4, 
+                                                     GEDCOM_MAKE_STRING($4));
+                            START(PLAC, $<ctxt>$)           
+                           }           
+                           no_std_subs           
+                           { CHECK0 }           
+                           CLOSE           
+                           { end_element(ELT_SOUR_DATA_EVEN_PLAC, PARENT,
+                                        $<ctxt>5, NULL);
+                          }
                          ;
 
 sour_data_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item          
-                      { START(AGNC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SOUR_DATA_AGNC,
+                                                PARENT, $1, $3, $4, 
+                                                GEDCOM_MAKE_STRING($4));
+                       START(AGNC, $<ctxt>$)           
+                      }           
+                      no_std_subs           
+                      { CHECK0 }           
+                      CLOSE           
+                      { end_element(ELT_SOUR_DATA_AGNC, PARENT,
+                                   $<ctxt>5, NULL);
+                     }
                     ;
 
 /* SOUR.AUTH */
 sour_auth_sect : OPEN DELIM TAG_AUTH mand_line_item
-                 { START(AUTH, NULL) }
+                 { $<ctxt>$ = start_element(ELT_SOUR_AUTH,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(AUTH, $<ctxt>$) 
+                 }
                  sour_auth_subs
                 { CHECK0 }
-                 CLOSE { }
+                 CLOSE 
+                 { end_element(ELT_SOUR_AUTH, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 sour_auth_subs : /* empty */
@@ -1330,10 +1439,16 @@ sour_auth_sub  : continuation_sub  /* 0:M */
 
 /* SOUR.TITL */
 sour_titl_sect : OPEN DELIM TAG_TITL mand_line_item  
-                 { START(TITL, NULL) }
+                 { $<ctxt>$ = start_element(ELT_SOUR_TITL,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(TITL, $<ctxt>$)   
+                 }
                  sour_titl_subs 
                 { CHECK0 }
-                 CLOSE { }
+                 CLOSE   
+                 { end_element(ELT_SOUR_TITL, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 sour_titl_subs : /* empty */
@@ -1346,15 +1461,30 @@ sour_titl_sub  : continuation_sub  /* 0:M */
 
 /* SOUR.ABBR */
 sour_abbr_sect : OPEN DELIM TAG_ABBR mand_line_item           
-                 { START(ABBR, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SOUR_ABBR,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(ABBR, $<ctxt>$)            
+                 }            
+                 no_std_subs            
+                 { CHECK0 }            
+                 CLOSE            
+                 { end_element(ELT_SOUR_ABBR, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SOUR.PUBL */
 sour_publ_sect : OPEN DELIM TAG_PUBL mand_line_item  
-                 { START(PUBL, NULL) }
+                 { $<ctxt>$ = start_element(ELT_SOUR_PUBL,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(PUBL, $<ctxt>$)            
+                 }
                  sour_publ_subs  
                 { CHECK0 }
-                 CLOSE { }
+                 CLOSE            
+                 { end_element(ELT_SOUR_PUBL, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 sour_publ_subs : /* empty */
@@ -1367,10 +1497,16 @@ sour_publ_sub  : continuation_sub  /* 0:M */
 
 /* SOUR.TEXT */
 sour_text_sect : OPEN DELIM TAG_TEXT mand_line_item   
-                 { START(TEXT, NULL) }
+                 { $<ctxt>$ = start_element(ELT_SOUR_TEXT,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(TEXT, $<ctxt>$)    
+                 }
                  sour_text_subs  
                 { CHECK0 }
-                 CLOSE { }
+                 CLOSE    
+                 { end_element(ELT_SOUR_TEXT, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 sour_text_subs : /* empty */
@@ -1385,7 +1521,8 @@ sour_text_sub  : continuation_sub  /* 0:M */
 /**** Submission record                                           ****/
 /*********************************************************************/
 submis_rec  : OPEN DELIM POINTER DELIM TAG_SUBN    
-              { $<ctxt>$ = start_record(REC_SUBN, $1, $3, $5);
+              { $<ctxt>$ = start_record(REC_SUBN,
+                                       $1, GEDCOM_MAKE_STRING($3), $5);
                START(SUBN, $<ctxt>$) }
               subn_subs
              { CHECK0 }
@@ -1409,44 +1546,108 @@ subn_sub    : subn_subm_sect  { OCCUR2(SUBM, 0, 1) }
 
 /* SUBN.SUBM */
 subn_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
-                 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_SUBM,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(SUBM, $<ctxt>$) 
+                 } 
+                 no_std_subs 
+                 { CHECK0 } 
+                 CLOSE 
+                 { end_element(ELT_SUBN_SUBM, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBN.FAMF */
 subn_famf_sect : OPEN DELIM TAG_FAMF mand_line_item            
-                 { START(FAMF, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_FAMF,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(FAMF, $<ctxt>$)             
+                 }             
+                 no_std_subs             
+                 { CHECK0 }             
+                 CLOSE             
+                 { end_element(ELT_SUBN_FAMF, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBN.TEMP */
 subn_temp_sect : OPEN DELIM TAG_TEMP mand_line_item            
-                 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_TEMP,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(TEMP, $<ctxt>$)             
+                 }             
+                 no_std_subs             
+                 { CHECK0 }             
+                 CLOSE             
+                 { end_element(ELT_SUBN_TEMP, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBN.ANCE */
 subn_ance_sect : OPEN DELIM TAG_ANCE mand_line_item            
-                 { START(ANCE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_ANCE,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(ANCE, $<ctxt>$)             
+                 }             
+                 no_std_subs             
+                 { CHECK0 }             
+                 CLOSE             
+                 { end_element(ELT_SUBN_ANCE, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBN.DESC */
 subn_desc_sect : OPEN DELIM TAG_DESC mand_line_item            
-                 { START(DESC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_DESC,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(DESC, $<ctxt>$)             
+                 }             
+                 no_std_subs             
+                 { CHECK0 }             
+                 CLOSE             
+                 { end_element(ELT_SUBN_DESC, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBN.ORDI */
 subn_ordi_sect : OPEN DELIM TAG_ORDI mand_line_item            
-                 { START(ORDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_ORDI,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(ORDI, $<ctxt>$)             
+                 }             
+                 no_std_subs             
+                 { CHECK0 }             
+                 CLOSE             
+                 { end_element(ELT_SUBN_ORDI, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBN.RIN */
 subn_rin_sect  : OPEN DELIM TAG_RIN mand_line_item            
-                 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBN_RIN,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(RIN, $<ctxt>$)             
+                 }             
+                 no_std_subs             
+                 { CHECK0 }             
+                 CLOSE             
+                 { end_element(ELT_SUBN_RIN, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /*********************************************************************/
 /**** Submitter record                                            ****/
 /*********************************************************************/
 submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM    
-             { $<ctxt>$ = start_record(REC_SUBM, $1, $3, $5);
+             { $<ctxt>$ = start_record(REC_SUBM,
+                                      $1, GEDCOM_MAKE_STRING($3), $5);
                START(SUBM, $<ctxt>$) }
              subm_subs
             { CHECK1(NAME) }
@@ -1470,22 +1671,58 @@ subm_sub   : subm_name_sect  { OCCUR2(NAME, 0, 1) }
 
 /* SUBM.NAME */
 subm_name_sect : OPEN DELIM TAG_NAME mand_line_item             
-                 { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBM_NAME,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(NAME, $<ctxt>$)              
+                 }              
+                 no_std_subs              
+                 { CHECK0 }              
+                 CLOSE              
+                 { end_element(ELT_SUBM_NAME, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBM.LANG */
 subm_lang_sect : OPEN DELIM TAG_LANG mand_line_item             
-                 { START(LANG, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBM_LANG,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(LANG, $<ctxt>$)              
+                 }              
+                 no_std_subs              
+                 { CHECK0 }              
+                 CLOSE              
+                 { end_element(ELT_SUBM_LANG, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBM.RFN */
 subm_rfn_sect  : OPEN DELIM TAG_RFN mand_line_item             
-                 { START(RFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBM_RFN,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(RFN, $<ctxt>$)              
+                 }              
+                 no_std_subs              
+                 { CHECK0 }              
+                 CLOSE              
+                 { end_element(ELT_SUBM_RFN, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* SUBM.RIN */
 subm_rin_sect  : OPEN DELIM TAG_RIN mand_line_item             
-                 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUBM_RIN,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(RIN, $<ctxt>$)              
+                 }              
+                 no_std_subs              
+                 { CHECK0 }              
+                 CLOSE              
+                 { end_element(ELT_SUBM_RIN, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /*********************************************************************/
@@ -1498,10 +1735,16 @@ addr_struc_sub : addr_sect { OCCUR2(ADDR, 0, 1) }
                ;
 
 addr_sect   : OPEN DELIM TAG_ADDR mand_line_item 
-              { START(ADDR, NULL) }
+              { $<ctxt>$ = start_element(ELT_SUB_ADDR,
+                                        PARENT, $1, $3, $4, 
+                                        GEDCOM_MAKE_STRING($4));
+               START(ADDR, $<ctxt>$)  
+              }
               addr_subs
              { CHECK0 }
-              CLOSE { }
+              CLOSE  
+              { end_element(ELT_SUB_ADDR, PARENT, $<ctxt>5, NULL);
+             }
             ;
 
 addr_subs   : /* empty */
@@ -1519,29 +1762,101 @@ addr_sub    : addr_cont_sect  /* 0:M */
             ;
 
 addr_cont_sect : OPEN DELIM TAG_CONT mand_line_item              
-                 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_CONT,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(CONT, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_CONT, PARENT, $<ctxt>5, NULL);
+                }
                ;
 addr_adr1_sect : OPEN DELIM TAG_ADR1 mand_line_item              
-                 { START(ADR1, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_ADR1,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(ADR1, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_ADR1, PARENT, $<ctxt>5, NULL);
+                }
                ;
 addr_adr2_sect : OPEN DELIM TAG_ADR2 mand_line_item              
-                 { START(ADR2, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_ADR2,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(ADR2, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_ADR2, PARENT, $<ctxt>5, NULL);
+                }
                ;
 addr_city_sect : OPEN DELIM TAG_CITY mand_line_item              
-                 { START(CITY, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_CITY,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(CITY, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_CITY, PARENT, $<ctxt>5, NULL);
+                }
                ;
 addr_stae_sect : OPEN DELIM TAG_STAE mand_line_item              
-                 { START(STAE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_STAE,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(STAE, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_STAE, PARENT, $<ctxt>5, NULL);
+                }
                ;
 addr_post_sect : OPEN DELIM TAG_POST mand_line_item              
-                 { START(POST, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_POST,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(POST, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_POST, PARENT, $<ctxt>5, NULL);
+                }
                ;
 addr_ctry_sect : OPEN DELIM TAG_CTRY mand_line_item              
-                 { START(CTRY, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ADDR_CTRY,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(CTRY, $<ctxt>$)               
+                 }               
+                 no_std_subs               
+                 { CHECK0 }               
+                 CLOSE               
+                 { end_element(ELT_SUB_ADDR_CTRY, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 phon_sect   : OPEN DELIM TAG_PHON mand_line_item              
-              { START(PHON, NULL) } no_std_subs { CHECK0 } CLOSE { }
+              { $<ctxt>$ = start_element(ELT_SUB_PHON,
+                                        PARENT, $1, $3, $4, 
+                                        GEDCOM_MAKE_STRING($4));
+               START(PHON, $<ctxt>$)               
+              }               
+              no_std_subs               
+              { CHECK0 }               
+              CLOSE               
+              { end_element(ELT_SUB_PHON, PARENT, $<ctxt>5, NULL);
+             }
             ;
 
 /* ASSOCIATION STRUCTURE */
@@ -1549,10 +1864,16 @@ assoc_struc_sub : asso_sect /* 0:M */
                 ;
 
 asso_sect : OPEN DELIM TAG_ASSO mand_pointer
-            { START(ASSO, NULL) }
+            { $<ctxt>$ = start_element(ELT_SUB_ASSO,
+                                      PARENT, $1, $3, $4, 
+                                      GEDCOM_MAKE_STRING($4));
+             START(ASSO, $<ctxt>$) 
+            }
             asso_subs
            { CHECK2(TYPE,RELA) }
-            CLOSE { }
+            CLOSE 
+            { end_element(ELT_SUB_ASSO, PARENT, $<ctxt>5, NULL);
+           }
           ;
 
 asso_subs : /* empty */
@@ -1564,11 +1885,29 @@ asso_subs : /* empty */
           ;
 
 asso_type_sect : OPEN DELIM TAG_TYPE mand_line_item               
-                 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ASSO_TYPE,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(TYPE, $<ctxt>$)                
+                 }                
+                 no_std_subs                
+                 { CHECK0 }                
+                 CLOSE                
+                 { end_element(ELT_SUB_ASSO_TYPE, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 asso_rela_sect : OPEN DELIM TAG_RELA mand_line_item               
-                 { START(RELA, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_ASSO_RELA,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(RELA, $<ctxt>$)                
+                 }                
+                 no_std_subs                
+                 { CHECK0 }                
+                 CLOSE                
+                 { end_element(ELT_SUB_ASSO_RELA, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* CHANGE DATE */
@@ -1576,10 +1915,16 @@ change_date_sub : change_date_chan_sect  { OCCUR2(CHAN, 0, 1) }
                 ;
 
 change_date_chan_sect : OPEN DELIM TAG_CHAN
-                        { START(CHAN, NULL) }
+                        { $<ctxt>$ = start_element(ELT_SUB_CHAN,
+                                                  PARENT, $1, $3, NULL, 
+                                                  GEDCOM_MAKE_NULL());
+                         START(CHAN, $<ctxt>$) 
+                        }
                         change_date_chan_subs
                        { CHECK1(DATE) }
-                        CLOSE { }
+                        CLOSE 
+                        { end_element(ELT_SUB_CHAN, PARENT, $<ctxt>4, NULL);
+                       }
                       ;
 
 change_date_chan_subs : /* empty */
@@ -1592,10 +1937,17 @@ change_date_chan_sub  : change_date_date_sect  { OCCUR2(DATE, 1, 1) }
                       ;
 
 change_date_date_sect : OPEN DELIM TAG_DATE mand_line_item 
-                        { START(DATE, NULL) }
+                        { struct date_value dv = gedcom_parse_date($4);
+                         $<ctxt>$ = start_element(ELT_SUB_CHAN_DATE,
+                                                  PARENT, $1, $3, $4, 
+                                                  GEDCOM_MAKE_DATE(dv));
+                         START(DATE, $<ctxt>$) }
                         change_date_date_subs
                        { CHECK0 }
-                        CLOSE { }
+                        CLOSE 
+                       { end_element(ELT_SUB_CHAN_DATE, PARENT, $<ctxt>5,
+                                     NULL);
+                       }
                       ;
 
 change_date_date_subs : /* empty */
@@ -1607,7 +1959,18 @@ change_date_date_sub : change_date_date_time_sect  { OCCUR2(TIME, 0, 1) }
                      ;
 
 change_date_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
-                             { START(TIME, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                             { $<ctxt>$
+                                = start_element(ELT_SUB_CHAN_TIME,
+                                                PARENT, $1, $3, $4, 
+                                                GEDCOM_MAKE_STRING($4));
+                              START(TIME, $<ctxt>$) 
+                             } 
+                             no_std_subs 
+                             { CHECK0 } 
+                             CLOSE 
+                             { end_element(ELT_SUB_CHAN_TIME, PARENT, $<ctxt>5,
+                                          NULL);
+                            }
                            ;
 
 /* CHILD TO FAMILY LINK */
@@ -1615,10 +1978,16 @@ chi_fam_link_sub : famc_sect  /* 0:M */
                  ;
 
 famc_sect : OPEN DELIM TAG_FAMC mand_pointer
-            { START(FAMC, NULL) }
+            { $<ctxt>$ = start_element(ELT_SUB_FAMC,
+                                      PARENT, $1, $3, $4, 
+                                      GEDCOM_MAKE_STRING($4));
+             START(FAMC, $<ctxt>$) 
+            }
             famc_subs
            { CHECK0 }
-            CLOSE { }
+            CLOSE 
+            { end_element(ELT_SUB_FAMC, PARENT, $<ctxt>5, NULL);
+           }
           ;
 
 famc_subs : /* empty */
@@ -1631,7 +2000,16 @@ famc_sub  : famc_pedi_sect  /* 0:M */
           ;
 
 famc_pedi_sect : OPEN DELIM TAG_PEDI mand_line_item 
-                 { START(PEDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_FAMC_PEDI,
+                                           PARENT, $1, $3, $4, 
+                                           GEDCOM_MAKE_STRING($4));
+                  START(PEDI, $<ctxt>$)  
+                 }  
+                 no_std_subs  
+                 { CHECK0 }  
+                 CLOSE  
+                 { end_element(ELT_SUB_FAMC_PEDI, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 /* CONTINUATION SUBSECTIONS */
@@ -1640,11 +2018,29 @@ continuation_sub : cont_sect  /* 0:M */
                  ;
 
 cont_sect : OPEN DELIM TAG_CONT mand_line_item 
-            { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
+            { $<ctxt>$ = start_element(ELT_SUB_CONT,
+                                      PARENT, $1, $3, $4, 
+                                      GEDCOM_MAKE_STRING($4));
+             START(CONT, $<ctxt>$)  
+            }  
+            no_std_subs  
+            { CHECK0 }  
+            CLOSE  
+            { end_element(ELT_SUB_CONT, PARENT, $<ctxt>5, NULL);
+           }
           ;
 
 conc_sect : OPEN DELIM TAG_CONC mand_line_item 
-            { START(CONC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+            { $<ctxt>$ = start_element(ELT_SUB_CONC,
+                                      PARENT, $1, $3, $4, 
+                                      GEDCOM_MAKE_STRING($4));
+             START(CONC, $<ctxt>$)  
+            }  
+            no_std_subs  
+            { CHECK0 }  
+            CLOSE  
+            { end_element(ELT_SUB_CONC, PARENT, $<ctxt>5, NULL);
+           }
           ; 
 
 /* EVENT DETAIL */
@@ -1661,19 +2057,70 @@ event_detail_sub : event_detail_type_sect  { OCCUR2(TYPE, 0, 1) }
                  ;
 
 event_detail_type_sect : OPEN DELIM TAG_TYPE mand_line_item 
-                         { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                         { $<ctxt>$ = start_element(ELT_SUB_EVT_TYPE,
+                                                   PARENT, $1, $3, $4, 
+                                                   GEDCOM_MAKE_STRING($4));
+                          START(TYPE, $<ctxt>$)  
+                         }  
+                         no_std_subs  
+                         { CHECK0 }  
+                         CLOSE  
+                         { end_element(ELT_SUB_EVT_TYPE, PARENT, $<ctxt>5,
+                                      NULL);
+                        }
                        ;
 event_detail_date_sect : OPEN DELIM TAG_DATE mand_line_item 
-                         { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                         { struct date_value dv = gedcom_parse_date($4);
+                          $<ctxt>$ = start_element(ELT_SUB_EVT_DATE,
+                                                   PARENT, $1, $3, $4, 
+                                                   GEDCOM_MAKE_DATE(dv));
+                          START(DATE, $<ctxt>$)  
+                         }  
+                         no_std_subs  
+                         { CHECK0 }  
+                         CLOSE  
+                         { end_element(ELT_SUB_EVT_DATE, PARENT, $<ctxt>5,
+                                      NULL);
+                        }
                        ;
 event_detail_age_sect  : OPEN DELIM TAG_AGE mand_line_item 
-                         { START(AGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                         { $<ctxt>$ = start_element(ELT_SUB_EVT_AGE,
+                                                   PARENT, $1, $3, $4, 
+                                                   GEDCOM_MAKE_STRING($4));
+                          START(AGE, $<ctxt>$)  
+                         }  
+                         no_std_subs  
+                         { CHECK0 }  
+                         CLOSE  
+                         { end_element(ELT_SUB_EVT_AGE, PARENT, $<ctxt>5,
+                                      NULL);
+                        }
                        ;
 event_detail_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item 
-                         { START(AGNC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                         { $<ctxt>$ = start_element(ELT_SUB_EVT_AGNC,
+                                                   PARENT, $1, $3, $4, 
+                                                   GEDCOM_MAKE_STRING($4));
+                          START(AGNC, $<ctxt>$)  
+                         }  
+                         no_std_subs  
+                         { CHECK0 }  
+                         CLOSE  
+                         { end_element(ELT_SUB_EVT_AGNC, PARENT, $<ctxt>5,
+                                      NULL);
+                        }
                        ;
 event_detail_caus_sect : OPEN DELIM TAG_CAUS mand_line_item 
-                         { START(CAUS, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                         { $<ctxt>$ = start_element(ELT_SUB_EVT_CAUS,
+                                                   PARENT, $1, $3, $4, 
+                                                   GEDCOM_MAKE_STRING($4));
+                          START(CAUS, $<ctxt>$)  
+                         }  
+                         no_std_subs  
+                         { CHECK0 }  
+                         CLOSE  
+                         { end_element(ELT_SUB_EVT_CAUS, PARENT, $<ctxt>5,
+                                      NULL);
+                        }
                        ;
 
 /* FAMILY EVENT STRUCTURE */
@@ -1681,21 +2128,31 @@ fam_event_struc_sub : fam_event_sect
                     | fam_gen_even_sect  /* 0:M */
                     ;
 
-fam_event_sect : OPEN DELIM fam_event_tag opt_value fam_event_subs
+fam_event_sect : OPEN DELIM fam_event_tag opt_value  
+                 { 
+                  $<ctxt>$ = start_element(ELT_SUB_FAM_EVT,
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_NULL_OR_STRING($4));
+                  /* set the parent context separately from START here */
+                  set_parentctxt($<ctxt>$);
+                }
+                 fam_event_subs
                  { CHECK0 }
-                 CLOSE { }
-               ;
-
-fam_event_tag : TAG_ANUL { START(ANUL, NULL) }
-              | TAG_CENS { START(CENS, NULL) }
-              | TAG_DIV { START(DIV, NULL) }
-              | TAG_DIVF { START(DIVF, NULL) }
-              | TAG_ENGA { START(ENGA, NULL) }
-              | TAG_MARR { START(MARR, NULL) }
-              | TAG_MARB { START(MARB, NULL) }
-              | TAG_MARC { START(MARC, NULL) }
-              | TAG_MARL { START(MARL, NULL) }
-              | TAG_MARS { START(MARS, NULL) }
+                 CLOSE 
+                 { end_element(ELT_SUB_FAM_EVT, PARENT, $<ctxt>5, NULL);
+                }
+               ;
+
+fam_event_tag : TAG_ANUL { $$ = $1; START(ANUL, NULL) }
+              | TAG_CENS { $$ = $1; START(CENS, NULL) }
+              | TAG_DIV { $$ = $1; START(DIV, NULL) }
+              | TAG_DIVF { $$ = $1; START(DIVF, NULL) }
+              | TAG_ENGA { $$ = $1; START(ENGA, NULL) }
+              | TAG_MARR { $$ = $1; START(MARR, NULL) }
+              | TAG_MARB { $$ = $1; START(MARB, NULL) }
+              | TAG_MARC { $$ = $1; START(MARC, NULL) }
+              | TAG_MARL { $$ = $1; START(MARL, NULL) }
+              | TAG_MARS { $$ = $1; START(MARS, NULL) }
               ;
 
 fam_event_subs : /* empty */
@@ -1709,36 +2166,67 @@ fam_event_sub : event_detail_sub
               ;
 
 fam_even_husb_sect : OPEN DELIM TAG_HUSB
-                     { START(HUSB, NULL) }
+                     { $<ctxt>$ = start_element(ELT_SUB_FAM_EVT_HUSB,
+                                               PARENT, $1, $3, NULL,
+                                               GEDCOM_MAKE_NULL());
+                      START(HUSB, $<ctxt>$) 
+                     }
                      fam_even_husb_subs
                     { CHECK1(AGE) }
-                     CLOSE { }
+                     CLOSE 
+                     { end_element(ELT_SUB_FAM_EVT_HUSB, PARENT, $<ctxt>4,
+                                  NULL);
+                    }
                    ;
 
 fam_even_husb_subs : /* empty */
                    | fam_even_husb_subs fam_even_husb_sub
                    ;
 
-fam_even_husb_sub : fam_even_husb_age_sect  { OCCUR2(AGE, 1, 1) }
+fam_even_husb_sub : fam_even_age_sect  { OCCUR2(AGE, 1, 1) }
                   | no_std_sub
                   ;
 
-fam_even_husb_age_sect : OPEN DELIM TAG_AGE mand_line_item  
-                         { START(AGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
-                       ;
+fam_even_age_sect : OPEN DELIM TAG_AGE mand_line_item  
+                    { $<ctxt>$ = start_element(ELT_SUB_FAM_EVT_AGE,
+                                              PARENT, $1, $3, $4,
+                                              GEDCOM_MAKE_STRING($4));
+                     START(AGE, $<ctxt>$)   
+                    }   
+                    no_std_subs   
+                    { CHECK0 }   
+                    CLOSE   
+                    { end_element(ELT_SUB_FAM_EVT_AGE, PARENT, $<ctxt>5,
+                                 NULL);
+                   }
+                  ;
 
 fam_even_wife_sect : OPEN DELIM TAG_WIFE
-                     { START(HUSB, NULL) }
+                     { $<ctxt>$ = start_element(ELT_SUB_FAM_EVT_WIFE,
+                                               PARENT, $1, $3, NULL,
+                                               GEDCOM_MAKE_NULL());
+                      START(WIFE, $<ctxt>$) 
+                     }
                      fam_even_husb_subs
                     { CHECK1(AGE) }
-                     CLOSE { }
+                     CLOSE 
+                     { end_element(ELT_SUB_FAM_EVT_WIFE, PARENT, $<ctxt>4,
+                                  NULL);
+                    }
                    ;
 
 fam_gen_even_sect : OPEN DELIM TAG_EVEN
-                    { START(EVEN, NULL) }
+                    { $<ctxt>$ = start_element(ELT_SUB_FAM_EVT_EVEN,
+                                               PARENT, $1, $3, NULL,
+                                               GEDCOM_MAKE_NULL());
+                      START(EVEN, $<ctxt>$) 
+                    }
                     fam_gen_even_subs
                    { CHECK0 }
-                    CLOSE { }
+                    CLOSE 
+                    { end_element(ELT_SUB_FAM_EVT_EVEN, PARENT, $<ctxt>4,
+                                 NULL);
+                   }
                   ;
 
 fam_gen_even_subs : /* empty */
@@ -1757,10 +2245,17 @@ ident_struc_sub : ident_refn_sect  /* 0:M */
                 ;
 
 ident_refn_sect : OPEN DELIM TAG_REFN mand_line_item 
-                  { START(REFN, NULL) }
+                  { $<ctxt>$ = start_element(ELT_SUB_IDENT_REFN,
+                                            PARENT, $1, $3, $4,
+                                            GEDCOM_MAKE_STRING($4));
+                   START(REFN, $<ctxt>$)  
+                  }
                   ident_refn_subs
                  { CHECK0 }
-                  CLOSE { }
+                  CLOSE  
+                  { end_element(ELT_SUB_IDENT_REFN, PARENT, $<ctxt>5,
+                               NULL);
+                 }
                 ;
 
 ident_refn_subs : /* empty */
@@ -1772,106 +2267,75 @@ ident_refn_sub  : ident_refn_type_sect  { OCCUR2(TYPE, 0, 1) }
                 ;
 
 ident_refn_type_sect : OPEN DELIM TAG_TYPE mand_line_item   
-                       { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                       { $<ctxt>$ = start_element(ELT_SUB_IDENT_REFN_TYPE,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(TYPE, $<ctxt>$)    
+                       }    
+                       no_std_subs    
+                       { CHECK0 }    
+                       CLOSE    
+                       { end_element(ELT_SUB_IDENT_REFN_TYPE, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 ident_rin_sect  : OPEN DELIM TAG_RIN mand_line_item   
-                  { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                  { $<ctxt>$ = start_element(ELT_SUB_IDENT_RIN,
+                                            PARENT, $1, $3, $4,
+                                            GEDCOM_MAKE_STRING($4));
+                   START(RIN, $<ctxt>$)    
+                  }    
+                  no_std_subs    
+                  { CHECK0 }    
+                  CLOSE    
+                  { end_element(ELT_SUB_IDENT_RIN, PARENT, $<ctxt>5,
+                               NULL);
+                 }
                 ;
 
 /* INDIVIDUAL ATTRIBUTE STRUCTURE */
-indiv_attr_struc_sub : indiv_cast_sect  /* 0:M */
-                     | indiv_dscr_sect  /* 0:M */
-                     | indiv_educ_sect  /* 0:M */
-                     | indiv_idno_sect  /* 0:M */
-                     | indiv_nati_sect  /* 0:M */
-                     | indiv_nchi_sect  /* 0:M */
-                     | indiv_nmr_sect  /* 0:M */
-                     | indiv_occu_sect  /* 0:M */
-                     | indiv_prop_sect  /* 0:M */
-                     | indiv_reli_sect  /* 0:M */
+indiv_attr_struc_sub : indiv_attr_sect   /* 0:M */
                      | indiv_resi_sect  /* 0:M */
-                     | indiv_ssn_sect  /* 0:M */
-                     | indiv_titl_sect  /* 0:M */
                      ;
 
-indiv_cast_sect : OPEN DELIM TAG_CAST mand_line_item 
-                  { START(CAST, NULL) }
-                  indiv_attr_event_subs
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_dscr_sect : OPEN DELIM TAG_DSCR mand_line_item 
-                  { START(DSCR, NULL) }
+indiv_attr_sect : OPEN DELIM indiv_attr_tag mand_line_item
+                  { $<ctxt>$ = start_element(ELT_SUB_INDIV_ATTR,
+                                            PARENT, $1, $3, $4,
+                                            GEDCOM_MAKE_STRING($4));
+                   /* set the parent context separately from START here */
+                   set_parentctxt($<ctxt>$);
+                 }
                   indiv_attr_event_subs
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_educ_sect : OPEN DELIM TAG_EDUC mand_line_item  
-                  { START(EDUC, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_idno_sect : OPEN DELIM TAG_IDNO mand_line_item 
-                  { START(IDNO, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_nati_sect : OPEN DELIM TAG_NATI mand_line_item 
-                  { START(NATI, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item 
-                  { START(NCHI, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_nmr_sect  : OPEN DELIM TAG_NMR mand_line_item 
-                  { START(NMR, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_occu_sect : OPEN DELIM TAG_OCCU mand_line_item 
-                  { START(OCCU, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_prop_sect : OPEN DELIM TAG_PROP mand_line_item 
-                  { START(PROP, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_reli_sect : OPEN DELIM TAG_RELI mand_line_item 
-                  { START(RELI, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
+                  { CHECK0 }
+                  CLOSE
+                  { end_element(ELT_SUB_INDIV_ATTR, PARENT, $<ctxt>5, NULL);
+                 }
+
+indiv_attr_tag  : TAG_CAST { $$ = $1; START(CAST, NULL) }
+                | TAG_DSCR { $$ = $1; START(DSCR, NULL) }
+                | TAG_EDUC { $$ = $1; START(EDUC, NULL) }
+                | TAG_IDNO { $$ = $1; START(IDNO, NULL) }
+                | TAG_NATI { $$ = $1; START(NATI, NULL) }
+                | TAG_NCHI { $$ = $1; START(NCHI, NULL) }
+                | TAG_NMR  { $$ = $1; START(NMR, NULL) }
+                | TAG_OCCU { $$ = $1; START(OCCU, NULL) }
+                | TAG_PROP { $$ = $1; START(PROP, NULL) }
+                | TAG_RELI { $$ = $1; START(RELI, NULL) }
+                | TAG_SSN  { $$ = $1; START(SSN, NULL) }
+                | TAG_TITL { $$ = $1; START(TITL, NULL) }
+
 indiv_resi_sect : OPEN DELIM TAG_RESI 
-                  { START(RESI, NULL) }
+                  { $<ctxt>$ = start_element(ELT_SUB_INDIV_RESI,
+                                            PARENT, $1, $3, NULL,
+                                            GEDCOM_MAKE_NULL());
+                   START(RESI, $<ctxt>$)  
+                  }
                   indiv_attr_event_subs 
                  { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_ssn_sect  : OPEN DELIM TAG_SSN mand_line_item 
-                  { START(SSN, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
-                ;
-indiv_titl_sect : OPEN DELIM TAG_TITL mand_line_item 
-                  { START(TITL, NULL) }
-                  indiv_attr_event_subs 
-                 { CHECK0 }
-                  CLOSE { }
+                  CLOSE  
+                  { end_element(ELT_SUB_INDIV_RESI, PARENT, $<ctxt>4, NULL);
+                 }
                 ;
 
 indiv_attr_event_subs : /* empty */
@@ -1889,13 +2353,22 @@ indiv_even_struc_sub : indiv_birt_sect
                      | indiv_even_sect  /* 0:M */
                      ;
 
-indiv_birt_sect : OPEN DELIM indiv_birt_tag opt_value indiv_birt_subs
+indiv_birt_sect : OPEN DELIM indiv_birt_tag opt_value 
+                  { $<ctxt>$ = start_element(ELT_SUB_INDIV_BIRT,
+                                            PARENT, $1, $3, $4,
+                                            GEDCOM_MAKE_NULL_OR_STRING($4));
+                   /* set the parent context separately from START here */
+                   set_parentctxt($<ctxt>$);
+                 }
+                  indiv_birt_subs
                   { CHECK0 }
-                  CLOSE { }
+                  CLOSE 
+                  { end_element(ELT_SUB_INDIV_BIRT, PARENT, $<ctxt>5, NULL);
+                 }
                 ;
 
-indiv_birt_tag  : TAG_BIRT { START(BIRT, NULL) }
-                | TAG_CHR { START(CHR, NULL) }
+indiv_birt_tag  : TAG_BIRT { $$ = $1; START(BIRT, NULL) }
+                | TAG_CHR { $$ = $1; START(CHR, NULL) }
                 ;
 
 indiv_birt_subs : /* empty */
@@ -1908,33 +2381,52 @@ indiv_birt_sub  : event_detail_sub
                 ;
 
 indiv_birt_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
-                       { START(FAMC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                       { $<ctxt>$ = start_element(ELT_SUB_INDIV_BIRT_FAMC,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(FAMC, $<ctxt>$) 
+                       } 
+                       no_std_subs 
+                       { CHECK0 } 
+                       CLOSE 
+                       { end_element(ELT_SUB_INDIV_BIRT_FAMC, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
-indiv_gen_sect  : OPEN DELIM indiv_gen_tag opt_value indiv_gen_subs
+indiv_gen_sect  : OPEN DELIM indiv_gen_tag opt_value 
+                  { $<ctxt>$ = start_element(ELT_SUB_INDIV_GEN,
+                                            PARENT, $1, $3, $4,
+                                            GEDCOM_MAKE_NULL_OR_STRING($4));
+                   /* set the parent context separately from START here */
+                   set_parentctxt($<ctxt>$);
+                 }
+                  indiv_gen_subs
                   { CHECK0 }
-                  CLOSE { }
+                  CLOSE 
+                  { end_element(ELT_SUB_INDIV_GEN, PARENT, $<ctxt>5, NULL);
+                 }
                 ;
 
-indiv_gen_tag   : TAG_DEAT { START(DEAT, NULL) }
-                | TAG_BURI { START(BURI, NULL) }
-                | TAG_CREM { START(CREM, NULL) }
-                | TAG_BAPM { START(BAPM, NULL) }
-                | TAG_BARM { START(BARM, NULL) }
-                | TAG_BASM { START(BASM, NULL) }
-                | TAG_BLES { START(BLES, NULL) }
-                | TAG_CHRA { START(CHRA, NULL) }
-                | TAG_CONF { START(CONF, NULL) }
-                | TAG_FCOM { START(FCOM, NULL) }
-                | TAG_ORDN { START(ORDN, NULL) }
-                | TAG_NATU { START(NATU, NULL) }
-                | TAG_EMIG { START(EMIG, NULL) }
-                | TAG_IMMI { START(IMMI, NULL) }
-                | TAG_CENS { START(CENS, NULL) }
-                | TAG_PROB { START(PROB, NULL) }
-                | TAG_WILL { START(WILL, NULL) }
-                | TAG_GRAD { START(GRAD, NULL) }
-                | TAG_RETI { START(RETI, NULL) }
+indiv_gen_tag   : TAG_DEAT { $$ = $1; START(DEAT, NULL) }
+                | TAG_BURI { $$ = $1; START(BURI, NULL) }
+                | TAG_CREM { $$ = $1; START(CREM, NULL) }
+                | TAG_BAPM { $$ = $1; START(BAPM, NULL) }
+                | TAG_BARM { $$ = $1; START(BARM, NULL) }
+                | TAG_BASM { $$ = $1; START(BASM, NULL) }
+                | TAG_BLES { $$ = $1; START(BLES, NULL) }
+                | TAG_CHRA { $$ = $1; START(CHRA, NULL) }
+                | TAG_CONF { $$ = $1; START(CONF, NULL) }
+                | TAG_FCOM { $$ = $1; START(FCOM, NULL) }
+                | TAG_ORDN { $$ = $1; START(ORDN, NULL) }
+                | TAG_NATU { $$ = $1; START(NATU, NULL) }
+                | TAG_EMIG { $$ = $1; START(EMIG, NULL) }
+                | TAG_IMMI { $$ = $1; START(IMMI, NULL) }
+                | TAG_CENS { $$ = $1; START(CENS, NULL) }
+                | TAG_PROB { $$ = $1; START(PROB, NULL) }
+                | TAG_WILL { $$ = $1; START(WILL, NULL) }
+                | TAG_GRAD { $$ = $1; START(GRAD, NULL) }
+                | TAG_RETI { $$ = $1; START(RETI, NULL) }
                 ;
 
 indiv_gen_subs  : /* empty */
@@ -1946,10 +2438,15 @@ indiv_gen_sub   : event_detail_sub
                 ;
 
 indiv_adop_sect : OPEN DELIM TAG_ADOP opt_value 
-                  { START(ADOP, NULL) }
+                  { $<ctxt>$ = start_element(ELT_SUB_INDIV_ADOP,
+                                            PARENT, $1, $3, $4,
+                                            GEDCOM_MAKE_NULL_OR_STRING($4));
+                   START(ADOP, $<ctxt>$) }
                   indiv_adop_subs
                  { CHECK0 }
-                  CLOSE { }
+                  CLOSE 
+                  { end_element(ELT_SUB_INDIV_ADOP, PARENT, $<ctxt>5, NULL);
+                 }
                 ;
 
 indiv_adop_subs : /* empty */
@@ -1962,10 +2459,16 @@ indiv_adop_sub  : event_detail_sub
                 ;
 
 indiv_adop_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
-                       { START(FAMC, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_INDIV_ADOP_FAMC,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(FAMC, $<ctxt>$) }
                        indiv_adop_famc_subs
                       { CHECK0 }
-                       CLOSE { }
+                       CLOSE 
+                      { end_element(ELT_SUB_INDIV_ADOP_FAMC, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 indiv_adop_famc_subs : /* empty */
@@ -1977,14 +2480,29 @@ indiv_adop_famc_sub  : indiv_adop_famc_adop_sect  { OCCUR2(ADOP,0, 1) }
                      ;
 
 indiv_adop_famc_adop_sect : OPEN DELIM TAG_ADOP mand_line_item   
-                            { START(ADOP, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                            { $<ctxt>$
+                               = start_element(ELT_SUB_INDIV_ADOP_FAMC_ADOP,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                             START(ADOP, $<ctxt>$) }    
+                            no_std_subs    
+                            { CHECK0 }    
+                            CLOSE    
+                            { end_element(ELT_SUB_INDIV_ADOP_FAMC_ADOP,
+                                         PARENT, $<ctxt>5, NULL);
+                           }
                           ;
 
 indiv_even_sect : OPEN DELIM TAG_EVEN
-                  { START(EVEN, NULL) }
+                  { $<ctxt>$ = start_element(ELT_SUB_INDIV_EVEN,
+                                            PARENT, $1, $3, NULL,
+                                            GEDCOM_MAKE_NULL());
+                   START(EVEN, $<ctxt>$) }
                   indiv_gen_subs
                  { CHECK0 }
-                  CLOSE { }
+                  CLOSE    
+                  { end_element(ELT_SUB_INDIV_EVEN, PARENT, $<ctxt>4, NULL);
+                 }
                 ;
 
 /* LDS INDIVIDUAL ORDINANCE */
@@ -1992,14 +2510,23 @@ lds_indiv_ord_sub : lio_bapl_sect  /* 0:M */
                   | lio_slgc_sect  /* 0:M */
                   ;
 
-lio_bapl_sect : OPEN DELIM lio_bapl_tag lio_bapl_subs
+lio_bapl_sect : OPEN DELIM lio_bapl_tag 
+                { $<ctxt>$ = start_element(ELT_SUB_LIO_BAPL,
+                                          PARENT, $1, $3, NULL,
+                                          GEDCOM_MAKE_NULL());
+                 /* set the parent context separately from START here */
+                 set_parentctxt($<ctxt>$);
+               }
+                lio_bapl_subs
                 { CHECK0 }
-                CLOSE { }
+                CLOSE 
+                { end_element(ELT_SUB_LIO_BAPL, PARENT, $<ctxt>4, NULL);
+               }
               ;
 
-lio_bapl_tag  : TAG_BAPL { START(BAPL, NULL) }
-              | TAG_CONL { START(CONL, NULL) }
-              | TAG_ENDL { START(ENDL, NULL) }
+lio_bapl_tag  : TAG_BAPL { $$ = $1; START(BAPL, NULL) }
+              | TAG_CONL { $$ = $1; START(CONL, NULL) }
+              | TAG_ENDL { $$ = $1; START(ENDL, NULL) }
               ;
 
 lio_bapl_subs : /* empty */
@@ -2016,23 +2543,70 @@ lio_bapl_sub  : lio_bapl_stat_sect  { OCCUR2(STAT, 0, 1) }
               ;
 
 lio_bapl_stat_sect : OPEN DELIM TAG_STAT mand_line_item   
-                     { START(STAT, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LIO_BAPL_STAT,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(STAT, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LIO_BAPL_STAT, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 lio_bapl_date_sect : OPEN DELIM TAG_DATE mand_line_item   
-                     { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { struct date_value dv = gedcom_parse_date($4);
+                      $<ctxt>$ = start_element(ELT_SUB_LIO_BAPL_DATE,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_DATE(dv));
+                      START(DATE, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LIO_BAPL_DATE, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 lio_bapl_temp_sect : OPEN DELIM TAG_TEMP mand_line_item   
-                     { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LIO_BAPL_TEMP,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(TEMP, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LIO_BAPL_TEMP, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 lio_bapl_plac_sect : OPEN DELIM TAG_PLAC mand_line_item   
-                     { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LIO_BAPL_PLAC,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(PLAC, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LIO_BAPL_PLAC, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 
 lio_slgc_sect : OPEN DELIM TAG_SLGC
-                { START(SLGC, NULL) }
+                { $<ctxt>$ = start_element(ELT_SUB_LIO_SLGC,
+                                          PARENT, $1, $3, NULL,
+                                          GEDCOM_MAKE_NULL());
+                 START(SLGC, $<ctxt>$) 
+                }
                 lio_slgc_subs
                { CHECK1(FAMC) }
-                CLOSE { }
+                CLOSE 
+                { end_element(ELT_SUB_LIO_SLGC, PARENT, $<ctxt>4, NULL);
+               }
               ;
 
 lio_slgc_subs : /* empty */
@@ -2044,7 +2618,17 @@ lio_slgc_sub  : lio_bapl_sub
               ;
 
 lio_slgc_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
-                     { START(FAMC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LIO_SLGC_FAMC,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(FAMC, $<ctxt>$) 
+                     } 
+                     no_std_subs 
+                     { CHECK0 } 
+                     CLOSE 
+                     { end_element(ELT_SUB_LIO_SLGC_FAMC, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 
 /* LDS SPOUSE SEALING */
@@ -2052,10 +2636,15 @@ lds_spouse_seal_sub : lss_slgs_sect
                     ;
 
 lss_slgs_sect : OPEN DELIM TAG_SLGS
-                { START(SLGS, NULL) }
+                { $<ctxt>$ = start_element(ELT_SUB_LSS_SLGS,
+                                          PARENT, $1, $3, NULL,
+                                          GEDCOM_MAKE_NULL());
+                 START(SLGS, $<ctxt>$) }
                 lss_slgs_subs
                { CHECK0 }
-                CLOSE { }
+                CLOSE 
+                { end_element(ELT_SUB_LIO_SLGC, PARENT, $<ctxt>4, NULL);
+               }
               ;
 
 lss_slgs_subs : /* empty */
@@ -2072,16 +2661,57 @@ lss_slgs_sub  : lss_slgs_stat_sect  { OCCUR2(STAT, 0, 1) }
               ;
 
 lss_slgs_stat_sect : OPEN DELIM TAG_STAT mand_line_item   
-                     { START(STAT, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LSS_SLGS_STAT,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(STAT, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LSS_SLGS_STAT, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 lss_slgs_date_sect : OPEN DELIM TAG_DATE mand_line_item   
-                     { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { struct date_value dv = gedcom_parse_date($4);
+                      $<ctxt>$ = start_element(ELT_SUB_LSS_SLGS_DATE,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_DATE(dv));
+                      START(DATE, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LSS_SLGS_DATE, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 lss_slgs_temp_sect : OPEN DELIM TAG_TEMP mand_line_item   
-                     { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LSS_SLGS_TEMP,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(TEMP, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LSS_SLGS_TEMP, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 lss_slgs_plac_sect : OPEN DELIM TAG_PLAC mand_line_item   
-                     { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                     { $<ctxt>$ = start_element(ELT_SUB_LSS_SLGS_PLAC,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(PLAC, $<ctxt>$)    
+                     }    
+                     no_std_subs    
+                     { CHECK0 }    
+                     CLOSE    
+                     { end_element(ELT_SUB_LSS_SLGS_PLAC, PARENT, $<ctxt>5,
+                                  NULL);
+                    }
                    ;
 
 /* MULTIMEDIA LINK */
@@ -2090,14 +2720,31 @@ multim_link_sub : multim_obje_link_sect
                 ;
 
 multim_obje_link_sect : OPEN DELIM TAG_OBJE DELIM POINTER    
-                        { START(OBJE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                        { $<ctxt>$ = start_element(ELT_SUB_MULTIM_OBJE,
+                                                  PARENT, $1, $3, $5,
+                                                  GEDCOM_MAKE_STRING($5));
+                         START(OBJE, $<ctxt>$)     
+                        }     
+                        no_std_subs     
+                        { CHECK0 }     
+                        CLOSE     
+                        { end_element(ELT_SUB_MULTIM_OBJE, PARENT, $<ctxt>6,
+                                     NULL);
+                       }
                       ;
 
 multim_obje_emb_sect : OPEN DELIM TAG_OBJE
-                       { START(OBJE, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_MULTIM_OBJE,
+                                                 PARENT, $1, $3, NULL,
+                                                 GEDCOM_MAKE_NULL());
+                        START(OBJE, $<ctxt>$) 
+                       }
                        multim_obje_emb_subs
                       { CHECK2(FORM,FILE) }
-                       CLOSE { }
+                       CLOSE 
+                       { end_element(ELT_SUB_MULTIM_OBJE, PARENT, $<ctxt>4,
+                                    NULL);
+                      }
                      ;
 
 multim_obje_emb_subs : /* empty */
@@ -2112,13 +2759,43 @@ multim_obje_emb_sub : multim_obje_form_sect  { OCCUR2(FORM, 1, 1) }
                     ;
 
 multim_obje_form_sect : OPEN DELIM TAG_FORM mand_line_item    
-                        { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                        { $<ctxt>$ = start_element(ELT_SUB_MULTIM_OBJE_FORM,
+                                                  PARENT, $1, $3, $4,
+                                                  GEDCOM_MAKE_STRING($4));
+                         START(FORM, $<ctxt>$)     
+                        }     
+                        no_std_subs     
+                        { CHECK0 }     
+                        CLOSE     
+                        { end_element(ELT_SUB_MULTIM_OBJE_FORM,
+                                     PARENT, $<ctxt>5, NULL);
+                       }
                       ;
 multim_obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item    
-                        { START(TITL, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                        { $<ctxt>$ = start_element(ELT_SUB_MULTIM_OBJE_TITL,
+                                                  PARENT, $1, $3, $4,
+                                                  GEDCOM_MAKE_STRING($4));
+                         START(TITL, $<ctxt>$)     
+                        }     
+                        no_std_subs     
+                        { CHECK0 }     
+                        CLOSE     
+                        { end_element(ELT_SUB_MULTIM_OBJE_TITL,
+                                     PARENT, $<ctxt>5, NULL);
+                       }
                       ;
 multim_obje_file_sect : OPEN DELIM TAG_FILE mand_line_item    
-                        { START(FILE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                        { $<ctxt>$ = start_element(ELT_SUB_MULTIM_OBJE_FILE,
+                                                  PARENT, $1, $3, $4,
+                                                  GEDCOM_MAKE_STRING($4));
+                         START(FILE, $<ctxt>$)     
+                        }     
+                        no_std_subs     
+                        { CHECK0 }     
+                        CLOSE     
+                        { end_element(ELT_SUB_MULTIM_OBJE_FILE,
+                                     PARENT, $<ctxt>5, NULL);
+                       }
                       ;
 
 /* NOTE STRUCTURE */
@@ -2127,10 +2804,16 @@ note_struc_sub : note_struc_link_sect  /* 0:M */
                ;
 
 note_struc_link_sect : OPEN DELIM TAG_NOTE DELIM POINTER
-                       { START(NOTE, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_NOTE,
+                                                 PARENT, $1, $3, $5,
+                                                 GEDCOM_MAKE_STRING($5));
+                        START(NOTE, $<ctxt>$) 
+                       }
                        note_struc_link_subs
                       { CHECK0 }
-                       CLOSE { }
+                       CLOSE 
+                       { end_element(ELT_SUB_NOTE, PARENT, $<ctxt>6, NULL);
+                      }
                      ;
 
 note_struc_link_subs : /* empty */
@@ -2142,10 +2825,17 @@ note_struc_link_sub : source_cit_sub
                     ;
 
 note_struc_emb_sect : OPEN DELIM TAG_NOTE opt_line_item
-                      { START(NOTE, NULL) }
+                      { $<ctxt>$
+                         = start_element(ELT_SUB_NOTE,
+                                         PARENT, $1, $3, $4,
+                                         GEDCOM_MAKE_NULL_OR_STRING($4));
+                       START(NOTE, $<ctxt>$) 
+                      }
                       note_struc_emb_subs
                      { CHECK0 }
-                      CLOSE { }
+                      CLOSE 
+                      { end_element(ELT_SUB_NOTE, PARENT, $<ctxt>5, NULL);
+                     }
                     ;
 
 note_struc_emb_subs : /* empty */
@@ -2162,10 +2852,16 @@ pers_name_struc_sub : pers_name_sect /* 0:M */
                     ;
 
 pers_name_sect : OPEN DELIM TAG_NAME mand_line_item 
-                 { START(NAME, NULL) }
+                 { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME,
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
+                  START(NAME, $<ctxt>$)  
+                 }
                  pers_name_subs
                 { CHECK0 }
-                 CLOSE { }
+                 CLOSE  
+                 { end_element(ELT_SUB_PERS_NAME, PARENT, $<ctxt>5, NULL);
+                }
                ;
 
 pers_name_subs : /* empty */
@@ -2184,22 +2880,82 @@ pers_name_sub  : pers_name_npfx_sect  { OCCUR2(NPFX, 0, 1) }
                ;
 
 pers_name_npfx_sect : OPEN DELIM TAG_NPFX mand_line_item    
-                      { START(NPFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME_NPFX,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(NPFX, $<ctxt>$)     
+                      }     
+                      no_std_subs     
+                      { CHECK0 }     
+                      CLOSE     
+                      { end_element(ELT_SUB_PERS_NAME_NPFX, PARENT, $<ctxt>5,
+                                   NULL);
+                     }
                     ;
 pers_name_givn_sect : OPEN DELIM TAG_GIVN mand_line_item    
-                      { START(GIVN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME_GIVN,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(GIVN, $<ctxt>$)     
+                      }     
+                      no_std_subs     
+                      { CHECK0 }     
+                      CLOSE     
+                      { end_element(ELT_SUB_PERS_NAME_GIVN, PARENT, $<ctxt>5,
+                                   NULL);
+                     }
                     ;
 pers_name_nick_sect : OPEN DELIM TAG_NICK mand_line_item    
-                      { START(NICK, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME_NICK,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(NICK, $<ctxt>$)     
+                      }     
+                      no_std_subs     
+                      { CHECK0 }     
+                      CLOSE     
+                      { end_element(ELT_SUB_PERS_NAME_NICK, PARENT, $<ctxt>5,
+                                   NULL);
+                     }
                     ;
 pers_name_spfx_sect : OPEN DELIM TAG_SPFX mand_line_item    
-                      { START(SPFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME_SPFX,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(SPFX, $<ctxt>$)     
+                      }     
+                      no_std_subs     
+                      { CHECK0 }     
+                      CLOSE     
+                      { end_element(ELT_SUB_PERS_NAME_SPFX, PARENT, $<ctxt>5,
+                                   NULL);
+                     }
                     ;
 pers_name_surn_sect : OPEN DELIM TAG_SURN mand_line_item    
-                      { START(SURN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME_SURN,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(SURN, $<ctxt>$)     
+                      }     
+                      no_std_subs     
+                      { CHECK0 }     
+                      CLOSE     
+                      { end_element(ELT_SUB_PERS_NAME_SURN, PARENT, $<ctxt>5,
+                                   NULL);
+                     }
                     ;
 pers_name_nsfx_sect : OPEN DELIM TAG_NSFX mand_line_item    
-                      { START(NSFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                      { $<ctxt>$ = start_element(ELT_SUB_PERS_NAME_NSFX,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(NSFX, $<ctxt>$)     
+                      }     
+                      no_std_subs     
+                      { CHECK0 }     
+                      CLOSE     
+                      { end_element(ELT_SUB_PERS_NAME_NSFX, PARENT, $<ctxt>5,
+                                   NULL);
+                     }
                     ;
 
 /* PLACE STRUCTURE */
@@ -2207,10 +2963,16 @@ place_struc_sub : place_struc_plac_sect /* 0:M */
                 ;
 
 place_struc_plac_sect : OPEN DELIM TAG_PLAC mand_line_item 
-                        { START(PLAC, NULL) }
+                        { $<ctxt>$ = start_element(ELT_SUB_PLAC,
+                                                  PARENT, $1, $3, $4,
+                                                  GEDCOM_MAKE_STRING($4));
+                         START(PLAC, $<ctxt>$)  
+                        }
                         place_struc_plac_subs
                        { CHECK0 }
-                        CLOSE { }
+                        CLOSE  
+                        { end_element(ELT_SUB_PLAC, PARENT, $<ctxt>5, NULL);
+                       }
                       ;
 
 place_struc_plac_subs : /* empty */
@@ -2224,7 +2986,17 @@ place_struc_plac_sub : place_plac_form_sect  { OCCUR2(FORM, 0, 1) }
                      ;
 
 place_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item    
-                       { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                       { $<ctxt>$ = start_element(ELT_SUB_PLAC_FORM,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(FORM, $<ctxt>$)     
+                       }     
+                       no_std_subs     
+                       { CHECK0 }     
+                       CLOSE     
+                       { end_element(ELT_SUB_PLAC_FORM, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 /* SOURCE_CITATION */
@@ -2233,10 +3005,16 @@ source_cit_sub : source_cit_link_sect /* 0:M */
                ;
 
 source_cit_link_sect : OPEN DELIM TAG_SOUR DELIM POINTER
-                       { START(SOUR, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_SOUR,
+                                                 PARENT, $1, $3, $5,
+                                                 GEDCOM_MAKE_STRING($5));
+                        START(SOUR, $<ctxt>$) 
+                       }
                        source_cit_link_subs
                       { CHECK0 }
-                       CLOSE { }
+                       CLOSE 
+                       { end_element(ELT_SUB_SOUR, PARENT, $<ctxt>6, NULL);
+                      }
                      ;
 
 source_cit_link_subs : /* empty */
@@ -2253,14 +3031,31 @@ source_cit_link_sub : source_cit_page_sect  { OCCUR2(PAGE, 0, 1) }
                     ;
 
 source_cit_page_sect : OPEN DELIM TAG_PAGE mand_line_item    
-                       { START(PAGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                       { $<ctxt>$ = start_element(ELT_SUB_SOUR_PAGE,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(PAGE, $<ctxt>$)     
+                       }     
+                       no_std_subs     
+                       { CHECK0 }     
+                       CLOSE     
+                       { end_element(ELT_SUB_SOUR_PAGE, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 source_cit_even_sect : OPEN DELIM TAG_EVEN mand_line_item 
-                       { START(EVEN, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_SOUR_EVEN,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(EVEN, $<ctxt>$)     
+                       }
                        source_cit_even_subs
                       { CHECK0 }
-                       CLOSE { }
+                       CLOSE     
+                       { end_element(ELT_SUB_SOUR_EVEN, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 source_cit_even_subs : /* empty */
@@ -2272,14 +3067,31 @@ source_cit_even_sub  : source_cit_even_role_sect  { OCCUR2(ROLE, 0, 1) }
                      ;
 
 source_cit_even_role_sect : OPEN DELIM TAG_ROLE mand_line_item    
-                          { START(ROLE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                          { $<ctxt>$ = start_element(ELT_SUB_SOUR_EVEN_ROLE,
+                                                    PARENT, $1, $3, $4,
+                                                    GEDCOM_MAKE_STRING($4));
+                           START(ROLE, $<ctxt>$)     
+                          }     
+                          no_std_subs     
+                          { CHECK0 }     
+                          CLOSE     
+                          { end_element(ELT_SUB_SOUR_EVEN_ROLE,
+                                       PARENT, $<ctxt>5, NULL);
+                         }
                           ;
 
 source_cit_data_sect : OPEN DELIM TAG_DATA
-                       { START(DATA, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_SOUR_DATA,
+                                                 PARENT, $1, $3, NULL,
+                                                 GEDCOM_MAKE_NULL());
+                        START(DATA, $<ctxt>$) 
+                       }
                        source_cit_data_subs
                       { CHECK0 }
-                       CLOSE { }
+                       CLOSE 
+                       { end_element(ELT_SUB_SOUR_DATA, PARENT, $<ctxt>4,
+                                    NULL);
+                      }
                      ;
 
 source_cit_data_subs : /* empty */
@@ -2292,14 +3104,32 @@ source_cit_data_sub : source_cit_data_date_sect  { OCCUR2(DATE, 0, 1) }
                     ;
 
 source_cit_data_date_sect : OPEN DELIM TAG_DATE mand_line_item    
-                            { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                            { struct date_value dv = gedcom_parse_date($4);
+                             $<ctxt>$ = start_element(ELT_SUB_SOUR_DATA_DATE,
+                                                      PARENT, $1, $3, $4,
+                                                      GEDCOM_MAKE_DATE(dv));
+                             START(DATE, $<ctxt>$)     
+                            }     
+                            no_std_subs     
+                            { CHECK0 }     
+                            CLOSE     
+                            { end_element(ELT_SUB_SOUR_DATA_DATE,
+                                         PARENT, $<ctxt>5, NULL);
+                           }
                           ;
 
 source_cit_text_sect : OPEN DELIM TAG_TEXT mand_line_item 
-                       { START(TEXT, NULL) }
+                       { $<ctxt>$ = start_element(ELT_SUB_SOUR_TEXT,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(TEXT, $<ctxt>$)  
+                       }
                        source_cit_text_subs
                       { CHECK0 }
-                       CLOSE { }
+                       CLOSE  
+                       { end_element(ELT_SUB_SOUR_TEXT, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 source_cit_text_subs : /* empty */
@@ -2311,14 +3141,30 @@ source_cit_text_sub : continuation_sub
                     ;
 
 source_cit_quay_sect : OPEN DELIM TAG_QUAY mand_line_item    
-                       { START(QUAY, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                       { $<ctxt>$ = start_element(ELT_SUB_SOUR_QUAY,
+                                                 PARENT, $1, $3, $4,
+                                                 GEDCOM_MAKE_STRING($4));
+                        START(QUAY, $<ctxt>$)     
+                       }     
+                       no_std_subs     
+                       { CHECK0 }     
+                       CLOSE     
+                       { end_element(ELT_SUB_SOUR_QUAY, PARENT, $<ctxt>5,
+                                    NULL);
+                      }
                      ;
 
 source_cit_emb_sect : OPEN DELIM TAG_SOUR mand_line_item
-                      { START(SOUR, NULL) }
+                      { $<ctxt>$ = start_element(ELT_SUB_SOUR,
+                                                PARENT, $1, $3, $4,
+                                                GEDCOM_MAKE_STRING($4));
+                       START(SOUR, $<ctxt>$) 
+                      }
                       source_cit_emb_subs
                      { CHECK0 }
-                      CLOSE { }
+                      CLOSE 
+                      { end_element(ELT_SUB_SOUR, PARENT, $<ctxt>5, NULL);
+                     }
                     ;
 
 source_cit_emb_subs : /* empty */
@@ -2336,10 +3182,16 @@ source_repos_cit_sub : source_repos_repo_sect  { OCCUR2(REPO, 0, 1) }
                      ;
 
 source_repos_repo_sect : OPEN DELIM TAG_REPO mand_pointer
-                         { START(REPO, NULL) }
+                         { $<ctxt>$ = start_element(ELT_SUB_REPO,
+                                                   PARENT, $1, $3, $4,
+                                                   GEDCOM_MAKE_STRING($4));
+                          START(REPO, $<ctxt>$) 
+                         }
                          source_repos_repo_subs
                         { CHECK0 }
-                         CLOSE { }
+                         CLOSE 
+                         { end_element(ELT_SUB_REPO, PARENT, $<ctxt>5, NULL);
+                        }
                        ;
 
 source_repos_repo_subs : /* empty */
@@ -2352,10 +3204,16 @@ source_repos_repo_sub  : note_struc_sub
                        ;
 
 caln_sect : OPEN DELIM TAG_CALN mand_line_item 
-            { START(CALN, NULL) }
+            { $<ctxt>$ = start_element(ELT_SUB_REPO_CALN,
+                                      PARENT, $1, $3, $4,
+                                      GEDCOM_MAKE_STRING($4));
+             START(CALN, $<ctxt>$) 
+           }
             caln_subs
            { CHECK0 }
-            CLOSE { }
+            CLOSE  
+           { end_element(ELT_SUB_REPO_CALN, PARENT, $<ctxt>5, NULL);
+           }
           ;
 
 caln_subs : /* empty */
@@ -2367,7 +3225,16 @@ caln_sub  : caln_medi_sect  { OCCUR2(MEDI, 0, 1) }
           ;
 
 caln_medi_sect : OPEN DELIM TAG_MEDI mand_line_item    
-                 { START(MEDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
+                 { $<ctxt>$ = start_element(ELT_SUB_REPO_CALN_MEDI,
+                                           PARENT, $1, $3, $4,
+                                           GEDCOM_MAKE_STRING($4));
+                  START(MEDI, $<ctxt>$)  
+                }   
+                no_std_subs   
+                { CHECK0 }   
+                CLOSE   
+                { end_element(ELT_SUB_REPO_CALN_MEDI, PARENT, $<ctxt>5, NULL);
+                }
                ;
  
 /* SPOUSE TO FAMILY LINK */
@@ -2375,10 +3242,16 @@ spou_fam_link_sub : spou_fam_fams_sect  /* 0:M */
                   ;
 
 spou_fam_fams_sect : OPEN DELIM TAG_FAMS mand_pointer
-                     { START(FAMS, NULL) }
+                     { $<ctxt>$ = start_element(ELT_SUB_FAMS,
+                                               PARENT, $1, $3, $4,
+                                               GEDCOM_MAKE_STRING($4));
+                      START(FAMS, $<ctxt>$) 
+                     }
                      spou_fam_fams_subs
                     { CHECK0 }
-                     CLOSE { }
+                     CLOSE 
+                     { end_element(ELT_SUB_FAMS, PARENT, $<ctxt>5, NULL);
+                    }
                    ;
 
 spou_fam_fams_subs : /* empty */
@@ -2389,10 +3262,6 @@ spou_fam_fams_sub  : note_struc_sub
                    | no_std_sub
                    ;
 
-/*********************************************************************/
-/**** Special values                                              ****/
-/*********************************************************************/
-
 /*********************************************************************/
 /**** General                                                     ****/
 /*********************************************************************/
@@ -2412,14 +3281,15 @@ no_std_rec  : user_rec /* 0:M */
            ;
 
 user_rec    : OPEN DELIM opt_xref USERTAG 
-              { if ($4[0] != '_') {
+              { if ($4.string[0] != '_') {
                  gedcom_error(_("Undefined tag (and not a valid user tag): %s"),
                               $4);
                  YYERROR;
                }
              }
               opt_value
-              { $<ctxt>$ = start_record(REC_USER, $1, $3, $4);
+              { $<ctxt>$ = start_record(REC_USER,
+                                       $1, GEDCOM_MAKE_NULL_OR_STRING($3), $4);
                START($4, $<ctxt>$)
              }
              user_sects
@@ -2428,14 +3298,15 @@ user_rec    : OPEN DELIM opt_xref USERTAG
               { end_record(REC_USER, $<ctxt>7); }
             ;
 user_sect   : OPEN DELIM opt_xref USERTAG 
-              { if ($4[0] != '_') {
+              { if ($4.string[0] != '_') {
                  gedcom_error(_("Undefined tag (and not a valid user tag): %s"),
                               $4);
                  YYERROR;
                }
              }
               opt_value
-              { $<ctxt>$ = start_element(ELT_USER, PARENT, $1, $4, $6, $6);
+              { $<ctxt>$ = start_element(ELT_USER, PARENT, $1, $4, $6,  
+                                        GEDCOM_MAKE_NULL_OR_STRING($6));
                START($4, $<ctxt>$);
              }
              user_sects
@@ -2486,9 +3357,11 @@ line_item   : anychar  { size_t i;
                             *line_item_buf_ptr++ = $1[i];
                         $$ = line_item_buf;
                        }
-            | ESCAPE   { CLEAR_BUFFER(line_item_buf);
+            | ESCAPE   { size_t i;
+                         CLEAR_BUFFER(line_item_buf);
                         line_item_buf_ptr = line_item_buf;
-                        /* For now, ignore escapes */
+                        for (i=0; i < strlen($1); i++)
+                          *line_item_buf_ptr++ = $1[i];
                         $$ = line_item_buf;
                       }
             | line_item anychar
@@ -2502,7 +3375,9 @@ line_item   : anychar  { size_t i;
                    $$ = line_item_buf;
                  }
             | line_item ESCAPE
-                  { /* For now, ignore escapes */
+                  { size_t i;
+                   for (i=0; i < strlen($2); i++)
+                     *line_item_buf_ptr++ = $2[i];
                    $$ = line_item_buf;
                  }
             ;