Release 0.2
[gedcom-parse.git] / gedcom.y
1 /* $Id$ */
2 /* $Name$ */
3
4 /* WARNING: THIS PARSER RELIES HEAVILY ON SOME FEATURES OF BISON.
5    DON'T TRY TO USE IT WITH YACC, IT WON'T WORK...
6 */
7
8 /* Design of the parser:
9    ---------------------
10    In general, a GEDCOM file contains records, each consisting of a line
11    (which we'll call a section), hierarchically containing other lines
12    (subsections of the section).
13
14    This means that in general we have:
15
16      A 'record' is a 'section' (sect) containing 'subsections' (subs)
17      Each 'subsection' (sub) is again a specific 'section' (sect)
18
19    In parser notation, this means:
20
21      record : sect
22
23      sect   : <some prefix> subs <some suffix>
24
25      subs   : <empty> | subs sub
26
27      sub    : sect_a | sect_b | ...
28
29    This pattern is repeated throughout the parser for the different types of
30    sections.
31    
32
33    Cardinality of the subsections:
34    -------------------------------
35    Note that in the above, the order of the subsections is of no importance.
36    Indeed, this is the case in the GEDCOM grammar.  However, this also makes
37    it difficult to check whether there are not too many subsections of a
38    specific type, or whether a mandatory subsection is indeed there.
39
40    Suppose there is a section A that can contain 0 or 1 B section and
41    2 C sections.
42
43    This can be expressed in parser notation as follows:
44
45      A    : CC | BCC | CBC | CCB
46
47    So, cardinality is indeed expressable.  However, as the number of subsection
48    types and the limits grow bigger (and even theoretically limitless), listing
49    all possible permutations becomes quickly unfeasible.
50
51    Much simpler is to say:
52
53      A    : subs
54      subs : <empty> | subs sub
55      sub  : B | C
56
57    and then check the cardinality in the semantic actions, which is the
58    solution chosen in the parser below, using the following macros:
59
60     - OPEN(<parent>)
61          Make a new context for the <parent> tag to count child tags in
62          
63     - OCCUR2(<child>, <min>, <max>)
64          Express that the <child> tag should occur at least <min> times and
65          at most <max> tags within its parent
66
67          What this actually does is the following.  It increments the counter
68          for that tag and then checks whether the maximum is exceeded.  If so,
69          then a parser error is produced.  The minimum is not actually checked
70          by this macro, but it makes the statements more declarative.
71
72     - OCCUR1(<child>, <min>)
73          Express that the <child> tag should occur at least <min> times within
74          its parent (no upper limit)
75
76          Actually, this only increments the counter for the tag, but it looks
77          very like the previous macro.
78
79          If the minimum is 0, it is not necessary to express this constraint.
80
81     - CHECKn(<child1>, ..., <childn>)
82          This closes the context for the parent tag and checks whether the
83          given <child> tags did effectively occur within the parent (i.e.
84          these are the tags that were mandatory).
85
86          Since the <min> values above are always 0 or 1 in GEDCOM, this is
87          sufficient.  All sub-tags that declare a minimum of 1 in the OCCUR
88          macros should be listed in this macro here.
89
90          The macros CHECK0 to CHECK4 are defined like this (the first one
91          has no arguments and is only used to close the parent context; note
92          that this is necessary for correct functioning).
93
94    Example of usage:
95
96      Only sections that have subsections need to use these macros.  This can
97      be done like this (the OPEN and CHECK macros are used as mid-rule
98      actions around the subsections):
99
100        head_sect : OPEN DELIM TAG_HEAD
101                    { OPEN(HEAD) }
102                    head_subs
103                    { CHECK1(SOUR) }
104                    CLOSE { <semantic actions> }
105                   
106        head_subs : <empty>
107                  | head_subs head_sub
108                  ;
109
110        head_sub  : head_sour_sect  { OCCUR2(SOUR, 1, 1) }
111                  | head_dest_sect  { OCCUR2(DEST, 0, 1) }
112                  | head_date_sect  { OCCUR2(DATE, 0, 1) }
113                  ;
114 */
115
116 /* General notes:
117
118    - The syntax analysis doesn't handle the contents of the line values
119      or their encoding; this is done in the semantic analysis.
120
121  */
122
123 %{
124 #include "gedcom.h"
125
126 int  count_level=0;
127 int  fail=0; 
128 MECHANISM curr_mechanism=IMMED_FAIL; 
129
130 /* These are defined at the bottom of the file */ 
131 void push_countarray();
132 void set_parenttag(char* tag);
133 char* get_parenttag(); 
134 void pop_countarray();
135 int  count_tag(int tag);
136 int  check_occurrence(int tag);
137  
138 #define HANDLE_ERROR \
139      { \
140        if (curr_mechanism == IMMED_FAIL) { \
141          YYABORT; \
142        } \
143        else if (curr_mechanism == DEFER_FAIL) { \
144          yyerrok; fail = 1; \
145        } \
146        else if (curr_mechanism == IGNORE_ERRORS) { \
147          yyerrok; \
148        } \
149      }
150 #define OPEN(PARENTTAG) \
151      { ++count_level; \
152        set_parenttag(#PARENTTAG); \
153        push_countarray(); \
154      }
155 #define CHK(TAG) \
156      { if (!check_occurrence(TAG_##TAG)) { \
157          char* parenttag = get_parenttag(); \
158          gedcom_error("The tag '%s' is mandatory within '%s'", \
159                       #TAG, parenttag); \
160          HANDLE_ERROR; \
161        } \
162      }
163 #define POP \
164      { pop_countarray(); \
165        --count_level; \
166      }
167 #define CHECK0 POP; 
168 #define CHECK1(TAG1) { CHK(TAG1); POP; }
169 #define CHECK2(TAG1,TAG2) \
170      { CHK(TAG1); CHK(TAG2); POP; }
171 #define CHECK3(TAG1,TAG2,TAG3) \
172      { CHK(TAG1); CHK(TAG2); CHK(TAG3); POP; }
173 #define CHECK4(TAG1,TAG2,TAG3,TAG4) \
174      { CHK(TAG1); CHK(TAG2); CHK(TAG3); CHK(TAG4); POP; } 
175 #define OCCUR1(CHILDTAG, MIN) { count_tag(TAG_##CHILDTAG); } 
176 #define OCCUR2(CHILDTAG, MIN, MAX) \
177      { int num = count_tag(TAG_##CHILDTAG); \
178        if (num > MAX) { \
179          char* parenttag = get_parenttag(); \
180          gedcom_error("The tag '%s' can maximally occur %d " \
181                       "time(s) within '%s'", \
182                       #CHILDTAG, MAX, parenttag); \
183          YYERROR; \
184        } \
185      }
186 #define INVALID_TAG(CHILDTAG) \
187      { char* parenttag = get_parenttag(); \
188        gedcom_error("The tag '%s' is not a valid tag within '%s'", \
189                     CHILDTAG, parenttag); \
190        YYERROR; \
191      }
192 #define INVALID_TOP_TAG(CHILDTAG) \
193      { gedcom_error("The tag '%s' is not a valid top-level tag", \
194                     CHILDTAG); \
195        YYERROR; \
196      }
197
198 %}
199
200 %union {
201   char *string;
202 }
203
204 %token_table
205 %expect 291
206
207 %token <string> BADTOKEN
208 %token <string> OPEN
209 %token <string> CLOSE
210 %token <string> ESCAPE
211 %token <string> DELIM
212 %token <string> ANYCHAR
213 %token <string> POINTER
214 %token <string> USERTAG
215 %token <string> TAG_ABBR
216 %token <string> TAG_ADDR
217 %token <string> TAG_ADR1
218 %token <string> TAG_ADR2
219 %token <string> TAG_ADOP
220 %token <string> TAG_AFN
221 %token <string> TAG_AGE
222 %token <string> TAG_AGNC
223 %token <string> TAG_ALIA
224 %token <string> TAG_ANCE
225 %token <string> TAG_ANCI
226 %token <string> TAG_ANUL
227 %token <string> TAG_ASSO
228 %token <string> TAG_AUTH
229 %token <string> TAG_BAPL
230 %token <string> TAG_BAPM
231 %token <string> TAG_BARM
232 %token <string> TAG_BASM
233 %token <string> TAG_BIRT
234 %token <string> TAG_BLES
235 %token <string> TAG_BLOB
236 %token <string> TAG_BURI
237 %token <string> TAG_CALN
238 %token <string> TAG_CAST
239 %token <string> TAG_CAUS
240 %token <string> TAG_CENS
241 %token <string> TAG_CHAN
242 %token <string> TAG_CHAR
243 %token <string> TAG_CHIL
244 %token <string> TAG_CHR
245 %token <string> TAG_CHRA
246 %token <string> TAG_CITY
247 %token <string> TAG_CONC
248 %token <string> TAG_CONF
249 %token <string> TAG_CONL
250 %token <string> TAG_CONT
251 %token <string> TAG_COPR
252 %token <string> TAG_CORP
253 %token <string> TAG_CREM
254 %token <string> TAG_CTRY
255 %token <string> TAG_DATA
256 %token <string> TAG_DATE
257 %token <string> TAG_DEAT
258 %token <string> TAG_DESC
259 %token <string> TAG_DESI
260 %token <string> TAG_DEST
261 %token <string> TAG_DIV
262 %token <string> TAG_DIVF
263 %token <string> TAG_DSCR
264 %token <string> TAG_EDUC
265 %token <string> TAG_EMIG
266 %token <string> TAG_ENDL
267 %token <string> TAG_ENGA
268 %token <string> TAG_EVEN
269 %token <string> TAG_FAM
270 %token <string> TAG_FAMC
271 %token <string> TAG_FAMF
272 %token <string> TAG_FAMS
273 %token <string> TAG_FCOM
274 %token <string> TAG_FILE
275 %token <string> TAG_FORM
276 %token <string> TAG_GEDC
277 %token <string> TAG_GIVN
278 %token <string> TAG_GRAD
279 %token <string> TAG_HEAD
280 %token <string> TAG_HUSB
281 %token <string> TAG_IDNO
282 %token <string> TAG_IMMI
283 %token <string> TAG_INDI
284 %token <string> TAG_LANG
285 %token <string> TAG_LEGA
286 %token <string> TAG_MARB
287 %token <string> TAG_MARC
288 %token <string> TAG_MARL
289 %token <string> TAG_MARR
290 %token <string> TAG_MARS
291 %token <string> TAG_MEDI
292 %token <string> TAG_NAME
293 %token <string> TAG_NATI
294 %token <string> TAG_NATU
295 %token <string> TAG_NCHI
296 %token <string> TAG_NICK
297 %token <string> TAG_NMR
298 %token <string> TAG_NOTE
299 %token <string> TAG_NPFX
300 %token <string> TAG_NSFX
301 %token <string> TAG_OBJE
302 %token <string> TAG_OCCU
303 %token <string> TAG_ORDI
304 %token <string> TAG_ORDN
305 %token <string> TAG_PAGE
306 %token <string> TAG_PEDI
307 %token <string> TAG_PHON
308 %token <string> TAG_PLAC
309 %token <string> TAG_POST
310 %token <string> TAG_PROB
311 %token <string> TAG_PROP
312 %token <string> TAG_PUBL
313 %token <string> TAG_QUAY
314 %token <string> TAG_REFN
315 %token <string> TAG_RELA
316 %token <string> TAG_RELI
317 %token <string> TAG_REPO
318 %token <string> TAG_RESI
319 %token <string> TAG_RESN
320 %token <string> TAG_RETI
321 %token <string> TAG_RFN
322 %token <string> TAG_RIN
323 %token <string> TAG_ROLE
324 %token <string> TAG_SEX
325 %token <string> TAG_SLGC
326 %token <string> TAG_SLGS
327 %token <string> TAG_SOUR
328 %token <string> TAG_SPFX
329 %token <string> TAG_SSN
330 %token <string> TAG_STAE
331 %token <string> TAG_STAT
332 %token <string> TAG_SUBM
333 %token <string> TAG_SUBN
334 %token <string> TAG_SURN
335 %token <string> TAG_TEMP
336 %token <string> TAG_TEXT
337 %token <string> TAG_TIME
338 %token <string> TAG_TITL
339 %token <string> TAG_TRLR
340 %token <string> TAG_TYPE
341 %token <string> TAG_VERS
342 %token <string> TAG_WIFE
343 %token <string> TAG_WILL
344
345 %type <string> anystdtag
346
347 %%
348
349 file        : head_sect records trlr_sect
350                { if (fail == 1) YYABORT; }
351             ;
352
353 records     : /* empty */
354             | records record
355             ;
356
357 record      : fam_rec
358             | indiv_rec
359             | multim_rec
360             | note_rec
361             | repos_rec
362             | source_rec
363             | submis_rec
364             | submit_rec
365             | no_std_rec
366             ;
367
368 /*********************************************************************/
369 /**** Header                                                      ****/
370 /*********************************************************************/
371 head_sect    : OPEN DELIM TAG_HEAD
372                { OPEN(HEAD) }
373                head_subs
374                { CHECK4(SOUR, SUBM, GEDC, CHAR) }
375                CLOSE { }
376              ;
377
378 head_subs    : /* empty */
379              | head_subs head_sub
380              ;
381
382 head_sub     : head_sour_sect  { OCCUR2(SOUR, 1, 1) }
383              | head_dest_sect  { OCCUR2(DEST, 0, 1) }
384              | head_date_sect  { OCCUR2(DATE, 0, 1) }
385              | head_subm_sect  { OCCUR2(SUBM, 1, 1) }
386              | head_subn_sect  { OCCUR2(SUBN, 0, 1) }
387              | head_file_sect  { OCCUR2(FILE, 0, 1) }
388              | head_copr_sect  { OCCUR2(COPR, 0, 1) }
389              | head_gedc_sect  { OCCUR2(GEDC, 1, 1) }
390              | head_char_sect  { OCCUR2(CHAR, 1, 1) }
391              | head_lang_sect  { OCCUR2(LANG, 0, 1) }
392              | head_plac_sect  { OCCUR2(PLAC, 0, 1) }
393              | head_note_sect  { OCCUR2(NOTE, 0, 1) }
394              | no_std_sub
395              ;
396
397 /* HEAD.SOUR */
398 head_sour_sect : OPEN DELIM TAG_SOUR DELIM line_item 
399                  { OPEN(SOUR) }
400                  head_sour_subs
401                  { CHECK0 }
402                  CLOSE
403                        { }
404                ;
405
406 head_sour_subs : /* empty */
407                | head_sour_subs head_sour_sub
408                ;
409
410 head_sour_sub : head_sour_vers_sect  { OCCUR2(VERS, 0, 1) }
411               | head_sour_name_sect  { OCCUR2(NAME, 0, 1) }
412               | head_sour_corp_sect  { OCCUR2(CORP, 0, 1) } 
413               | head_sour_data_sect  { OCCUR2(DATA, 0, 1) }
414               | no_std_sub
415               ;
416
417 head_sour_vers_sect : OPEN DELIM TAG_VERS DELIM line_item
418                       { OPEN(VERS)} no_std_subs { CHECK0 } CLOSE
419                             { }
420                     ;
421 head_sour_name_sect : OPEN DELIM TAG_NAME DELIM line_item
422                       { OPEN(NAME) } no_std_subs { CHECK0 } CLOSE
423                             { }
424                     ;
425 head_sour_corp_sect : OPEN DELIM TAG_CORP DELIM line_item 
426                       { OPEN(CORP) }
427                       head_sour_corp_subs
428                       { CHECK0 }
429                       CLOSE
430                             { }
431                     ;
432
433 head_sour_corp_subs : /* empty */
434                     | head_sour_corp_subs head_sour_corp_sub
435                     ;
436
437 head_sour_corp_sub : addr_struc_sub  /* 0:1 */
438                    | no_std_sub
439                    ;
440
441 head_sour_data_sect : OPEN DELIM TAG_DATA DELIM line_item 
442                       { OPEN(DATA) }
443                       head_sour_data_subs
444                       { CHECK0 }
445                       CLOSE
446                             { }
447                     ;
448
449 head_sour_data_subs : /* empty */
450                     | head_sour_data_subs head_sour_data_sub
451                     ;
452
453 head_sour_data_sub : head_sour_data_date_sect  { OCCUR2(DATE, 0, 1) }
454                    | head_sour_data_copr_sect  { OCCUR2(COPR, 0, 1) }
455                    | no_std_sub
456                    ;
457
458 head_sour_data_date_sect : OPEN DELIM TAG_DATE DELIM line_item
459                            { OPEN(DATE) } no_std_subs { CHECK0 } CLOSE
460                                 { }
461                          ;
462 head_sour_data_copr_sect : OPEN DELIM TAG_COPR DELIM line_item
463                            { OPEN(COPR) } no_std_subs { CHECK0 } CLOSE
464                                 { }
465                          ;
466
467 /* HEAD.DEST */
468 head_dest_sect : OPEN DELIM TAG_DEST DELIM line_item
469                  { OPEN(DEST) } no_std_subs { CHECK0 } CLOSE
470                        { }
471                ;
472
473 /* HEAD.DATE */
474 head_date_sect : OPEN DELIM TAG_DATE DELIM line_item 
475                  { OPEN(DATE) }
476                  head_date_subs
477                  { CHECK0 }
478                  CLOSE
479                        { }
480                ;
481
482 head_date_subs : /* empty */
483                | head_date_subs head_date_sub
484                ;
485
486 head_date_sub  : head_date_time_sect  { OCCUR2(TIME, 0, 1) }
487                | no_std_sub
488                ;
489
490 head_date_time_sect : OPEN DELIM TAG_TIME DELIM line_item
491                       { OPEN(TIME) } no_std_subs { CHECK0 } CLOSE
492                           { }
493                     ;
494
495 /* HEAD.SUBM */
496 head_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER
497                  { OPEN(SUBM) } no_std_subs { CHECK0 } CLOSE
498                        { }
499                ;
500 /* HEAD.SUBN */
501 head_subn_sect : OPEN DELIM TAG_SUBN DELIM POINTER 
502                  { OPEN(SUBN) } no_std_subs { CHECK0 } CLOSE
503                        { }
504                ;
505 /* HEAD.FILE */
506 head_file_sect : OPEN DELIM TAG_FILE DELIM line_item 
507                  { OPEN(FILE) } no_std_subs { CHECK0 } CLOSE
508                        { }
509                ;
510 /* HEAD.COPR */
511 head_copr_sect : OPEN DELIM TAG_COPR DELIM line_item 
512                  { OPEN(COPR) } no_std_subs { CHECK0 } CLOSE
513                        { }
514                ;
515 /* HEAD.GEDC */
516 head_gedc_sect : OPEN DELIM TAG_GEDC
517                  { OPEN(GEDC) }
518                  head_gedc_subs
519                  { CHECK2(VERS, FORM) }
520                  CLOSE
521                        { }
522                ;
523
524 head_gedc_subs : /* empty */
525                | head_gedc_subs head_gedc_sub
526                ;
527
528 head_gedc_sub  : head_gedc_vers_sect  { OCCUR2(VERS, 1, 1) }
529                | head_gedc_form_sect  { OCCUR2(FORM, 1, 1) }
530                | no_std_sub
531                ;
532 head_gedc_vers_sect : OPEN DELIM TAG_VERS DELIM line_item  
533                       { OPEN(VERS) } no_std_subs { CHECK0 } CLOSE
534                           { }
535                     ;
536 head_gedc_form_sect : OPEN DELIM TAG_FORM DELIM line_item   
537                       { OPEN(FORM) } no_std_subs { CHECK0 } CLOSE
538                           { }
539                     ;
540
541 /* HEAD.CHAR */
542 head_char_sect : OPEN DELIM TAG_CHAR DELIM line_item 
543                  { OPEN(CHAR) }
544                  head_char_subs
545                  { CHECK0 }
546                  CLOSE
547                        { }
548                ;
549
550 head_char_subs : /* empty */
551                | head_char_subs head_char_sub
552                ;
553
554 head_char_sub  : head_char_vers_sect  { OCCUR2(VERS, 0, 1) }
555                | no_std_sub
556                ;
557 head_char_vers_sect : OPEN DELIM TAG_VERS DELIM line_item   
558                       { OPEN(VERS) } no_std_subs { CHECK0 } CLOSE
559                           { }
560                     ;
561
562 /* HEAD.LANG */
563 head_lang_sect : OPEN DELIM TAG_LANG DELIM line_item   
564                  { OPEN(LANG) } no_std_subs { CHECK0 } CLOSE
565                        { }
566                ;
567 /* HEAD.PLAC */
568 head_plac_sect : OPEN DELIM TAG_PLAC
569                  { OPEN(PLAC) }
570                  head_plac_subs
571                  { CHECK1(FORM) }
572                  CLOSE
573                        { }
574                ;
575
576 head_plac_subs : /* empty */
577                | head_plac_subs head_plac_sub
578                ;
579
580 head_plac_sub  : head_plac_form_sect  { OCCUR2(FORM, 1, 1) }
581                | no_std_sub
582                ;
583 head_plac_form_sect : OPEN DELIM TAG_FORM DELIM line_item   
584                       { OPEN(FORM) } no_std_subs { CHECK0 } CLOSE
585                           { }
586                     ;
587
588 /* HEAD.NOTE */
589 head_note_sect : OPEN DELIM TAG_NOTE DELIM line_item 
590                  { OPEN(NOTE) }
591                  head_note_subs
592                  { CHECK0 }
593                  CLOSE
594                        { }
595                ;
596
597 head_note_subs : /* empty */
598                | head_note_subs head_note_sub
599                ;
600
601 head_note_sub  : continuation_sub  /* 0:M */
602                | no_std_sub
603                ;
604
605 /*********************************************************************/
606 /**** Trailer                                                     ****/
607 /*********************************************************************/
608 trlr_sect   : OPEN DELIM TAG_TRLR CLOSE { }
609             ;
610
611 /*********************************************************************/
612 /**** Family record                                               ****/
613 /*********************************************************************/
614 fam_rec      : OPEN DELIM POINTER DELIM TAG_FAM
615                { OPEN(FAM) }
616                fam_subs
617                { CHECK0 }
618                CLOSE { }
619              ;
620
621 fam_subs     : /* empty */
622              | fam_subs fam_sub
623              ;
624
625 fam_sub      : fam_event_struc_sub  /* 0:M */
626              | fam_husb_sect  { OCCUR2(HUSB, 0, 1) }
627              | fam_wife_sect  { OCCUR2(WIFE, 0, 1) }
628              | fam_chil_sect  /* 0:M */
629              | fam_nchi_sect  { OCCUR2(NCHI, 0, 1) }
630              | fam_subm_sect  /* 0:M */
631              | lds_spouse_seal_sub  /* 0:M */
632              | source_cit_sub  /* 0:M */
633              | multim_link_sub  /* 0:M */
634              | note_struc_sub  /* 0:M */
635              | ident_struc_sub  /* 0:1 */
636              | change_date_sub  /* 0:1 */
637              | no_std_sub
638              ;
639
640 /* FAM.HUSB */
641 fam_husb_sect : OPEN DELIM TAG_HUSB DELIM POINTER    
642                 { OPEN(HUSB) } no_std_subs { CHECK0 } CLOSE
643                        { }
644               ;
645
646 /* FAM.WIFE */
647 fam_wife_sect : OPEN DELIM TAG_WIFE DELIM POINTER    
648                 { OPEN(WIFE) } no_std_subs { CHECK0 } CLOSE
649                        { }
650               ;
651
652 /* FAM.CHIL */
653 fam_chil_sect : OPEN DELIM TAG_CHIL DELIM POINTER    
654                 { OPEN(CHIL) } no_std_subs { CHECK0 } CLOSE
655                        { }
656               ;
657
658 /* FAM.NCHI */
659 fam_nchi_sect : OPEN DELIM TAG_NCHI DELIM line_item    
660                 { OPEN(NCHI) } no_std_subs { CHECK0 } CLOSE
661                        { }
662               ;
663
664 /* FAM.SUBM */
665 fam_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER    
666                 { OPEN(SUBM) } no_std_subs { CHECK0 } CLOSE
667                        { }
668               ;
669
670 /*********************************************************************/
671 /**** Individual record                                           ****/
672 /*********************************************************************/
673 indiv_rec   : OPEN DELIM POINTER DELIM TAG_INDI
674               { OPEN(INDI) }
675               indi_subs
676               { CHECK0 }
677               CLOSE { }
678             ;
679
680 indi_subs   : /* empty */
681             | indi_subs indi_sub
682             ;
683
684 indi_sub    : indi_resn_sect  { OCCUR2(RESN, 0, 1) }
685             | pers_name_struc_sub  /* 0:M */
686             | indi_sex_sect  { OCCUR2(SEX, 0, 1) }
687             | indiv_even_struc_sub  /* 0:M */
688             | indiv_attr_struc_sub  /* 0:M */
689             | lds_indiv_ord_sub  /* 0:M */
690             | chi_fam_link_sub  /* 0:M */
691             | spou_fam_link_sub  /* 0:M */
692             | indi_subm_sect  /* 0:M */
693             | assoc_struc_sub  /* 0:M */
694             | indi_alia_sect  /* 0:M */
695             | indi_anci_sect  /* 0:M */
696             | indi_desi_sect  /* 0:M */
697             | source_cit_sub  /* 0:M */
698             | multim_link_sub  /* 0:M */
699             | note_struc_sub  /* 0:M */
700             | indi_rfn_sect  { OCCUR2(RFN, 0, 1) }
701             | indi_afn_sect  /* 0:M */
702             | ident_struc_sub  /* 0:1 */
703             | change_date_sub  /* 0:1 */
704             | no_std_sub
705             ;
706
707 /* INDI.RESN */
708 indi_resn_sect : OPEN DELIM TAG_RESN DELIM line_item     
709                  { OPEN(RESN) } no_std_subs { CHECK0 } CLOSE { }
710                ;
711
712 /* INDI.SEX */
713 indi_sex_sect  : OPEN DELIM TAG_SEX DELIM line_item     
714                  { OPEN(SEX) } no_std_subs { CHECK0 } CLOSE { }
715                ;
716
717 /* INDI.SUBM */
718 indi_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER     
719                  { OPEN(SUBM) } no_std_subs { CHECK0 } CLOSE { }
720                ;
721
722 /* INDI.ALIA */
723 indi_alia_sect : OPEN DELIM TAG_ALIA DELIM POINTER     
724                  { OPEN(ALIA) } no_std_subs { CHECK0 } CLOSE { }
725                ;
726
727 /* INDI.ANCI */
728 indi_anci_sect : OPEN DELIM TAG_ANCI DELIM POINTER     
729                  { OPEN(ANCI) } no_std_subs { CHECK0 } CLOSE { }
730                ;
731
732 /* INDI.DESI */
733 indi_desi_sect : OPEN DELIM TAG_DESI DELIM POINTER     
734                  { OPEN(DESI) } no_std_subs { CHECK0 } CLOSE { }
735                ;
736
737 /* INDI.RFN */
738 indi_rfn_sect  : OPEN DELIM TAG_RFN DELIM line_item     
739                  { OPEN(RFN) } no_std_subs { CHECK0 } CLOSE { }
740                ;
741
742 /* INDI.AFN */
743 indi_afn_sect  : OPEN DELIM TAG_AFN DELIM line_item      
744                  { OPEN(AFN) } no_std_subs { CHECK0 } CLOSE { }
745                ;
746
747 /*********************************************************************/
748 /**** Multimedia record                                           ****/
749 /*********************************************************************/
750 multim_rec  : OPEN DELIM POINTER DELIM TAG_OBJE
751               { OPEN(OBJE) }
752               obje_subs
753               { CHECK2(FORM, BLOB) }
754               CLOSE { }
755             ;
756
757 obje_subs   : /* empty */
758             | obje_subs obje_sub
759             ;
760
761 obje_sub    : obje_form_sect  { OCCUR2(FORM, 1, 1) }
762             | obje_titl_sect  { OCCUR2(TITL, 0, 1) }
763             | note_struc_sub  /* 0:M */
764             | obje_blob_sect  { OCCUR2(BLOB, 1, 1) }
765             | obje_obje_sect  { OCCUR2(OBJE, 0, 1) }
766             | ident_struc_sub  /* 0:1 */
767             | change_date_sub  /* 0:1 */
768             | no_std_sub
769             ;
770
771 /* OBJE.FORM */
772 obje_form_sect : OPEN DELIM TAG_FORM DELIM line_item       
773                  { OPEN(FORM) } no_std_subs { CHECK0 } CLOSE { }
774                ;
775
776 /* OBJE.TITL */
777 obje_titl_sect : OPEN DELIM TAG_TITL DELIM line_item       
778                  { OPEN(TITL) } no_std_subs { CHECK0 } CLOSE { }
779                ;
780
781 /* OBJE.BLOB */
782 obje_blob_sect : OPEN DELIM TAG_BLOB
783                  { OPEN(BLOB) }
784                  obje_blob_subs
785                  { CHECK1(CONT) }
786                  CLOSE { }
787                ;
788
789 obje_blob_subs : /* empty */
790                | obje_blob_subs obje_blob_sub
791                ;
792
793 obje_blob_sub  : obje_blob_cont_sect  { OCCUR1(CONT, 1) }
794                | no_std_sub
795                ;
796
797 obje_blob_cont_sect : OPEN DELIM TAG_CONT DELIM line_item        
798                       { OPEN(CONT) } no_std_subs { CHECK0 } CLOSE { }
799                     ;
800
801 /* OBJE.OBJE */
802 obje_obje_sect : OPEN DELIM TAG_OBJE DELIM POINTER        
803                  { OPEN(OBJE) } no_std_subs { CHECK0 } CLOSE { }
804                ;
805
806 /*********************************************************************/
807 /**** Note record                                                 ****/
808 /*********************************************************************/
809 note_rec    : OPEN DELIM POINTER DELIM TAG_NOTE DELIM line_item
810               { OPEN(NOTE) }
811               note_subs
812               { CHECK0 }
813               CLOSE { }
814             ;
815
816 note_subs   : /* empty */
817             | note_subs note_sub
818             ;
819
820 note_sub    : continuation_sub  /* 0:M */
821             | source_cit_sub  /* 0:M */
822             | ident_struc_sub  /* 0:1 */
823             | change_date_sub  /* 0:1 */
824             | no_std_sub
825             ;
826
827 /*********************************************************************/
828 /**** Repository record                                           ****/
829 /*********************************************************************/
830 repos_rec   : OPEN DELIM POINTER DELIM TAG_REPO
831               { OPEN(REPO) }
832               repo_subs
833               { CHECK0 }
834               CLOSE { }
835             ;
836
837 repo_subs   : /* empty */
838             | repo_subs repo_sub
839             ;
840
841 repo_sub    : repo_name_sect  { OCCUR2(NAME, 0, 1) }
842             | addr_struc_sub  /* 0:1 */
843             | note_struc_sub  /* 0:M */
844             | ident_struc_sub  /* 0:1 */
845             | change_date_sub  /* 0:1 */
846             | no_std_sub
847             ;
848
849 /* REPO.NAME */
850 repo_name_sect : OPEN DELIM TAG_NAME DELIM line_item         
851                  { OPEN(NAME) } no_std_subs { CHECK0 } CLOSE {}
852                ;
853
854 /*********************************************************************/
855 /**** Source record                                               ****/
856 /*********************************************************************/
857 source_rec  : OPEN DELIM POINTER DELIM TAG_SOUR
858               { OPEN(SOUR) }
859               sour_subs
860               { CHECK0 }
861               CLOSE { }
862             ;
863
864 sour_subs   : /* empty */
865             | sour_subs sour_sub
866             ;
867
868 sour_sub    : sour_data_sect  { OCCUR2(DATA, 0, 1) }
869             | sour_auth_sect  { OCCUR2(AUTH, 0, 1) }
870             | sour_titl_sect  { OCCUR2(TITL, 0, 1) }
871             | sour_abbr_sect  { OCCUR2(ABBR, 0, 1) }
872             | sour_publ_sect  { OCCUR2(PUBL, 0, 1) }
873             | sour_text_sect  { OCCUR2(TEXT, 0, 1) }
874             | source_repos_cit_sub  /* 0:1 */
875             | multim_link_sub  /* 0:M */
876             | note_struc_sub  /* 0:M */
877             | ident_struc_sub  /* 0:1 */
878             | change_date_sub  /* 0:1 */
879             | no_std_sub
880             ;
881
882 /* SOUR.DATA */
883 sour_data_sect : OPEN DELIM TAG_DATA
884                  { OPEN(DATA) }
885                  sour_data_subs
886                  { CHECK0 }
887                  CLOSE { }
888                ;
889
890 sour_data_subs : /* empty */
891                | sour_data_subs sour_data_sub
892                ;
893
894 sour_data_sub  : sour_data_even_sect  /* 0:M */
895                | sour_data_agnc_sect  { OCCUR2(AGNC, 0, 1) }
896                | note_struc_sub  /* 0:M */
897                | no_std_sub
898                ;
899
900 sour_data_even_sect : OPEN DELIM TAG_EVEN DELIM line_item 
901                       { OPEN(EVEN) }
902                       sour_data_even_subs
903                       { CHECK0 }
904                       CLOSE { }
905                     ;
906
907 sour_data_even_subs : /* empty */
908                     | sour_data_even_subs sour_data_even_sub
909                     ;
910
911 sour_data_even_sub  : sour_data_even_date_sect { OCCUR2(DATE, 0, 1) }
912                     | sour_data_even_plac_sect { OCCUR2(PLAC, 0, 1) }
913                     | no_std_sub
914                     ;
915
916 sour_data_even_date_sect : OPEN DELIM TAG_DATE DELIM line_item          
917                            { OPEN(DATE) } no_std_subs { CHECK0 } CLOSE { }
918                          ;
919
920 sour_data_even_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item          
921                            { OPEN(PLAC) } no_std_subs { CHECK0 } CLOSE { }
922                          ;
923
924 sour_data_agnc_sect : OPEN DELIM TAG_AGNC DELIM line_item          
925                       { OPEN(AGNC) } no_std_subs { CHECK0 } CLOSE { }
926                     ;
927
928 /* SOUR.AUTH */
929 sour_auth_sect : OPEN DELIM TAG_AUTH DELIM line_item
930                  { OPEN(AUTH) }
931                  sour_auth_subs
932                  { CHECK0 }
933                  CLOSE { }
934                ;
935
936 sour_auth_subs : /* empty */
937                | sour_auth_subs sour_auth_sub
938                ;
939
940 sour_auth_sub  : continuation_sub  /* 0:M */
941                | no_std_sub
942                ;
943
944 /* SOUR.TITL */
945 sour_titl_sect : OPEN DELIM TAG_TITL DELIM line_item  
946                  { OPEN(TITL) }
947                  sour_titl_subs 
948                  { CHECK0 }
949                  CLOSE { }
950                ;
951
952 sour_titl_subs : /* empty */
953                | sour_titl_subs sour_titl_sub
954                ;
955
956 sour_titl_sub  : continuation_sub  /* 0:M */
957                | no_std_sub
958                ;
959
960 /* SOUR.ABBR */
961 sour_abbr_sect : OPEN DELIM TAG_ABBR DELIM line_item           
962                  { OPEN(ABBR) } no_std_subs { CHECK0 } CLOSE { }
963                ;
964
965 /* SOUR.PUBL */
966 sour_publ_sect : OPEN DELIM TAG_PUBL DELIM line_item  
967                  { OPEN(PUBL) }
968                  sour_publ_subs  
969                  { CHECK0 }
970                  CLOSE { }
971                ;
972
973 sour_publ_subs : /* empty */
974                | sour_publ_subs sour_publ_sub
975                ;
976
977 sour_publ_sub  : continuation_sub  /* 0:M */
978                | no_std_sub
979                ;
980
981 /* SOUR.TEXT */
982 sour_text_sect : OPEN DELIM TAG_TEXT DELIM line_item   
983                  { OPEN(TEXT) }
984                  sour_text_subs  
985                  { CHECK0 }
986                  CLOSE { }
987                ;
988
989 sour_text_subs : /* empty */
990                | sour_text_subs sour_text_sub
991                ;
992
993 sour_text_sub  : continuation_sub  /* 0:M */
994                | no_std_sub
995                ;
996
997 /*********************************************************************/
998 /**** Submission record                                           ****/
999 /*********************************************************************/
1000 submis_rec  : OPEN DELIM POINTER DELIM TAG_SUBN    
1001               { OPEN(SUBN) }
1002               subn_subs
1003               { CHECK0 }
1004               CLOSE { }
1005             ;
1006
1007 subn_subs   : /* empty */
1008             | subn_subs subn_sub
1009             ;
1010
1011 subn_sub    : subn_subm_sect  { OCCUR2(SUBM, 0, 1) }
1012             | subn_famf_sect  { OCCUR2(FAMF, 0, 1) }
1013             | subn_temp_sect  { OCCUR2(TEMP, 0, 1) }
1014             | subn_ance_sect  { OCCUR2(ANCE, 0, 1) }
1015             | subn_desc_sect  { OCCUR2(DESC, 0, 1) }
1016             | subn_ordi_sect  { OCCUR2(ORDI, 0, 1) }
1017             | subn_rin_sect  { OCCUR2(RIN, 0, 1) }
1018             | no_std_sub
1019             ;
1020
1021 /* SUBN.SUBM */
1022 subn_subm_sect : OPEN DELIM TAG_SUBM DELIM POINTER            
1023                  { OPEN(SUBM) } no_std_subs { CHECK0 } CLOSE { }
1024                ;
1025
1026 /* SUBN.FAMF */
1027 subn_famf_sect : OPEN DELIM TAG_FAMF DELIM line_item            
1028                  { OPEN(FAMF) } no_std_subs { CHECK0 } CLOSE { }
1029                ;
1030
1031 /* SUBN.TEMP */
1032 subn_temp_sect : OPEN DELIM TAG_TEMP DELIM line_item            
1033                  { OPEN(TEMP) } no_std_subs { CHECK0 } CLOSE { }
1034                ;
1035
1036 /* SUBN.ANCE */
1037 subn_ance_sect : OPEN DELIM TAG_ANCE DELIM line_item            
1038                  { OPEN(ANCE) } no_std_subs { CHECK0 } CLOSE { }
1039                ;
1040
1041 /* SUBN.DESC */
1042 subn_desc_sect : OPEN DELIM TAG_DESC DELIM line_item            
1043                  { OPEN(DESC) } no_std_subs { CHECK0 } CLOSE { }
1044                ;
1045
1046 /* SUBN.ORDI */
1047 subn_ordi_sect : OPEN DELIM TAG_ORDI DELIM line_item            
1048                  { OPEN(ORDI) } no_std_subs { CHECK0 } CLOSE { }
1049                ;
1050
1051 /* SUBN.RIN */
1052 subn_rin_sect  : OPEN DELIM TAG_RIN DELIM line_item            
1053                  { OPEN(RIN) } no_std_subs { CHECK0 } CLOSE { }
1054                ;
1055
1056 /*********************************************************************/
1057 /**** Submitter record                                            ****/
1058 /*********************************************************************/
1059 submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM    
1060              { OPEN(SUBM) }
1061              subm_subs
1062              { CHECK1(NAME) }
1063              CLOSE { }
1064            ;
1065
1066 subm_subs  : /* empty */
1067            | subm_subs subm_sub
1068            ;
1069
1070 subm_sub   : subm_name_sect  { OCCUR2(NAME, 0, 1) }
1071            | addr_struc_sub  /* 0:1 */
1072            | multim_link_sub  /* 0:M */
1073            | subm_lang_sect  { OCCUR2(LANG, 0, 3) }
1074            | subm_rfn_sect  { OCCUR2(RFN, 0, 1) }
1075            | subm_rin_sect  { OCCUR2(RIN, 0, 1) }
1076            | change_date_sub  /* 0:1 */
1077            | no_std_sub
1078            ;
1079
1080 /* SUBM.NAME */
1081 subm_name_sect : OPEN DELIM TAG_NAME DELIM line_item             
1082                  { OPEN(NAME) } no_std_subs { CHECK0 } CLOSE { }
1083                ;
1084
1085 /* SUBM.LANG */
1086 subm_lang_sect : OPEN DELIM TAG_LANG DELIM line_item             
1087                  { OPEN(LANG) } no_std_subs { CHECK0 } CLOSE { }
1088                ;
1089
1090 /* SUBM.RFN */
1091 subm_rfn_sect  : OPEN DELIM TAG_RFN DELIM line_item             
1092                  { OPEN(RFN) } no_std_subs { CHECK0 } CLOSE { }
1093                ;
1094
1095 /* SUBM.RIN */
1096 subm_rin_sect  : OPEN DELIM TAG_RIN DELIM line_item             
1097                  { OPEN(RIN) } no_std_subs { CHECK0 } CLOSE { }
1098                ;
1099
1100 /*********************************************************************/
1101 /**** Substructures                                               ****/
1102 /*********************************************************************/
1103
1104 /* ADDRESS STRUCTURE */
1105 addr_struc_sub : addr_sect { OCCUR2(ADDR, 0, 1) }
1106                | phon_sect { OCCUR2(PHON, 0, 3) }
1107                ;
1108
1109 addr_sect   : OPEN DELIM TAG_ADDR DELIM line_item 
1110               { OPEN(ADDR) }
1111               addr_subs
1112               { CHECK0 }
1113               CLOSE { }
1114             ;
1115
1116 addr_subs   : /* empty */
1117             | addr_subs addr_sub
1118             ;
1119
1120 addr_sub    : addr_cont_sect  /* 0:M */
1121             | addr_adr1_sect  { OCCUR2(ADR1, 0, 1) }
1122             | addr_adr2_sect  { OCCUR2(ADR2, 0, 1) }
1123             | addr_city_sect  { OCCUR2(CITY, 0, 1) }
1124             | addr_stae_sect  { OCCUR2(STAE, 0, 1) }
1125             | addr_post_sect  { OCCUR2(POST, 0, 1) }
1126             | addr_ctry_sect  { OCCUR2(CTRY, 0, 1) }
1127             | no_std_sub
1128             ;
1129
1130 addr_cont_sect : OPEN DELIM TAG_CONT DELIM line_item              
1131                  { OPEN(CONT) } no_std_subs { CHECK0 } CLOSE { }
1132                ;
1133 addr_adr1_sect : OPEN DELIM TAG_ADR1 DELIM line_item              
1134                  { OPEN(ADR1) } no_std_subs { CHECK0 } CLOSE { }
1135                ;
1136 addr_adr2_sect : OPEN DELIM TAG_ADR2 DELIM line_item              
1137                  { OPEN(ADR2) } no_std_subs { CHECK0 } CLOSE { }
1138                ;
1139 addr_city_sect : OPEN DELIM TAG_CITY DELIM line_item              
1140                  { OPEN(CITY) } no_std_subs { CHECK0 } CLOSE { }
1141                ;
1142 addr_stae_sect : OPEN DELIM TAG_STAE DELIM line_item              
1143                  { OPEN(STAE) } no_std_subs { CHECK0 } CLOSE { }
1144                ;
1145 addr_post_sect : OPEN DELIM TAG_POST DELIM line_item              
1146                  { OPEN(POST) } no_std_subs { CHECK0 } CLOSE { }
1147                ;
1148 addr_ctry_sect : OPEN DELIM TAG_CTRY DELIM line_item              
1149                  { OPEN(CTRY) } no_std_subs { CHECK0 } CLOSE { }
1150                ;
1151
1152 phon_sect   : OPEN DELIM TAG_PHON DELIM line_item              
1153               { OPEN(PHON) } no_std_subs { CHECK0 } CLOSE { }
1154             ;
1155
1156 /* ASSOCIATION STRUCTURE */
1157 assoc_struc_sub : asso_sect /* 0:M */
1158                 ;
1159
1160 asso_sect : OPEN DELIM TAG_ASSO DELIM POINTER 
1161             { OPEN(ASSO) }
1162             asso_subs
1163             { CHECK2(TYPE,RELA) }
1164             CLOSE { }
1165           ;
1166
1167 asso_subs : /* empty */
1168           | asso_type_sect  { OCCUR2(TYPE, 1, 1) }
1169           | asso_rela_sect  { OCCUR2(RELA, 1, 1) }
1170           | note_struc_sub
1171           | source_cit_sub
1172           | no_std_sub
1173           ;
1174
1175 asso_type_sect : OPEN DELIM TAG_TYPE DELIM line_item               
1176                  { OPEN(TYPE) } no_std_subs { CHECK0 } CLOSE { }
1177                ;
1178
1179 asso_rela_sect : OPEN DELIM TAG_RELA DELIM line_item               
1180                  { OPEN(RELA) } no_std_subs { CHECK0 } CLOSE { }
1181                ;
1182
1183 /* CHANGE DATE */
1184 change_date_sub : change_date_chan_sect  { OCCUR2(CHAN, 0, 1) }
1185                 ;
1186
1187 change_date_chan_sect : OPEN DELIM TAG_CHAN
1188                         { OPEN(CHAN) }
1189                         change_date_chan_subs
1190                         { CHECK1(DATE) }
1191                         CLOSE { }
1192                       ;
1193
1194 change_date_chan_subs : /* empty */
1195                       | change_date_chan_subs change_date_chan_sub
1196                       ;
1197
1198 change_date_chan_sub  : change_date_date_sect  { OCCUR2(DATE, 1, 1) }
1199                       | note_struc_sub
1200                       | no_std_sub
1201                       ;
1202
1203 change_date_date_sect : OPEN DELIM TAG_DATE DELIM line_item 
1204                         { OPEN(DATE) }
1205                         change_date_date_subs
1206                         { CHECK0 }
1207                         CLOSE { }
1208                       ;
1209
1210 change_date_date_subs : /* empty */
1211                       | change_date_date_subs change_date_date_sub
1212                       ;
1213
1214 change_date_date_sub : change_date_date_time_sect  { OCCUR2(TIME, 0, 1) }
1215                      | no_std_sub
1216                      ;
1217
1218 change_date_date_time_sect : OPEN DELIM TAG_TIME DELIM line_item
1219                              { OPEN(TIME) } no_std_subs { CHECK0 } CLOSE { }
1220                            ;
1221
1222 /* CHILD TO FAMILY LINK */
1223 chi_fam_link_sub : famc_sect  /* 0:M */
1224                  ;
1225
1226 famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER 
1227             { OPEN(FAMC) }
1228             famc_subs
1229             { CHECK0 }
1230             CLOSE { }
1231           ;
1232
1233 famc_subs : /* empty */
1234           | famc_subs famc_sub
1235           ;
1236
1237 famc_sub  : famc_pedi_sect  /* 0:M */
1238           | note_struc_sub
1239           | no_std_sub
1240           ;
1241
1242 famc_pedi_sect : OPEN DELIM TAG_PEDI DELIM line_item 
1243                  { OPEN(PEDI) } no_std_subs { CHECK0 } CLOSE { }
1244                ;
1245
1246 /* CONTINUATION SUBSECTIONS */
1247 continuation_sub : cont_sect  /* 0:M */
1248                  | conc_sect  /* 0:M */
1249                  ;
1250
1251 cont_sect : OPEN DELIM TAG_CONT DELIM line_item 
1252             { OPEN(CONT) } no_std_subs { CHECK0 } CLOSE { }
1253           ;
1254
1255 conc_sect : OPEN DELIM TAG_CONC DELIM line_item 
1256             { OPEN(CONC) } no_std_subs { CHECK0 } CLOSE { }
1257           ; 
1258
1259 /* EVENT DETAIL */
1260 event_detail_sub : event_detail_type_sect  { OCCUR2(TYPE, 0, 1) }
1261                  | event_detail_date_sect  { OCCUR2(DATE, 0, 1) }
1262                  | place_struc_sub
1263                  | addr_struc_sub
1264                  | event_detail_age_sect  { OCCUR2(AGE, 0, 1) }
1265                  | event_detail_agnc_sect  { OCCUR2(AGNC, 0, 1) }
1266                  | event_detail_caus_sect  { OCCUR2(CAUS, 0, 1) }
1267                  | source_cit_sub
1268                  | multim_link_sub
1269                  | note_struc_sub
1270                  ;
1271
1272 event_detail_type_sect : OPEN DELIM TAG_TYPE DELIM line_item 
1273                          { OPEN(TYPE) } no_std_subs { CHECK0 } CLOSE { }
1274                        ;
1275 event_detail_date_sect : OPEN DELIM TAG_DATE DELIM line_item 
1276                          { OPEN(DATE) } no_std_subs { CHECK0 } CLOSE { }
1277                        ;
1278 event_detail_age_sect  : OPEN DELIM TAG_AGE DELIM line_item 
1279                          { OPEN(AGE) } no_std_subs { CHECK0 } CLOSE { }
1280                        ;
1281 event_detail_agnc_sect : OPEN DELIM TAG_AGNC DELIM line_item 
1282                          { OPEN(AGNC) } no_std_subs { CHECK0 } CLOSE { }
1283                        ;
1284 event_detail_caus_sect : OPEN DELIM TAG_CAUS DELIM line_item 
1285                          { OPEN(CAUS) } no_std_subs { CHECK0 } CLOSE { }
1286                        ;
1287
1288 /* FAMILY EVENT STRUCTURE */
1289 fam_event_struc_sub : fam_event_sect
1290                     | fam_gen_even_sect  /* 0:M */
1291                     ;
1292
1293 fam_event_sect : OPEN DELIM fam_event_tag opt_value fam_event_subs
1294                  { CHECK0 }
1295                  CLOSE { }
1296                ;
1297
1298 fam_event_tag : TAG_ANUL { OPEN(ANUL) }
1299               | TAG_CENS { OPEN(CENS) }
1300               | TAG_DIV { OPEN(DIV) }
1301               | TAG_DIVF { OPEN(DIVF) }
1302               | TAG_ENGA { OPEN(ENGA) }
1303               | TAG_MARR { OPEN(MARR) }
1304               | TAG_MARB { OPEN(MARB) }
1305               | TAG_MARC { OPEN(MARC) }
1306               | TAG_MARL { OPEN(MARL) }
1307               | TAG_MARS { OPEN(MARS) }
1308               ;
1309
1310 fam_event_subs : /* empty */
1311                | fam_event_subs fam_event_sub
1312                ;
1313
1314 fam_event_sub : event_detail_sub
1315               | fam_even_husb_sect  { OCCUR2(HUSB, 0, 1) }
1316               | fam_even_wife_sect  { OCCUR2(WIFE, 0, 1) }
1317               | no_std_sub
1318               ;
1319
1320 fam_even_husb_sect : OPEN DELIM TAG_HUSB
1321                      { OPEN(HUSB) }
1322                      fam_even_husb_subs
1323                      { CHECK1(AGE) }
1324                      CLOSE { }
1325                    ;
1326
1327 fam_even_husb_subs : /* empty */
1328                    | fam_even_husb_subs fam_even_husb_sub
1329                    ;
1330
1331 fam_even_husb_sub : fam_even_husb_age_sect  { OCCUR2(AGE, 1, 1) }
1332                   | no_std_sub
1333                   ;
1334
1335 fam_even_husb_age_sect : OPEN DELIM TAG_AGE DELIM line_item  
1336                          { OPEN(AGE) } no_std_subs { CHECK0 } CLOSE { }
1337                        ;
1338
1339 fam_even_wife_sect : OPEN DELIM TAG_WIFE
1340                      { OPEN(HUSB) }
1341                      fam_even_husb_subs
1342                      { CHECK1(AGE) }
1343                      CLOSE { }
1344                    ;
1345
1346 fam_gen_even_sect : OPEN DELIM TAG_EVEN
1347                     { OPEN(EVEN) }
1348                     fam_gen_even_subs
1349                     { CHECK0 }
1350                     CLOSE { }
1351                   ;
1352
1353 fam_gen_even_subs : /* empty */
1354                   | fam_gen_even_subs fam_gen_even_sub
1355                   ;
1356
1357 fam_gen_even_sub : event_detail_sub
1358                  | fam_even_husb_sect  { OCCUR2(HUSB, 0, 1) }
1359                  | fam_even_wife_sect  { OCCUR2(WIFE, 0, 1) }
1360                  | no_std_sub
1361                  ;
1362
1363 /* IDENTIFICATION STRUCTURE */
1364 ident_struc_sub : ident_refn_sect  /* 0:M */
1365                 | ident_rin_sect  { OCCUR2(RIN, 0, 1) }
1366                 ;
1367
1368 ident_refn_sect : OPEN DELIM TAG_REFN DELIM line_item 
1369                   { OPEN(REFN) }
1370                   ident_refn_subs
1371                   { CHECK0 }
1372                   CLOSE { }
1373                 ;
1374
1375 ident_refn_subs : /* empty */
1376                 | ident_refn_subs ident_refn_sub
1377                 ;
1378
1379 ident_refn_sub  : ident_refn_type_sect  { OCCUR2(TYPE, 0, 1) }
1380                 | no_std_sub
1381                 ;
1382
1383 ident_refn_type_sect : OPEN DELIM TAG_TYPE DELIM line_item   
1384                        { OPEN(TYPE) } no_std_subs { CHECK0 } CLOSE { }
1385                      ;
1386
1387 ident_rin_sect  : OPEN DELIM TAG_RIN DELIM line_item   
1388                   { OPEN(RIN) } no_std_subs { CHECK0 } CLOSE { }
1389                 ;
1390
1391 /* INDIVIDUAL ATTRIBUTE STRUCTURE */
1392 indiv_attr_struc_sub : indiv_cast_sect  /* 0:M */
1393                      | indiv_dscr_sect  /* 0:M */
1394                      | indiv_educ_sect  /* 0:M */
1395                      | indiv_idno_sect  /* 0:M */
1396                      | indiv_nati_sect  /* 0:M */
1397                      | indiv_nchi_sect  /* 0:M */
1398                      | indiv_nmr_sect  /* 0:M */
1399                      | indiv_occu_sect  /* 0:M */
1400                      | indiv_prop_sect  /* 0:M */
1401                      | indiv_reli_sect  /* 0:M */
1402                      | indiv_resi_sect  /* 0:M */
1403                      | indiv_ssn_sect  /* 0:M */
1404                      | indiv_titl_sect  /* 0:M */
1405                      ;
1406
1407 indiv_cast_sect : OPEN DELIM TAG_CAST DELIM line_item 
1408                   { OPEN(CAST) }
1409                   indiv_attr_event_subs
1410                   { CHECK0 }
1411                   CLOSE { }
1412                 ;
1413 indiv_dscr_sect : OPEN DELIM TAG_DSCR DELIM line_item 
1414                   { OPEN(DSCR) }
1415                   indiv_attr_event_subs
1416                   { CHECK0 }
1417                   CLOSE { }
1418                 ;
1419 indiv_educ_sect : OPEN DELIM TAG_EDUC DELIM line_item  
1420                   { OPEN(EDUC) }
1421                   indiv_attr_event_subs 
1422                   { CHECK0 }
1423                   CLOSE { }
1424                 ;
1425 indiv_idno_sect : OPEN DELIM TAG_IDNO DELIM line_item 
1426                   { OPEN(IDNO) }
1427                   indiv_attr_event_subs 
1428                   { CHECK0 }
1429                   CLOSE { }
1430                 ;
1431 indiv_nati_sect : OPEN DELIM TAG_NATI DELIM line_item 
1432                   { OPEN(NATI) }
1433                   indiv_attr_event_subs 
1434                   { CHECK0 }
1435                   CLOSE { }
1436                 ;
1437 indiv_nchi_sect : OPEN DELIM TAG_NCHI DELIM line_item 
1438                   { OPEN(NCHI) }
1439                   indiv_attr_event_subs 
1440                   { CHECK0 }
1441                   CLOSE { }
1442                 ;
1443 indiv_nmr_sect  : OPEN DELIM TAG_NMR DELIM line_item 
1444                   { OPEN(NMR) }
1445                   indiv_attr_event_subs 
1446                   { CHECK0 }
1447                   CLOSE { }
1448                 ;
1449 indiv_occu_sect : OPEN DELIM TAG_OCCU DELIM line_item 
1450                   { OPEN(OCCU) }
1451                   indiv_attr_event_subs 
1452                   { CHECK0 }
1453                   CLOSE { }
1454                 ;
1455 indiv_prop_sect : OPEN DELIM TAG_PROP DELIM line_item 
1456                   { OPEN(PROP) }
1457                   indiv_attr_event_subs 
1458                   { CHECK0 }
1459                   CLOSE { }
1460                 ;
1461 indiv_reli_sect : OPEN DELIM TAG_RELI DELIM line_item 
1462                   { OPEN(RELI) }
1463                   indiv_attr_event_subs 
1464                   { CHECK0 }
1465                   CLOSE { }
1466                 ;
1467 indiv_resi_sect : OPEN DELIM TAG_RESI 
1468                   { OPEN(RESI) }
1469                   indiv_attr_event_subs 
1470                   { CHECK0 }
1471                   CLOSE { }
1472                 ;
1473 indiv_ssn_sect  : OPEN DELIM TAG_SSN DELIM line_item 
1474                   { OPEN(SSN) }
1475                   indiv_attr_event_subs 
1476                   { CHECK0 }
1477                   CLOSE { }
1478                 ;
1479 indiv_titl_sect : OPEN DELIM TAG_TITL DELIM line_item 
1480                   { OPEN(TITL) }
1481                   indiv_attr_event_subs 
1482                   { CHECK0 }
1483                   CLOSE { }
1484                 ;
1485
1486 indiv_attr_event_subs : /* empty */
1487                       | indiv_attr_event_subs indiv_attr_event_sub
1488                       ;
1489
1490 indiv_attr_event_sub  : event_detail_sub
1491                       | no_std_sub
1492                       ;
1493
1494 /* INDIVIDUAL EVENT STRUCTURE */
1495 indiv_even_struc_sub : indiv_birt_sect
1496                      | indiv_gen_sect
1497                      | indiv_adop_sect  /* 0:M */
1498                      | indiv_even_sect  /* 0:M */
1499                      ;
1500
1501 indiv_birt_sect : OPEN DELIM indiv_birt_tag opt_value indiv_birt_subs
1502                   { CHECK0 }
1503                   CLOSE { }
1504                 ;
1505
1506 indiv_birt_tag  : TAG_BIRT { OPEN(BIRT) }
1507                 | TAG_CHR { OPEN(CHR) }
1508                 ;
1509
1510 indiv_birt_subs : /* empty */
1511                 | indiv_birt_subs indiv_birt_sub
1512                 ;
1513
1514 indiv_birt_sub  : event_detail_sub
1515                 | indiv_birt_famc_sect  { OCCUR2(FAMC,0, 1) }
1516                 | no_std_sub
1517                 ;
1518
1519 indiv_birt_famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER   
1520                        { OPEN(FAMC) } no_std_subs { CHECK0 } CLOSE { }
1521                      ;
1522
1523 indiv_gen_sect  : OPEN DELIM indiv_gen_tag opt_value indiv_gen_subs
1524                   { CHECK0 }
1525                   CLOSE { }
1526                 ;
1527
1528 indiv_gen_tag   : TAG_DEAT { OPEN(DEAT) }
1529                 | TAG_BURI { OPEN(BURI) }
1530                 | TAG_CREM { OPEN(CREM) }
1531                 | TAG_BAPM { OPEN(BAPM) }
1532                 | TAG_BARM { OPEN(BARM) }
1533                 | TAG_BASM { OPEN(BASM) }
1534                 | TAG_BLES { OPEN(BLES) }
1535                 | TAG_CHRA { OPEN(CHRA) }
1536                 | TAG_CONF { OPEN(CONF) }
1537                 | TAG_FCOM { OPEN(FCOM) }
1538                 | TAG_ORDN { OPEN(ORDN) }
1539                 | TAG_NATU { OPEN(NATU) }
1540                 | TAG_EMIG { OPEN(EMIG) }
1541                 | TAG_IMMI { OPEN(IMMI) }
1542                 | TAG_CENS { OPEN(CENS) }
1543                 | TAG_PROB { OPEN(PROB) }
1544                 | TAG_WILL { OPEN(WILL) }
1545                 | TAG_GRAD { OPEN(GRAD) }
1546                 | TAG_RETI { OPEN(RETI) }
1547                 ;
1548
1549 indiv_gen_subs  : /* empty */
1550                 | indiv_gen_subs indiv_gen_sub
1551                 ;
1552
1553 indiv_gen_sub   : event_detail_sub
1554                 | no_std_sub
1555                 ;
1556
1557 indiv_adop_sect : OPEN DELIM TAG_ADOP opt_value 
1558                   { OPEN(ADOP) }
1559                   indiv_adop_subs
1560                   { CHECK0 }
1561                   CLOSE { }
1562                 ;
1563
1564 indiv_adop_subs : /* empty */
1565                 | indiv_adop_subs indiv_adop_sub
1566                 ;
1567
1568 indiv_adop_sub  : event_detail_sub
1569                 | indiv_adop_famc_sect  { OCCUR2(FAMC,0, 1) }
1570                 | no_std_sub
1571                 ;
1572
1573 indiv_adop_famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER 
1574                        { OPEN(FAMC) }
1575                        indiv_adop_famc_subs
1576                        { CHECK0 }
1577                        CLOSE { }
1578                      ;
1579
1580 indiv_adop_famc_subs : /* empty */
1581                      | indiv_adop_famc_subs indiv_adop_famc_sub
1582                      ;
1583
1584 indiv_adop_famc_sub  : indiv_adop_famc_adop_sect  { OCCUR2(ADOP,0, 1) }
1585                      | no_std_sub
1586                      ;
1587
1588 indiv_adop_famc_adop_sect : OPEN DELIM TAG_ADOP DELIM line_item   
1589                             { OPEN(ADOP) } no_std_subs { CHECK0 } CLOSE { }
1590                           ;
1591
1592 indiv_even_sect : OPEN DELIM TAG_EVEN
1593                   { OPEN(EVEN) }
1594                   indiv_gen_subs
1595                   { CHECK0 }
1596                   CLOSE { }
1597                 ;
1598
1599 /* LDS INDIVIDUAL ORDINANCE */
1600 lds_indiv_ord_sub : lio_bapl_sect  /* 0:M */
1601                   | lio_slgc_sect  /* 0:M */
1602                   ;
1603
1604 lio_bapl_sect : OPEN DELIM lio_bapl_tag lio_bapl_subs
1605                 { CHECK0 }
1606                 CLOSE { }
1607               ;
1608
1609 lio_bapl_tag  : TAG_BAPL { OPEN(BAPL) }
1610               | TAG_CONL { OPEN(CONL) }
1611               | TAG_ENDL { OPEN(ENDL) }
1612               ;
1613
1614 lio_bapl_subs : /* empty */
1615               | lio_bapl_subs lio_bapl_sub
1616               ;
1617
1618 lio_bapl_sub  : lio_bapl_stat_sect  { OCCUR2(STAT, 0, 1) }
1619               | lio_bapl_date_sect  { OCCUR2(DATE, 0, 1) }
1620               | lio_bapl_temp_sect  { OCCUR2(TEMP, 0, 1) }
1621               | lio_bapl_plac_sect  { OCCUR2(PLAC, 0, 1) }
1622               | source_cit_sub
1623               | note_struc_sub
1624               | no_std_sub
1625               ;
1626
1627 lio_bapl_stat_sect : OPEN DELIM TAG_STAT DELIM line_item   
1628                      { OPEN(STAT) } no_std_subs { CHECK0 } CLOSE { }
1629                    ;
1630 lio_bapl_date_sect : OPEN DELIM TAG_DATE DELIM line_item   
1631                      { OPEN(DATE) } no_std_subs { CHECK0 } CLOSE { }
1632                    ;
1633 lio_bapl_temp_sect : OPEN DELIM TAG_TEMP DELIM line_item   
1634                      { OPEN(TEMP) } no_std_subs { CHECK0 } CLOSE { }
1635                    ;
1636 lio_bapl_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item   
1637                      { OPEN(PLAC) } no_std_subs { CHECK0 } CLOSE { }
1638                    ;
1639
1640 lio_slgc_sect : OPEN DELIM TAG_SLGC
1641                 { OPEN(SLGC) }
1642                 lio_slgc_subs
1643                 { CHECK1(FAMC) }
1644                 CLOSE { }
1645               ;
1646
1647 lio_slgc_subs : /* empty */
1648               | lio_slgc_subs lio_slgc_sub
1649               ;
1650
1651 lio_slgc_sub  : lio_bapl_sub
1652               | lio_slgc_famc_sect  { OCCUR2(FAMC, 1, 1) }
1653               ;
1654
1655 lio_slgc_famc_sect : OPEN DELIM TAG_FAMC DELIM POINTER   
1656                      { OPEN(FAMC) } no_std_subs { CHECK0 } CLOSE { }
1657                    ;
1658
1659 /* LDS SPOUSE SEALING */
1660 lds_spouse_seal_sub : lss_slgs_sect
1661                     ;
1662
1663 lss_slgs_sect : OPEN DELIM TAG_SLGS
1664                 { OPEN(SLGS) }
1665                 lss_slgs_subs
1666                 { CHECK0 }
1667                 CLOSE { }
1668               ;
1669
1670 lss_slgs_subs : /* empty */
1671               | lss_slgs_subs lss_slgs_sub
1672               ;
1673
1674 lss_slgs_sub  : lss_slgs_stat_sect  { OCCUR2(STAT, 0, 1) }
1675               | lss_slgs_date_sect  { OCCUR2(DATE, 0, 1) }
1676               | lss_slgs_temp_sect  { OCCUR2(TEMP, 0, 1) }
1677               | lss_slgs_plac_sect  { OCCUR2(PLAC, 0, 1) }
1678               | source_cit_sub
1679               | note_struc_sub
1680               | no_std_sub
1681               ;
1682
1683 lss_slgs_stat_sect : OPEN DELIM TAG_STAT DELIM line_item   
1684                      { OPEN(STAT) } no_std_subs { CHECK0 } CLOSE { }
1685                    ;
1686 lss_slgs_date_sect : OPEN DELIM TAG_DATE DELIM line_item   
1687                      { OPEN(DATE) } no_std_subs { CHECK0 } CLOSE { }
1688                    ;
1689 lss_slgs_temp_sect : OPEN DELIM TAG_TEMP DELIM line_item   
1690                      { OPEN(TEMP) } no_std_subs { CHECK0 } CLOSE { }
1691                    ;
1692 lss_slgs_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item   
1693                      { OPEN(PLAC) } no_std_subs { CHECK0 } CLOSE { }
1694                    ;
1695
1696 /* MULTIMEDIA LINK */
1697 multim_link_sub : multim_obje_link_sect
1698                 | multim_obje_emb_sect
1699                 ;
1700
1701 multim_obje_link_sect : OPEN DELIM TAG_OBJE DELIM POINTER    
1702                         { OPEN(OBJE) } no_std_subs { CHECK0 } CLOSE { }
1703                       ;
1704
1705 multim_obje_emb_sect : OPEN DELIM TAG_OBJE
1706                        { OPEN(OBJE) }
1707                        multim_obje_emb_subs
1708                        { CHECK2(FORM,FILE) }
1709                        CLOSE { }
1710                      ;
1711
1712 multim_obje_emb_subs : /* empty */
1713                      | multim_obje_emb_subs multim_obje_emb_sub
1714                      ;
1715
1716 multim_obje_emb_sub : multim_obje_form_sect  { OCCUR2(FORM, 1, 1) }
1717                     | multim_obje_titl_sect  { OCCUR2(TITL, 0, 1) }
1718                     | multim_obje_file_sect  { OCCUR2(FILE, 1, 1) }
1719                     | note_struc_sub
1720                     | no_std_sub
1721                     ;
1722
1723 multim_obje_form_sect : OPEN DELIM TAG_FORM DELIM line_item    
1724                         { OPEN(FORM) } no_std_subs { CHECK0 } CLOSE { }
1725                       ;
1726 multim_obje_titl_sect : OPEN DELIM TAG_TITL DELIM line_item    
1727                         { OPEN(TITL) } no_std_subs { CHECK0 } CLOSE { }
1728                       ;
1729 multim_obje_file_sect : OPEN DELIM TAG_FILE DELIM line_item    
1730                         { OPEN(FILE) } no_std_subs { CHECK0 } CLOSE { }
1731                       ;
1732
1733 /* NOTE STRUCTURE */
1734 note_struc_sub : note_struc_link_sect  /* 0:M */
1735                | note_struc_emb_sect  /* 0:M */
1736                ;
1737
1738 note_struc_link_sect : OPEN DELIM TAG_NOTE DELIM POINTER
1739                        { OPEN(NOTE) }
1740                        note_struc_link_subs
1741                        { CHECK0 }
1742                        CLOSE { }
1743                      ;
1744
1745 note_struc_link_subs : /* empty */
1746                      | note_struc_link_subs note_struc_link_sub
1747                      ;
1748
1749 note_struc_link_sub : source_cit_sub
1750                     | no_std_sub
1751                     ;
1752
1753 note_struc_emb_sect : OPEN DELIM TAG_NOTE opt_line_item
1754                       { OPEN(NOTE) }
1755                       note_struc_emb_subs
1756                       { CHECK0 }
1757                       CLOSE { }
1758                     ;
1759
1760 note_struc_emb_subs : /* empty */
1761                     | note_struc_emb_subs note_struc_emb_sub
1762                     ;
1763
1764 note_struc_emb_sub  : continuation_sub
1765                     | source_cit_sub
1766                     | no_std_sub
1767                     ;
1768
1769 /* PERSONAL NAME STRUCTURE */
1770 pers_name_struc_sub : pers_name_sect /* 0:M */
1771                     ;
1772
1773 pers_name_sect : OPEN DELIM TAG_NAME DELIM line_item 
1774                  { OPEN(NAME) }
1775                  pers_name_subs
1776                  { CHECK0 }
1777                  CLOSE { }
1778                ;
1779
1780 pers_name_subs : /* empty */
1781                | pers_name_subs pers_name_sub
1782                ;
1783
1784 pers_name_sub  : pers_name_npfx_sect  { OCCUR2(NPFX, 0, 1) }
1785                | pers_name_givn_sect  { OCCUR2(GIVN, 0, 1) }
1786                | pers_name_nick_sect  { OCCUR2(NICK, 0, 1) }
1787                | pers_name_spfx_sect  { OCCUR2(SPFX, 0, 1) }
1788                | pers_name_surn_sect  { OCCUR2(SURN, 0, 1) }
1789                | pers_name_nsfx_sect  { OCCUR2(NSFX, 0, 1) }
1790                | source_cit_sub
1791                | note_struc_sub
1792                | no_std_sub
1793                ;
1794
1795 pers_name_npfx_sect : OPEN DELIM TAG_NPFX DELIM line_item    
1796                       { OPEN(NPFX) } no_std_subs { CHECK0 } CLOSE { }
1797                     ;
1798 pers_name_givn_sect : OPEN DELIM TAG_GIVN DELIM line_item    
1799                       { OPEN(GIVN) } no_std_subs { CHECK0 } CLOSE { }
1800                     ;
1801 pers_name_nick_sect : OPEN DELIM TAG_NICK DELIM line_item    
1802                       { OPEN(NICK) } no_std_subs { CHECK0 } CLOSE { }
1803                     ;
1804 pers_name_spfx_sect : OPEN DELIM TAG_SPFX DELIM line_item    
1805                       { OPEN(SPFX) } no_std_subs { CHECK0 } CLOSE { }
1806                     ;
1807 pers_name_surn_sect : OPEN DELIM TAG_SURN DELIM line_item    
1808                       { OPEN(SURN) } no_std_subs { CHECK0 } CLOSE { }
1809                     ;
1810 pers_name_nsfx_sect : OPEN DELIM TAG_NSFX DELIM line_item    
1811                       { OPEN(NSFX) } no_std_subs { CHECK0 } CLOSE { }
1812                     ;
1813
1814 /* PLACE STRUCTURE */
1815 place_struc_sub : place_struc_plac_sect /* 0:M */
1816                 ;
1817
1818 place_struc_plac_sect : OPEN DELIM TAG_PLAC DELIM line_item 
1819                         { OPEN(PLAC) }
1820                         place_struc_plac_subs
1821                         { CHECK0 }
1822                         CLOSE { }
1823                       ;
1824
1825 place_struc_plac_subs : /* empty */
1826                       | place_struc_plac_subs place_struc_plac_sub
1827                       ;
1828
1829 place_struc_plac_sub : place_plac_form_sect  { OCCUR2(FORM, 0, 1) }
1830                      | source_cit_sub
1831                      | note_struc_sub
1832                      | no_std_sub
1833                      ;
1834
1835 place_plac_form_sect : OPEN DELIM TAG_FORM DELIM line_item    
1836                        { OPEN(FORM) } no_std_subs { CHECK0 } CLOSE { }
1837                      ;
1838
1839 /* SOURCE_CITATION */
1840 source_cit_sub : source_cit_link_sect /* 0:M */
1841                | source_cit_emb_sect /* 0:M */
1842                ;
1843
1844 source_cit_link_sect : OPEN DELIM TAG_SOUR DELIM POINTER
1845                        { OPEN(SOUR) }
1846                        source_cit_link_subs
1847                        { CHECK0 }
1848                        CLOSE { }
1849                      ;
1850
1851 source_cit_link_subs : /* empty */
1852                      | source_cit_link_subs source_cit_link_sub
1853                      ;
1854
1855 source_cit_link_sub : source_cit_page_sect  { OCCUR2(PAGE, 0, 1) }
1856                     | source_cit_even_sect  { OCCUR2(EVEN, 0, 1) }
1857                     | source_cit_data_sect  { OCCUR2(DATA, 0, 1) }
1858                     | source_cit_quay_sect  { OCCUR2(QUAY, 0, 1) }
1859                     | multim_link_sub
1860                     | note_struc_sub
1861                     | no_std_sub
1862                     ;
1863
1864 source_cit_page_sect : OPEN DELIM TAG_PAGE DELIM line_item    
1865                        { OPEN(PAGE) } no_std_subs { CHECK0 } CLOSE { }
1866                      ;
1867
1868 source_cit_even_sect : OPEN DELIM TAG_EVEN DELIM line_item 
1869                        { OPEN(EVEN) }
1870                        source_cit_even_subs
1871                        { CHECK0 }
1872                        CLOSE { }
1873                      ;
1874
1875 source_cit_even_subs : /* empty */
1876                      | source_cit_even_subs source_cit_even_sub
1877                      ;
1878
1879 source_cit_even_sub  : source_cit_even_role_sect  { OCCUR2(ROLE, 0, 1) }
1880                      | no_std_sub
1881                      ;
1882
1883 source_cit_even_role_sect : OPEN DELIM TAG_ROLE DELIM line_item    
1884                           { OPEN(ROLE) } no_std_subs { CHECK0 } CLOSE { }
1885                           ;
1886
1887 source_cit_data_sect : OPEN DELIM TAG_DATA
1888                        { OPEN(DATA) }
1889                        source_cit_data_subs
1890                        { CHECK0 }
1891                        CLOSE { }
1892                      ;
1893
1894 source_cit_data_subs : /* empty */
1895                      | source_cit_data_subs source_cit_data_sub
1896                      ;
1897
1898 source_cit_data_sub : source_cit_data_date_sect  { OCCUR2(DATE, 0, 1) }
1899                     | source_cit_text_sect  /* 0:M */
1900                     | no_std_sub
1901                     ;
1902
1903 source_cit_data_date_sect : OPEN DELIM TAG_DATE DELIM line_item    
1904                             { OPEN(DATE) } no_std_subs { CHECK0 } CLOSE { }
1905                           ;
1906
1907 source_cit_text_sect : OPEN DELIM TAG_TEXT DELIM line_item 
1908                        { OPEN(TEXT) }
1909                        source_cit_text_subs
1910                        { CHECK0 }
1911                        CLOSE { }
1912                      ;
1913
1914 source_cit_text_subs : /* empty */
1915                      | source_cit_text_subs source_cit_text_sub
1916                      ;
1917
1918 source_cit_text_sub : continuation_sub
1919                     | no_std_sub
1920                     ;
1921
1922 source_cit_quay_sect : OPEN DELIM TAG_QUAY DELIM line_item    
1923                        { OPEN(QUAY) } no_std_subs { CHECK0 } CLOSE { }
1924                      ;
1925
1926 source_cit_emb_sect : OPEN DELIM TAG_SOUR DELIM line_item
1927                       { OPEN(SOUR) }
1928                       source_cit_emb_subs
1929                       { CHECK0 }
1930                       CLOSE { }
1931                     ;
1932
1933 source_cit_emb_subs : /* empty */
1934                     | source_cit_emb_subs source_cit_emb_sub
1935                     ;
1936
1937 source_cit_emb_sub : continuation_sub
1938                    | source_cit_text_sect  /* 0:M */
1939                    | note_struc_sub
1940                    | no_std_sub
1941                    ;
1942
1943 /* SOURCE REPOSITORY CITATION */
1944 source_repos_cit_sub : source_repos_repo_sect  { OCCUR2(REPO, 0, 1) }
1945                      ;
1946
1947 source_repos_repo_sect : OPEN DELIM TAG_REPO DELIM POINTER 
1948                          { OPEN(REPO) }
1949                          source_repos_repo_subs
1950                          { CHECK0 }
1951                          CLOSE { }
1952                        ;
1953
1954 source_repos_repo_subs : /* empty */
1955                        | source_repos_repo_subs source_repos_repo_sub
1956                        ;
1957
1958 source_repos_repo_sub  : note_struc_sub
1959                        | caln_sect  /* 0:M */
1960                        | no_std_sub
1961                        ;
1962
1963 caln_sect : OPEN DELIM TAG_CALN DELIM line_item 
1964             { OPEN(CALN) }
1965             caln_subs
1966             { CHECK0 }
1967             CLOSE { }
1968           ;
1969
1970 caln_subs : /* empty */
1971           | caln_subs caln_sub
1972           ;
1973
1974 caln_sub  : caln_medi_sect  { OCCUR2(MEDI, 0, 1) }
1975           | no_std_sub
1976           ;
1977
1978 caln_medi_sect : OPEN DELIM TAG_MEDI DELIM line_item    
1979                  { OPEN(MEDI) } no_std_subs { CHECK0 } CLOSE { }
1980                ;
1981  
1982 /* SPOUSE TO FAMILY LINK */
1983 spou_fam_link_sub : spou_fam_fams_sect  /* 0:M */
1984                   ;
1985
1986 spou_fam_fams_sect : OPEN DELIM TAG_FAMS DELIM POINTER 
1987                      { OPEN(FAMS) }
1988                      spou_fam_fams_subs
1989                      { CHECK0 }
1990                      CLOSE { }
1991                    ;
1992
1993 spou_fam_fams_subs : /* empty */
1994                    | spou_fam_fams_subs spou_fam_fams_sub
1995                    ;
1996
1997 spou_fam_fams_sub  : note_struc_sub
1998                    | no_std_sub
1999                    ;
2000
2001 /*********************************************************************/
2002 /**** General                                                     ****/
2003 /*********************************************************************/
2004
2005 no_std_subs : /* empty */
2006             | no_std_subs no_std_sub
2007             ;
2008
2009 no_std_sub  : user_sect /* 0:M */
2010             | gen_sect
2011             | error error_subs CLOSE  { HANDLE_ERROR }
2012             ;
2013
2014 no_std_rec  : user_rec /* 0:M */
2015             | gen_rec
2016             | error error_subs CLOSE  { HANDLE_ERROR }
2017             ;
2018
2019 user_rec    : OPEN DELIM opt_xref USERTAG 
2020               { if ($4[0] != '_') {
2021                   gedcom_error("Undefined tag (and not a valid user tag): %s",
2022                                $4);
2023                   YYERROR;
2024                 }
2025               }
2026               opt_value user_sects CLOSE { }
2027             ;
2028
2029 user_sect   : OPEN DELIM opt_xref USERTAG 
2030               { if ($4[0] != '_') {
2031                   gedcom_error("Undefined tag (and not a valid user tag): %s",
2032                                $4);
2033                   YYERROR;
2034                 }
2035               }
2036               opt_value user_sects CLOSE { }
2037             ;
2038
2039 user_sects   : /* empty */     { }
2040             | user_sects user_sect { }
2041             ;
2042
2043 opt_xref    : /* empty */        { }
2044             | POINTER DELIM        { }
2045             ;
2046
2047 opt_value   : /* empty */        { }
2048             | DELIM line_value        { }
2049             ;
2050
2051 line_value  : POINTER        { }
2052             | line_item        { }
2053             ;
2054
2055 opt_line_item : /* empty */ { }
2056               | DELIM line_item { }
2057               ;
2058
2059 line_item   : anychar        { }
2060             | ESCAPE        { }
2061             | line_item anychar        { }
2062             | line_item ESCAPE        { }
2063             ;
2064
2065 anychar     : ANYCHAR        { }
2066             | DELIM        { }
2067             ;
2068
2069 error_subs  : /* empty */
2070             | error_subs error_sect
2071             ;
2072
2073 error_sect  : OPEN DELIM opt_xref anytag opt_value error_subs CLOSE { }
2074
2075 gen_sect    : OPEN DELIM opt_xref anystdtag
2076               { INVALID_TAG($4); }
2077               opt_value opt_sects CLOSE
2078               { }
2079             ;
2080
2081 gen_rec     : OPEN DELIM opt_xref anystdtag
2082               { INVALID_TOP_TAG($4) }
2083               opt_value opt_sects CLOSE
2084               { }
2085             ;
2086
2087 opt_sects   : /* empty */     { }
2088             | opt_sects gen_sect { }
2089             ;
2090
2091 anytag      : USERTAG { }
2092             | anystdtag { }
2093             ;
2094
2095 anystdtag   : TAG_ABBR
2096             | TAG_ADDR
2097             | TAG_ADR1
2098             | TAG_ADR2   { }
2099             | TAG_ADOP   { }
2100             | TAG_AFN   { }
2101             | TAG_AGE   { }
2102             | TAG_AGNC   { }
2103             | TAG_ALIA   { }
2104             | TAG_ANCE   { }
2105             | TAG_ANCI   { }
2106             | TAG_ANUL   { }
2107             | TAG_ASSO   { }
2108             | TAG_AUTH   { }
2109             | TAG_BAPL   { }
2110             | TAG_BAPM   { }
2111             | TAG_BARM   { }
2112             | TAG_BASM   { }
2113             | TAG_BIRT   { }
2114             | TAG_BLES   { }
2115             | TAG_BLOB   { }
2116             | TAG_BURI   { }
2117             | TAG_CALN   { }
2118             | TAG_CAST   { }
2119             | TAG_CAUS   { }
2120             | TAG_CENS   { }
2121             | TAG_CHAN   { }
2122             | TAG_CHAR   { }
2123             | TAG_CHIL   { }
2124             | TAG_CHR   { }
2125             | TAG_CHRA   { }
2126             | TAG_CITY   { }
2127             | TAG_CONC   { }
2128             | TAG_CONF   { }
2129             | TAG_CONL   { }
2130             | TAG_CONT   { }
2131             | TAG_COPR   { }
2132             | TAG_CORP   { }
2133             | TAG_CREM   { }
2134             | TAG_CTRY   { }
2135             | TAG_DATA   { }
2136             | TAG_DATE   { }
2137             | TAG_DEAT   { }
2138             | TAG_DESC   { }
2139             | TAG_DESI   { }
2140             | TAG_DEST   { }
2141             | TAG_DIV   { }
2142             | TAG_DIVF   { }
2143             | TAG_DSCR   { }
2144             | TAG_EDUC   { }
2145             | TAG_EMIG   { }
2146             | TAG_ENDL   { }
2147             | TAG_ENGA   { }
2148             | TAG_EVEN   { }
2149             | TAG_FAM    { }
2150             | TAG_FAMC   { }
2151             | TAG_FAMS   { }
2152             | TAG_FCOM   { }
2153             | TAG_FILE   { }
2154             | TAG_FORM   { }
2155             | TAG_GEDC   { }
2156             | TAG_GIVN   { }
2157             | TAG_GRAD   { }
2158             | TAG_HEAD   { }
2159             | TAG_HUSB   { }
2160             | TAG_IDNO   { }
2161             | TAG_IMMI   { }
2162             | TAG_INDI   { }
2163             | TAG_LANG   { }
2164             | TAG_LEGA   { }
2165             | TAG_MARB   { }
2166             | TAG_MARC   { }
2167             | TAG_MARL   { }
2168             | TAG_MARR   { }
2169             | TAG_MARS   { }
2170             | TAG_MEDI   { }
2171             | TAG_NAME   { }
2172             | TAG_NATI   { }
2173             | TAG_NCHI   { }
2174             | TAG_NICK   { }
2175             | TAG_NMR   { }
2176             | TAG_NOTE   { }
2177             | TAG_NPFX   { }
2178             | TAG_NSFX   { }
2179             | TAG_OBJE   { }
2180             | TAG_OCCU   { }
2181             | TAG_ORDI   { }
2182             | TAG_ORDN   { }
2183             | TAG_PAGE   { }
2184             | TAG_PEDI   { }
2185             | TAG_PHON   { }
2186             | TAG_PLAC   { }
2187             | TAG_POST   { }
2188             | TAG_PROB   { }
2189             | TAG_PROP   { }
2190             | TAG_PUBL   { }
2191             | TAG_QUAY   { }
2192             | TAG_REFN   { }
2193             | TAG_RELA   { }
2194             | TAG_RELI   { }
2195             | TAG_REPO   { }
2196             | TAG_RESI   { }
2197             | TAG_RESN   { }
2198             | TAG_RETI   { }
2199             | TAG_RFN   { }
2200             | TAG_RIN   { }
2201             | TAG_ROLE   { }
2202             | TAG_SEX   { }
2203             | TAG_SLGC   { }
2204             | TAG_SLGS   { }
2205             | TAG_SOUR   { }
2206             | TAG_SPFX   { }
2207             | TAG_SSN   { }
2208             | TAG_STAE   { }
2209             | TAG_STAT   { }
2210             | TAG_SUBM   { }
2211             | TAG_SUBN   { }
2212             | TAG_SURN   { }
2213             | TAG_TEMP   { }
2214             | TAG_TEXT   { }
2215             | TAG_TIME   { }
2216             | TAG_TITL   { }
2217             | TAG_TRLR   { }
2218             | TAG_TYPE   { }
2219             | TAG_VERS   { }
2220             | TAG_WIFE   { }
2221             | TAG_WILL   { }
2222
2223 %%
2224
2225 /* Functions that handle the counting of subtags */
2226
2227 int* count_arrays[MAXGEDCOMLEVEL+1];
2228 char tag_stack[MAXGEDCOMLEVEL+1][MAXSTDTAGLENGTH+1];
2229
2230 void push_countarray()
2231 {
2232   int *count = NULL;
2233   if (count_level > MAXGEDCOMLEVEL) {
2234     gedcom_error("Internal error: count array overflow");
2235     exit(1);
2236   }
2237   else {
2238     count = (int *)calloc(YYNTOKENS, sizeof(int));
2239     if (count == NULL) {  int *count = count_arrays[count_level];
2240
2241       gedcom_error("Internal error: count array calloc error");
2242       exit(1);
2243     }
2244     else {
2245       count_arrays[count_level] = count;
2246     }
2247   }
2248 }
2249
2250 void set_parenttag(char* tag)
2251 {
2252   strncpy(tag_stack[count_level], tag, MAXSTDTAGLENGTH+1);
2253 }
2254
2255 char* get_parenttag()
2256 {
2257   return tag_stack[count_level];
2258 }
2259
2260 int count_tag(int tag)
2261 {
2262   int *count = count_arrays[count_level];
2263   return ++count[tag - GEDCOMTAGOFFSET];
2264 }
2265
2266 int check_occurrence(int tag)
2267 {
2268   int *count = count_arrays[count_level];
2269   return (count[tag - GEDCOMTAGOFFSET] > 0);
2270 }
2271
2272 void pop_countarray()
2273 {
2274   int *count;
2275   if (count_level < 0) {
2276     gedcom_error("Internal error: count array underflow");
2277     exit(1);
2278   }
2279   else {
2280     count = count_arrays[count_level];
2281     free(count);
2282     count_arrays[count_level] = NULL;
2283   }
2284 }
2285
2286 /* Enabling debug mode */
2287
2288 void gedcom_enable_debug()
2289 {
2290 #if YYDEBUG != 0
2291   gedcom_debug = 1;
2292 #endif
2293 }
2294
2295 /* Setting the error mechanism */
2296
2297 void gedcom_set_error_handling(MECHANISM mechanism)
2298 {
2299   curr_mechanism = mechanism;
2300 }
2301