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