Pass encoding terminator to encoding state.
[gedcom-parse.git] / gedcom / gedcom.y
index 4a131b04a6718da38792cdd6af3dbdad1a4395bb..ef95178d08664ece62d34a5cc91a6ced0adb1415 100644 (file)
@@ -496,7 +496,7 @@ head_sub     : head_sour_sect  { OCCUR2(SOUR, 1, 1) }
 
 /* HEAD.SOUR */
 head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item 
-                 { set_compatibility($4);
+                 { set_compatibility_program($4);
                   $<ctxt>$ = start_element(ELT_HEAD_SOUR, PARENT,
                                            $1, $3, $4,
                                            GEDCOM_MAKE_STRING(val1, $4));
@@ -505,7 +505,8 @@ head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item
                  head_sour_subs
                  { CHECK0 }
                 CLOSE
-                 { end_element(ELT_HEAD_SOUR, PARENT, $<ctxt>5,
+                 { compute_compatibility();
+                  end_element(ELT_HEAD_SOUR, PARENT, $<ctxt>5,
                               GEDCOM_MAKE_NULL(val1)); }
                ;
 
@@ -521,7 +522,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,
+                      { set_compatibility_version($4);
+                       $<ctxt>$ = start_element(ELT_HEAD_SOUR_VERS, PARENT,
                                                 $1, $3, $4,
                                                 GEDCOM_MAKE_STRING(val1, $4));
                        START(VERS, $1, $<ctxt>$)
@@ -3678,6 +3680,11 @@ user_sect   : OPEN DELIM opt_xref USERTAG
                      && compat_check_551_tag($4.string, &usertag_buffer)) {
                    $4.string = get_buf_string(&usertag_buffer);
                  }
+                 else if (compat_mode(C_SUBM_COMM) &&
+                          compat_check_subm_comm($4.string, get_parenttag(0),
+                                                 &usertag_buffer)) {
+                   $4.string = get_buf_string(&usertag_buffer);
+                 }
                  else {
                    gedcom_error(_("Undefined tag (and not a valid user tag): %s"),
                                 $4);
@@ -3694,11 +3701,21 @@ user_sect   : OPEN DELIM opt_xref USERTAG
              CLOSE
               { end_element(ELT_USER, PARENT, $<ctxt>7, 
                            GEDCOM_MAKE_NULL(val1));
+               if (compat_mode(C_SUBM_COMM))
+                 compat_close_subm_comm();
              }
             ;
 
 user_sects   : /* empty */     { }
             | user_sects user_sect { }
+            | user_sects gen_sect
+              { if (compat_mode(C_SUBM_COMM)) {
+                }
+               else {
+                 gedcom_error(_("Standard tag not allowed in user section"));
+                 YYERROR;
+               }
+             }
             ;
 
 opt_xref    : /* empty */        { $$ = NULL; }
@@ -3787,9 +3804,23 @@ error_sect  : OPEN DELIM opt_xref anytag opt_value error_subs CLOSE { }
             ;
 
 gen_sect    : OPEN DELIM opt_xref anystdtag
-              { INVALID_TAG($4.string); }
-              opt_value opt_sects CLOSE
-              { }
+              { if (compat_mode(C_SUBM_COMM)
+                   && compat_check_subm_comm_cont($4.string)) {
+                 /* Will pass here */
+               }
+               else {
+                 INVALID_TAG($4.string);
+               }
+             }
+              opt_value
+              { if (compat_mode(C_SUBM_COMM)) {
+                 $<ctxt>$ = compat_subm_comm_cont_start(PARENT, $6);
+                }
+             }
+             opt_sects CLOSE
+              { if (compat_mode(C_SUBM_COMM))
+                 compat_subm_comm_cont_end(PARENT, $<ctxt>7);
+             }
             ;
 
 gen_rec : gen_rec_top