1 /* This program is free software; you can redistribute it and/or modify *
2 * it under the terms of the GNU General Public License as published by *
3 * the Free Software Foundation; either version 2 of the License, or *
4 * (at your option) any later version. *
6 (C) 2001 by The Genes Development Team
7 Original author: Peter Verthez (Peter.Verthez@advalvas.be)
13 /* WARNING: THIS PARSER RELIES HEAVILY ON SOME FEATURES OF BISON.
14 DON'T TRY TO USE IT WITH YACC, IT WON'T WORK...
17 /* Design of the parser:
19 In general, a GEDCOM file contains records, each consisting of a line
20 (which we'll call a section), hierarchically containing other lines
21 (subsections of the section).
23 This means that in general we have:
25 A 'record' is a 'section' (sect) containing 'subsections' (subs)
26 Each 'subsection' (sub) is again a specific 'section' (sect)
28 In parser notation, this means:
32 sect : <some prefix> subs <some suffix>
34 subs : <empty> | subs sub
36 sub : sect_a | sect_b | ...
38 This pattern is repeated throughout the parser for the different types of
42 Cardinality of the subsections:
43 -------------------------------
44 Note that in the above, the order of the subsections is of no importance.
45 Indeed, this is the case in the GEDCOM grammar. However, this also makes
46 it difficult to check whether there are not too many subsections of a
47 specific type, or whether a mandatory subsection is indeed there.
49 Suppose there is a section A that can contain 0 or 1 B section and
52 This can be expressed in parser notation as follows:
54 A : CC | BCC | CBC | CCB
56 So, cardinality is indeed expressable. However, as the number of subsection
57 types and the limits grow bigger (and even theoretically limitless), listing
58 all possible permutations becomes quickly unfeasible.
60 Much simpler is to say:
63 subs : <empty> | subs sub
66 and then check the cardinality in the semantic actions, which is the
67 solution chosen in the parser below, using the following macros:
70 Make a new context for the <parent> tag to count child tags in
72 - OCCUR2(<child>, <min>, <max>)
73 Express that the <child> tag should occur at least <min> times and
74 at most <max> tags within its parent
76 What this actually does is the following. It increments the counter
77 for that tag and then checks whether the maximum is exceeded. If so,
78 then a parser error is produced. The minimum is not actually checked
79 by this macro, but it makes the statements more declarative.
81 - OCCUR1(<child>, <min>)
82 Express that the <child> tag should occur at least <min> times within
83 its parent (no upper limit)
85 Actually, this only increments the counter for the tag, but it looks
86 very like the previous macro.
88 If the minimum is 0, it is not necessary to express this constraint.
90 - CHECKn(<child1>, ..., <childn>)
91 This closes the context for the parent tag and checks whether the
92 given <child> tags did effectively occur within the parent (i.e.
93 these are the tags that were mandatory).
95 Since the <min> values above are always 0 or 1 in GEDCOM, this is
96 sufficient. All sub-tags that declare a minimum of 1 in the OCCUR
97 macros should be listed in this macro here.
99 The macros CHECK0 to CHECK4 are defined like this (the first one
100 has no arguments and is only used to close the parent context; note
101 that this is necessary for correct functioning).
105 Only sections that have subsections need to use these macros. This can
106 be done like this (the OPEN and CHECK macros are used as mid-rule
107 actions around the subsections):
109 head_sect : OPEN DELIM TAG_HEAD
113 CLOSE { <semantic actions> }
119 head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) }
120 | head_dest_sect { OCCUR2(DEST, 0, 1) }
121 | head_date_sect { OCCUR2(DATE, 0, 1) }
127 - The syntax analysis doesn't handle the contents of the line values;
128 this is done in the semantic analysis.
134 #include "multilex.h"
135 #include "encoding.h"
136 #include "interface.h"
140 int compat_enabled = 1;
141 int gedcom_high_level_debug = 0;
142 int compatibility = 0;
143 Gedcom_err_mech error_mechanism = IMMED_FAIL;
145 char line_item_buf[MAXGEDCLINELEN * UTF_FACTOR + 1];
146 char *line_item_buf_ptr;
152 /* These are defined at the bottom of the file */
153 void push_countarray();
154 void set_parenttag(char* tag);
155 char* get_parenttag();
156 void set_parentctxt(Gedcom_ctxt ctxt);
157 Gedcom_ctxt get_parentctxt();
158 void pop_countarray();
159 int count_tag(int tag);
160 int check_occurrence(int tag);
161 void set_compatibility(char* program);
162 int compat_mode(int flags);
164 #define CLEAR_BUFFER(BUF) \
165 memset(BUF, 0, sizeof(BUF));
167 #define HANDLE_ERROR \
168 { if (error_mechanism == IMMED_FAIL) { \
171 else if (error_mechanism == DEFER_FAIL) { \
174 else if (error_mechanism == IGNORE_ERRORS) { \
178 #define START(PARENTTAG,PARENTCTXT) \
180 set_parenttag(#PARENTTAG); \
181 set_parentctxt(PARENTCTXT); \
187 { if (!check_occurrence(TAG_##TAG)) { \
188 char* parenttag = get_parenttag(); \
189 gedcom_error("The tag '%s' is mandatory within '%s', but missing", \
195 { pop_countarray(); \
199 #define CHECK1(TAG1) { CHK(TAG1); POP; }
200 #define CHECK2(TAG1,TAG2) \
201 { CHK(TAG1); CHK(TAG2); POP; }
202 #define CHECK3(TAG1,TAG2,TAG3) \
203 { CHK(TAG1); CHK(TAG2); CHK(TAG3); POP; }
204 #define CHECK4(TAG1,TAG2,TAG3,TAG4) \
205 { CHK(TAG1); CHK(TAG2); CHK(TAG3); CHK(TAG4); POP; }
206 #define OCCUR1(CHILDTAG, MIN) { count_tag(TAG_##CHILDTAG); }
207 #define OCCUR2(CHILDTAG, MIN, MAX) \
208 { int num = count_tag(TAG_##CHILDTAG); \
210 char* parenttag = get_parenttag(); \
211 gedcom_error("The tag '%s' can maximally occur %d " \
212 "time(s) within '%s'", \
213 #CHILDTAG, MAX, parenttag); \
217 #define INVALID_TAG(CHILDTAG) \
218 { char* parenttag = get_parenttag(); \
219 gedcom_error("The tag '%s' is not a valid tag within '%s'", \
220 CHILDTAG, parenttag); \
223 #define INVALID_TOP_TAG(CHILDTAG) \
224 { gedcom_error("The tag '%s' is not a valid top-level tag", \
240 %token <string> BADTOKEN
242 %token <string> CLOSE
243 %token <string> ESCAPE
244 %token <string> DELIM
245 %token <string> ANYCHAR
246 %token <string> POINTER
247 %token <string> USERTAG
248 %token <string> TAG_ABBR
249 %token <string> TAG_ADDR
250 %token <string> TAG_ADR1
251 %token <string> TAG_ADR2
252 %token <string> TAG_ADOP
253 %token <string> TAG_AFN
254 %token <string> TAG_AGE
255 %token <string> TAG_AGNC
256 %token <string> TAG_ALIA
257 %token <string> TAG_ANCE
258 %token <string> TAG_ANCI
259 %token <string> TAG_ANUL
260 %token <string> TAG_ASSO
261 %token <string> TAG_AUTH
262 %token <string> TAG_BAPL
263 %token <string> TAG_BAPM
264 %token <string> TAG_BARM
265 %token <string> TAG_BASM
266 %token <string> TAG_BIRT
267 %token <string> TAG_BLES
268 %token <string> TAG_BLOB
269 %token <string> TAG_BURI
270 %token <string> TAG_CALN
271 %token <string> TAG_CAST
272 %token <string> TAG_CAUS
273 %token <string> TAG_CENS
274 %token <string> TAG_CHAN
275 %token <string> TAG_CHAR
276 %token <string> TAG_CHIL
277 %token <string> TAG_CHR
278 %token <string> TAG_CHRA
279 %token <string> TAG_CITY
280 %token <string> TAG_CONC
281 %token <string> TAG_CONF
282 %token <string> TAG_CONL
283 %token <string> TAG_CONT
284 %token <string> TAG_COPR
285 %token <string> TAG_CORP
286 %token <string> TAG_CREM
287 %token <string> TAG_CTRY
288 %token <string> TAG_DATA
289 %token <string> TAG_DATE
290 %token <string> TAG_DEAT
291 %token <string> TAG_DESC
292 %token <string> TAG_DESI
293 %token <string> TAG_DEST
294 %token <string> TAG_DIV
295 %token <string> TAG_DIVF
296 %token <string> TAG_DSCR
297 %token <string> TAG_EDUC
298 %token <string> TAG_EMIG
299 %token <string> TAG_ENDL
300 %token <string> TAG_ENGA
301 %token <string> TAG_EVEN
302 %token <string> TAG_FAM
303 %token <string> TAG_FAMC
304 %token <string> TAG_FAMF
305 %token <string> TAG_FAMS
306 %token <string> TAG_FCOM
307 %token <string> TAG_FILE
308 %token <string> TAG_FORM
309 %token <string> TAG_GEDC
310 %token <string> TAG_GIVN
311 %token <string> TAG_GRAD
312 %token <string> TAG_HEAD
313 %token <string> TAG_HUSB
314 %token <string> TAG_IDNO
315 %token <string> TAG_IMMI
316 %token <string> TAG_INDI
317 %token <string> TAG_LANG
318 %token <string> TAG_LEGA
319 %token <string> TAG_MARB
320 %token <string> TAG_MARC
321 %token <string> TAG_MARL
322 %token <string> TAG_MARR
323 %token <string> TAG_MARS
324 %token <string> TAG_MEDI
325 %token <string> TAG_NAME
326 %token <string> TAG_NATI
327 %token <string> TAG_NATU
328 %token <string> TAG_NCHI
329 %token <string> TAG_NICK
330 %token <string> TAG_NMR
331 %token <string> TAG_NOTE
332 %token <string> TAG_NPFX
333 %token <string> TAG_NSFX
334 %token <string> TAG_OBJE
335 %token <string> TAG_OCCU
336 %token <string> TAG_ORDI
337 %token <string> TAG_ORDN
338 %token <string> TAG_PAGE
339 %token <string> TAG_PEDI
340 %token <string> TAG_PHON
341 %token <string> TAG_PLAC
342 %token <string> TAG_POST
343 %token <string> TAG_PROB
344 %token <string> TAG_PROP
345 %token <string> TAG_PUBL
346 %token <string> TAG_QUAY
347 %token <string> TAG_REFN
348 %token <string> TAG_RELA
349 %token <string> TAG_RELI
350 %token <string> TAG_REPO
351 %token <string> TAG_RESI
352 %token <string> TAG_RESN
353 %token <string> TAG_RETI
354 %token <string> TAG_RFN
355 %token <string> TAG_RIN
356 %token <string> TAG_ROLE
357 %token <string> TAG_SEX
358 %token <string> TAG_SLGC
359 %token <string> TAG_SLGS
360 %token <string> TAG_SOUR
361 %token <string> TAG_SPFX
362 %token <string> TAG_SSN
363 %token <string> TAG_STAE
364 %token <string> TAG_STAT
365 %token <string> TAG_SUBM
366 %token <string> TAG_SUBN
367 %token <string> TAG_SURN
368 %token <string> TAG_TEMP
369 %token <string> TAG_TEXT
370 %token <string> TAG_TIME
371 %token <string> TAG_TITL
372 %token <string> TAG_TRLR
373 %token <string> TAG_TYPE
374 %token <string> TAG_VERS
375 %token <string> TAG_WIFE
376 %token <string> TAG_WILL
378 %type <string> anystdtag
379 %type <string> anytoptag
380 %type <string> line_item
381 %type <string> mand_line_item
382 %type <string> note_line_item
383 %type <string> anychar
384 %type <ctxt> head_sect
388 file : head_sect records trlr_sect
389 { if (fail == 1) YYABORT; }
392 records : /* empty */
407 /*********************************************************************/
409 /*********************************************************************/
410 head_sect : OPEN DELIM TAG_HEAD
411 { $<ctxt>$ = start_record(REC_HEAD, NULL);
412 START(HEAD, $<ctxt>$) }
414 { if (compat_mode(C_FTREE))
415 CHECK3(SOUR, GEDC, CHAR)
417 CHECK4(SOUR, SUBM, GEDC, CHAR)
420 { end_record(REC_HEAD, $<ctxt>4); }
423 head_subs : /* empty */
427 head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) }
428 | head_dest_sect { OCCUR2(DEST, 0, 1) }
429 | head_date_sect { OCCUR2(DATE, 0, 1) }
430 | head_subm_sect { OCCUR2(SUBM, 1, 1) }
431 | head_subn_sect { OCCUR2(SUBN, 0, 1) }
432 | head_file_sect { OCCUR2(FILE, 0, 1) }
433 | head_copr_sect { OCCUR2(COPR, 0, 1) }
434 | head_gedc_sect { OCCUR2(GEDC, 1, 1) }
435 | head_char_sect { OCCUR2(CHAR, 1, 1) }
436 | head_lang_sect { OCCUR2(LANG, 0, 1) }
437 | head_plac_sect { OCCUR2(PLAC, 0, 1) }
438 | head_note_sect { OCCUR2(NOTE, 0, 1) }
443 head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item
444 { set_compatibility($4);
445 $<ctxt>$ = start_element(ELT_HEAD_SOUR, PARENT,
447 START(SOUR, $<ctxt>$)
452 { end_element(PARENT, $<ctxt>5); }
455 head_sour_subs : /* empty */
456 | head_sour_subs head_sour_sub
459 head_sour_sub : head_sour_vers_sect { OCCUR2(VERS, 0, 1) }
460 | head_sour_name_sect { OCCUR2(NAME, 0, 1) }
461 | head_sour_corp_sect { OCCUR2(CORP, 0, 1) }
462 | head_sour_data_sect { OCCUR2(DATA, 0, 1) }
466 head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item
467 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_VERS, PARENT,
469 START(VERS, $<ctxt>$)
474 { end_element(PARENT, $<ctxt>5); }
476 head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item
477 { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE
478 { gedcom_debug_print("===Source name: '%s'\n", $4);
481 head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item
482 { gedcom_debug_print("===Source corp name: '%s'\n", $4);
490 head_sour_corp_subs : /* empty */
491 | head_sour_corp_subs head_sour_corp_sub
494 head_sour_corp_sub : addr_struc_sub /* 0:1 */
498 head_sour_data_sect : OPEN DELIM TAG_DATA mand_line_item
499 { START(DATA, NULL) }
506 head_sour_data_subs : /* empty */
507 | head_sour_data_subs head_sour_data_sub
510 head_sour_data_sub : head_sour_data_date_sect { OCCUR2(DATE, 0, 1) }
511 | head_sour_data_copr_sect { OCCUR2(COPR, 0, 1) }
515 head_sour_data_date_sect : OPEN DELIM TAG_DATE mand_line_item
516 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE
519 head_sour_data_copr_sect : OPEN DELIM TAG_COPR mand_line_item
520 { START(COPR, NULL) } no_std_subs { CHECK0 } CLOSE
525 head_dest_sect : OPEN DELIM TAG_DEST mand_line_item
526 { START(DEST, NULL) } no_std_subs { CHECK0 } CLOSE
531 head_date_sect : OPEN DELIM TAG_DATE mand_line_item
532 { START(DATE, NULL) }
539 head_date_subs : /* empty */
540 | head_date_subs head_date_sub
543 head_date_sub : head_date_time_sect { OCCUR2(TIME, 0, 1) }
547 head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
548 { START(TIME, NULL) } no_std_subs { CHECK0 } CLOSE
553 head_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
554 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE
558 head_subn_sect : OPEN DELIM TAG_SUBN mand_pointer
559 { START(SUBN, NULL) } no_std_subs { CHECK0 } CLOSE
563 head_file_sect : OPEN DELIM TAG_FILE mand_line_item
564 { START(FILE, NULL) } no_std_subs { CHECK0 } CLOSE
568 head_copr_sect : OPEN DELIM TAG_COPR mand_line_item
569 { START(COPR, NULL) } no_std_subs { CHECK0 } CLOSE
573 head_gedc_sect : OPEN DELIM TAG_GEDC
574 { START(GEDC, NULL) }
576 { CHECK2(VERS, FORM) }
581 head_gedc_subs : /* empty */
582 | head_gedc_subs head_gedc_sub
585 head_gedc_sub : head_gedc_vers_sect { OCCUR2(VERS, 1, 1) }
586 | head_gedc_form_sect { OCCUR2(FORM, 1, 1) }
589 head_gedc_vers_sect : OPEN DELIM TAG_VERS mand_line_item
590 { START(VERS, NULL) } no_std_subs { CHECK0 } CLOSE
593 head_gedc_form_sect : OPEN DELIM TAG_FORM mand_line_item
594 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE
599 head_char_sect : OPEN DELIM TAG_CHAR mand_line_item
600 { if (open_conv_to_internal($4) == 0) YYERROR;
608 head_char_subs : /* empty */
609 | head_char_subs head_char_sub
612 head_char_sub : head_char_vers_sect { OCCUR2(VERS, 0, 1) }
615 head_char_vers_sect : OPEN DELIM TAG_VERS mand_line_item
616 { START(VERS, NULL) } no_std_subs { CHECK0 } CLOSE
621 head_lang_sect : OPEN DELIM TAG_LANG mand_line_item
622 { START(LANG, NULL) } no_std_subs { CHECK0 } CLOSE
626 head_plac_sect : OPEN DELIM TAG_PLAC
627 { START(PLAC, NULL) }
634 head_plac_subs : /* empty */
635 | head_plac_subs head_plac_sub
638 head_plac_sub : head_plac_form_sect { OCCUR2(FORM, 1, 1) }
641 head_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item
642 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE
647 head_note_sect : OPEN DELIM TAG_NOTE mand_line_item
648 { START(NOTE, NULL) }
655 head_note_subs : /* empty */
656 | head_note_subs head_note_sub
659 head_note_sub : continuation_sub /* 0:M */
663 /*********************************************************************/
665 /*********************************************************************/
666 trlr_sect : OPEN DELIM TAG_TRLR CLOSE { }
669 /*********************************************************************/
670 /**** Family record ****/
671 /*********************************************************************/
672 fam_rec : OPEN DELIM POINTER DELIM TAG_FAM
673 { $<ctxt>$ = start_record(REC_FAM, $3);
674 START(FAM, $<ctxt>$) }
678 { end_record(REC_FAM, $<ctxt>6); }
681 fam_subs : /* empty */
685 fam_sub : fam_event_struc_sub /* 0:M */
686 | fam_husb_sect { OCCUR2(HUSB, 0, 1) }
687 | fam_wife_sect { OCCUR2(WIFE, 0, 1) }
688 | fam_chil_sect /* 0:M */
689 | fam_nchi_sect { OCCUR2(NCHI, 0, 1) }
690 | fam_subm_sect /* 0:M */
691 | lds_spouse_seal_sub /* 0:M */
692 | source_cit_sub /* 0:M */
693 | multim_link_sub /* 0:M */
694 | note_struc_sub /* 0:M */
695 | ident_struc_sub /* 0:1 */
696 | change_date_sub /* 0:1 */
701 fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer
702 { START(HUSB, NULL) } no_std_subs { CHECK0 } CLOSE
707 fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer
708 { START(WIFE, NULL) } no_std_subs { CHECK0 } CLOSE
713 fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer
714 { START(CHIL, NULL) } no_std_subs { CHECK0 } CLOSE
719 fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
720 { START(NCHI, NULL) } no_std_subs { CHECK0 } CLOSE
725 fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
726 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE
730 /*********************************************************************/
731 /**** Individual record ****/
732 /*********************************************************************/
733 indiv_rec : OPEN DELIM POINTER DELIM TAG_INDI
734 { START(INDI, NULL) }
740 indi_subs : /* empty */
744 indi_sub : indi_resn_sect { OCCUR2(RESN, 0, 1) }
745 | pers_name_struc_sub /* 0:M */
746 | indi_sex_sect { OCCUR2(SEX, 0, 1) }
747 | indiv_even_struc_sub /* 0:M */
748 | indiv_attr_struc_sub /* 0:M */
749 | lds_indiv_ord_sub /* 0:M */
750 | chi_fam_link_sub /* 0:M */
751 | spou_fam_link_sub /* 0:M */
752 | indi_subm_sect /* 0:M */
753 | assoc_struc_sub /* 0:M */
754 | indi_alia_sect /* 0:M */
755 | indi_anci_sect /* 0:M */
756 | indi_desi_sect /* 0:M */
757 | source_cit_sub /* 0:M */
758 | multim_link_sub /* 0:M */
759 | note_struc_sub /* 0:M */
760 | indi_rfn_sect { OCCUR2(RFN, 0, 1) }
761 | indi_afn_sect /* 0:M */
762 | ident_struc_sub /* 0:1 */
763 | change_date_sub /* 0:1 */
764 | ftree_addr_sect { if (!compat_mode(C_FTREE))
771 indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item
772 { START(RESN, NULL) } no_std_subs { CHECK0 } CLOSE { }
776 indi_sex_sect : OPEN DELIM TAG_SEX mand_line_item
777 { START(SEX, NULL) } no_std_subs { CHECK0 } CLOSE { }
781 indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
782 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE { }
786 indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer
787 { START(ALIA, NULL) } no_std_subs { CHECK0 } CLOSE { }
791 indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer
792 { START(ANCI, NULL) } no_std_subs { CHECK0 } CLOSE { }
796 indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer
797 { START(DESI, NULL) } no_std_subs { CHECK0 } CLOSE { }
801 indi_rfn_sect : OPEN DELIM TAG_RFN mand_line_item
802 { START(RFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
806 indi_afn_sect : OPEN DELIM TAG_AFN mand_line_item
807 { START(AFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
810 /* INDI.ADDR (Only for 'ftree' compatibility) */
811 ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item
812 { START(ADDR, NULL) } no_std_subs { CHECK0 } CLOSE { }
814 /*********************************************************************/
815 /**** Multimedia record ****/
816 /*********************************************************************/
817 multim_rec : OPEN DELIM POINTER DELIM TAG_OBJE
818 { START(OBJE, NULL) }
820 { CHECK2(FORM, BLOB) }
824 obje_subs : /* empty */
828 obje_sub : obje_form_sect { OCCUR2(FORM, 1, 1) }
829 | obje_titl_sect { OCCUR2(TITL, 0, 1) }
830 | note_struc_sub /* 0:M */
831 | obje_blob_sect { OCCUR2(BLOB, 1, 1) }
832 | obje_obje_sect { OCCUR2(OBJE, 0, 1) }
833 | ident_struc_sub /* 0:1 */
834 | change_date_sub /* 0:1 */
839 obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
840 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
844 obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
845 { START(TITL, NULL) } no_std_subs { CHECK0 } CLOSE { }
849 obje_blob_sect : OPEN DELIM TAG_BLOB
850 { START(BLOB, NULL) }
856 obje_blob_subs : /* empty */
857 | obje_blob_subs obje_blob_sub
860 obje_blob_sub : obje_blob_cont_sect { OCCUR1(CONT, 1) }
864 obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item
865 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
869 obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer
870 { START(OBJE, NULL) } no_std_subs { CHECK0 } CLOSE { }
873 /*********************************************************************/
874 /**** Note record ****/
875 /*********************************************************************/
876 note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item
877 { START(NOTE, NULL) }
883 note_line_item : /* empty */
884 { if (!compat_mode(C_FTREE)) {
885 gedcom_error("Missing value"); YYERROR;
889 { gedcom_debug_print("==Val: %s==\n", $2);
893 note_subs : /* empty */
897 note_sub : continuation_sub /* 0:M */
898 | source_cit_sub /* 0:M */
899 | ident_struc_sub /* 0:1 */
900 | change_date_sub /* 0:1 */
904 /*********************************************************************/
905 /**** Repository record ****/
906 /*********************************************************************/
907 repos_rec : OPEN DELIM POINTER DELIM TAG_REPO
908 { START(REPO, NULL) }
914 repo_subs : /* empty */
918 repo_sub : repo_name_sect { OCCUR2(NAME, 0, 1) }
919 | addr_struc_sub /* 0:1 */
920 | note_struc_sub /* 0:M */
921 | ident_struc_sub /* 0:1 */
922 | change_date_sub /* 0:1 */
927 repo_name_sect : OPEN DELIM TAG_NAME mand_line_item
928 { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE {}
931 /*********************************************************************/
932 /**** Source record ****/
933 /*********************************************************************/
934 source_rec : OPEN DELIM POINTER DELIM TAG_SOUR
935 { START(SOUR, NULL) }
941 sour_subs : /* empty */
945 sour_sub : sour_data_sect { OCCUR2(DATA, 0, 1) }
946 | sour_auth_sect { OCCUR2(AUTH, 0, 1) }
947 | sour_titl_sect { OCCUR2(TITL, 0, 1) }
948 | sour_abbr_sect { OCCUR2(ABBR, 0, 1) }
949 | sour_publ_sect { OCCUR2(PUBL, 0, 1) }
950 | sour_text_sect { OCCUR2(TEXT, 0, 1) }
951 | source_repos_cit_sub /* 0:1 */
952 | multim_link_sub /* 0:M */
953 | note_struc_sub /* 0:M */
954 | ident_struc_sub /* 0:1 */
955 | change_date_sub /* 0:1 */
960 sour_data_sect : OPEN DELIM TAG_DATA
961 { START(DATA, NULL) }
967 sour_data_subs : /* empty */
968 | sour_data_subs sour_data_sub
971 sour_data_sub : sour_data_even_sect /* 0:M */
972 | sour_data_agnc_sect { OCCUR2(AGNC, 0, 1) }
973 | note_struc_sub /* 0:M */
977 sour_data_even_sect : OPEN DELIM TAG_EVEN mand_line_item
978 { START(EVEN, NULL) }
984 sour_data_even_subs : /* empty */
985 | sour_data_even_subs sour_data_even_sub
988 sour_data_even_sub : sour_data_even_date_sect { OCCUR2(DATE, 0, 1) }
989 | sour_data_even_plac_sect { OCCUR2(PLAC, 0, 1) }
993 sour_data_even_date_sect : OPEN DELIM TAG_DATE mand_line_item
994 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
997 sour_data_even_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
998 { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1001 sour_data_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item
1002 { START(AGNC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1006 sour_auth_sect : OPEN DELIM TAG_AUTH mand_line_item
1007 { START(AUTH, NULL) }
1013 sour_auth_subs : /* empty */
1014 | sour_auth_subs sour_auth_sub
1017 sour_auth_sub : continuation_sub /* 0:M */
1022 sour_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1023 { START(TITL, NULL) }
1029 sour_titl_subs : /* empty */
1030 | sour_titl_subs sour_titl_sub
1033 sour_titl_sub : continuation_sub /* 0:M */
1038 sour_abbr_sect : OPEN DELIM TAG_ABBR mand_line_item
1039 { START(ABBR, NULL) } no_std_subs { CHECK0 } CLOSE { }
1043 sour_publ_sect : OPEN DELIM TAG_PUBL mand_line_item
1044 { START(PUBL, NULL) }
1050 sour_publ_subs : /* empty */
1051 | sour_publ_subs sour_publ_sub
1054 sour_publ_sub : continuation_sub /* 0:M */
1059 sour_text_sect : OPEN DELIM TAG_TEXT mand_line_item
1060 { START(TEXT, NULL) }
1066 sour_text_subs : /* empty */
1067 | sour_text_subs sour_text_sub
1070 sour_text_sub : continuation_sub /* 0:M */
1074 /*********************************************************************/
1075 /**** Submission record ****/
1076 /*********************************************************************/
1077 submis_rec : OPEN DELIM POINTER DELIM TAG_SUBN
1078 { START(SUBN, NULL) }
1084 subn_subs : /* empty */
1085 | subn_subs subn_sub
1088 subn_sub : subn_subm_sect { OCCUR2(SUBM, 0, 1) }
1089 | subn_famf_sect { OCCUR2(FAMF, 0, 1) }
1090 | subn_temp_sect { OCCUR2(TEMP, 0, 1) }
1091 | subn_ance_sect { OCCUR2(ANCE, 0, 1) }
1092 | subn_desc_sect { OCCUR2(DESC, 0, 1) }
1093 | subn_ordi_sect { OCCUR2(ORDI, 0, 1) }
1094 | subn_rin_sect { OCCUR2(RIN, 0, 1) }
1099 subn_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
1100 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE { }
1104 subn_famf_sect : OPEN DELIM TAG_FAMF mand_line_item
1105 { START(FAMF, NULL) } no_std_subs { CHECK0 } CLOSE { }
1109 subn_temp_sect : OPEN DELIM TAG_TEMP mand_line_item
1110 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1114 subn_ance_sect : OPEN DELIM TAG_ANCE mand_line_item
1115 { START(ANCE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1119 subn_desc_sect : OPEN DELIM TAG_DESC mand_line_item
1120 { START(DESC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1124 subn_ordi_sect : OPEN DELIM TAG_ORDI mand_line_item
1125 { START(ORDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
1129 subn_rin_sect : OPEN DELIM TAG_RIN mand_line_item
1130 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1133 /*********************************************************************/
1134 /**** Submitter record ****/
1135 /*********************************************************************/
1136 submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM
1137 { START(SUBM, NULL) }
1143 subm_subs : /* empty */
1144 | subm_subs subm_sub
1147 subm_sub : subm_name_sect { OCCUR2(NAME, 0, 1) }
1148 | addr_struc_sub /* 0:1 */
1149 | multim_link_sub /* 0:M */
1150 | subm_lang_sect { OCCUR2(LANG, 0, 3) }
1151 | subm_rfn_sect { OCCUR2(RFN, 0, 1) }
1152 | subm_rin_sect { OCCUR2(RIN, 0, 1) }
1153 | change_date_sub /* 0:1 */
1158 subm_name_sect : OPEN DELIM TAG_NAME mand_line_item
1159 { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE { }
1163 subm_lang_sect : OPEN DELIM TAG_LANG mand_line_item
1164 { START(LANG, NULL) } no_std_subs { CHECK0 } CLOSE { }
1168 subm_rfn_sect : OPEN DELIM TAG_RFN mand_line_item
1169 { START(RFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1173 subm_rin_sect : OPEN DELIM TAG_RIN mand_line_item
1174 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1177 /*********************************************************************/
1178 /**** Substructures ****/
1179 /*********************************************************************/
1181 /* ADDRESS STRUCTURE */
1182 addr_struc_sub : addr_sect { OCCUR2(ADDR, 0, 1) }
1183 | phon_sect { OCCUR2(PHON, 0, 3) }
1186 addr_sect : OPEN DELIM TAG_ADDR mand_line_item
1187 { START(ADDR, NULL) }
1193 addr_subs : /* empty */
1194 | addr_subs addr_sub
1197 addr_sub : addr_cont_sect /* 0:M */
1198 | addr_adr1_sect { OCCUR2(ADR1, 0, 1) }
1199 | addr_adr2_sect { OCCUR2(ADR2, 0, 1) }
1200 | addr_city_sect { OCCUR2(CITY, 0, 1) }
1201 | addr_stae_sect { OCCUR2(STAE, 0, 1) }
1202 | addr_post_sect { OCCUR2(POST, 0, 1) }
1203 | addr_ctry_sect { OCCUR2(CTRY, 0, 1) }
1207 addr_cont_sect : OPEN DELIM TAG_CONT mand_line_item
1208 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1210 addr_adr1_sect : OPEN DELIM TAG_ADR1 mand_line_item
1211 { START(ADR1, NULL) } no_std_subs { CHECK0 } CLOSE { }
1213 addr_adr2_sect : OPEN DELIM TAG_ADR2 mand_line_item
1214 { START(ADR2, NULL) } no_std_subs { CHECK0 } CLOSE { }
1216 addr_city_sect : OPEN DELIM TAG_CITY mand_line_item
1217 { START(CITY, NULL) } no_std_subs { CHECK0 } CLOSE { }
1219 addr_stae_sect : OPEN DELIM TAG_STAE mand_line_item
1220 { START(STAE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1222 addr_post_sect : OPEN DELIM TAG_POST mand_line_item
1223 { START(POST, NULL) } no_std_subs { CHECK0 } CLOSE { }
1225 addr_ctry_sect : OPEN DELIM TAG_CTRY mand_line_item
1226 { START(CTRY, NULL) } no_std_subs { CHECK0 } CLOSE { }
1229 phon_sect : OPEN DELIM TAG_PHON mand_line_item
1230 { START(PHON, NULL) } no_std_subs { CHECK0 } CLOSE { }
1233 /* ASSOCIATION STRUCTURE */
1234 assoc_struc_sub : asso_sect /* 0:M */
1237 asso_sect : OPEN DELIM TAG_ASSO mand_pointer
1238 { START(ASSO, NULL) }
1240 { CHECK2(TYPE,RELA) }
1244 asso_subs : /* empty */
1245 | asso_type_sect { OCCUR2(TYPE, 1, 1) }
1246 | asso_rela_sect { OCCUR2(RELA, 1, 1) }
1252 asso_type_sect : OPEN DELIM TAG_TYPE mand_line_item
1253 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1256 asso_rela_sect : OPEN DELIM TAG_RELA mand_line_item
1257 { START(RELA, NULL) } no_std_subs { CHECK0 } CLOSE { }
1261 change_date_sub : change_date_chan_sect { OCCUR2(CHAN, 0, 1) }
1264 change_date_chan_sect : OPEN DELIM TAG_CHAN
1265 { START(CHAN, NULL) }
1266 change_date_chan_subs
1271 change_date_chan_subs : /* empty */
1272 | change_date_chan_subs change_date_chan_sub
1275 change_date_chan_sub : change_date_date_sect { OCCUR2(DATE, 1, 1) }
1280 change_date_date_sect : OPEN DELIM TAG_DATE mand_line_item
1281 { START(DATE, NULL) }
1282 change_date_date_subs
1287 change_date_date_subs : /* empty */
1288 | change_date_date_subs change_date_date_sub
1291 change_date_date_sub : change_date_date_time_sect { OCCUR2(TIME, 0, 1) }
1295 change_date_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
1296 { START(TIME, NULL) } no_std_subs { CHECK0 } CLOSE { }
1299 /* CHILD TO FAMILY LINK */
1300 chi_fam_link_sub : famc_sect /* 0:M */
1303 famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1304 { START(FAMC, NULL) }
1310 famc_subs : /* empty */
1311 | famc_subs famc_sub
1314 famc_sub : famc_pedi_sect /* 0:M */
1319 famc_pedi_sect : OPEN DELIM TAG_PEDI mand_line_item
1320 { START(PEDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
1323 /* CONTINUATION SUBSECTIONS */
1324 continuation_sub : cont_sect /* 0:M */
1325 | conc_sect /* 0:M */
1328 cont_sect : OPEN DELIM TAG_CONT mand_line_item
1329 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1332 conc_sect : OPEN DELIM TAG_CONC mand_line_item
1333 { START(CONC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1337 event_detail_sub : event_detail_type_sect { OCCUR2(TYPE, 0, 1) }
1338 | event_detail_date_sect { OCCUR2(DATE, 0, 1) }
1341 | event_detail_age_sect { OCCUR2(AGE, 0, 1) }
1342 | event_detail_agnc_sect { OCCUR2(AGNC, 0, 1) }
1343 | event_detail_caus_sect { OCCUR2(CAUS, 0, 1) }
1349 event_detail_type_sect : OPEN DELIM TAG_TYPE mand_line_item
1350 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1352 event_detail_date_sect : OPEN DELIM TAG_DATE mand_line_item
1353 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1355 event_detail_age_sect : OPEN DELIM TAG_AGE mand_line_item
1356 { START(AGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1358 event_detail_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item
1359 { START(AGNC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1361 event_detail_caus_sect : OPEN DELIM TAG_CAUS mand_line_item
1362 { START(CAUS, NULL) } no_std_subs { CHECK0 } CLOSE { }
1365 /* FAMILY EVENT STRUCTURE */
1366 fam_event_struc_sub : fam_event_sect
1367 | fam_gen_even_sect /* 0:M */
1370 fam_event_sect : OPEN DELIM fam_event_tag opt_value fam_event_subs
1375 fam_event_tag : TAG_ANUL { START(ANUL, NULL) }
1376 | TAG_CENS { START(CENS, NULL) }
1377 | TAG_DIV { START(DIV, NULL) }
1378 | TAG_DIVF { START(DIVF, NULL) }
1379 | TAG_ENGA { START(ENGA, NULL) }
1380 | TAG_MARR { START(MARR, NULL) }
1381 | TAG_MARB { START(MARB, NULL) }
1382 | TAG_MARC { START(MARC, NULL) }
1383 | TAG_MARL { START(MARL, NULL) }
1384 | TAG_MARS { START(MARS, NULL) }
1387 fam_event_subs : /* empty */
1388 | fam_event_subs fam_event_sub
1391 fam_event_sub : event_detail_sub
1392 | fam_even_husb_sect { OCCUR2(HUSB, 0, 1) }
1393 | fam_even_wife_sect { OCCUR2(WIFE, 0, 1) }
1397 fam_even_husb_sect : OPEN DELIM TAG_HUSB
1398 { START(HUSB, NULL) }
1404 fam_even_husb_subs : /* empty */
1405 | fam_even_husb_subs fam_even_husb_sub
1408 fam_even_husb_sub : fam_even_husb_age_sect { OCCUR2(AGE, 1, 1) }
1412 fam_even_husb_age_sect : OPEN DELIM TAG_AGE mand_line_item
1413 { START(AGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1416 fam_even_wife_sect : OPEN DELIM TAG_WIFE
1417 { START(HUSB, NULL) }
1423 fam_gen_even_sect : OPEN DELIM TAG_EVEN
1424 { START(EVEN, NULL) }
1430 fam_gen_even_subs : /* empty */
1431 | fam_gen_even_subs fam_gen_even_sub
1434 fam_gen_even_sub : event_detail_sub
1435 | fam_even_husb_sect { OCCUR2(HUSB, 0, 1) }
1436 | fam_even_wife_sect { OCCUR2(WIFE, 0, 1) }
1440 /* IDENTIFICATION STRUCTURE */
1441 ident_struc_sub : ident_refn_sect /* 0:M */
1442 | ident_rin_sect { OCCUR2(RIN, 0, 1) }
1445 ident_refn_sect : OPEN DELIM TAG_REFN mand_line_item
1446 { START(REFN, NULL) }
1452 ident_refn_subs : /* empty */
1453 | ident_refn_subs ident_refn_sub
1456 ident_refn_sub : ident_refn_type_sect { OCCUR2(TYPE, 0, 1) }
1460 ident_refn_type_sect : OPEN DELIM TAG_TYPE mand_line_item
1461 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1464 ident_rin_sect : OPEN DELIM TAG_RIN mand_line_item
1465 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1468 /* INDIVIDUAL ATTRIBUTE STRUCTURE */
1469 indiv_attr_struc_sub : indiv_cast_sect /* 0:M */
1470 | indiv_dscr_sect /* 0:M */
1471 | indiv_educ_sect /* 0:M */
1472 | indiv_idno_sect /* 0:M */
1473 | indiv_nati_sect /* 0:M */
1474 | indiv_nchi_sect /* 0:M */
1475 | indiv_nmr_sect /* 0:M */
1476 | indiv_occu_sect /* 0:M */
1477 | indiv_prop_sect /* 0:M */
1478 | indiv_reli_sect /* 0:M */
1479 | indiv_resi_sect /* 0:M */
1480 | indiv_ssn_sect /* 0:M */
1481 | indiv_titl_sect /* 0:M */
1484 indiv_cast_sect : OPEN DELIM TAG_CAST mand_line_item
1485 { START(CAST, NULL) }
1486 indiv_attr_event_subs
1490 indiv_dscr_sect : OPEN DELIM TAG_DSCR mand_line_item
1491 { START(DSCR, NULL) }
1492 indiv_attr_event_subs
1496 indiv_educ_sect : OPEN DELIM TAG_EDUC mand_line_item
1497 { START(EDUC, NULL) }
1498 indiv_attr_event_subs
1502 indiv_idno_sect : OPEN DELIM TAG_IDNO mand_line_item
1503 { START(IDNO, NULL) }
1504 indiv_attr_event_subs
1508 indiv_nati_sect : OPEN DELIM TAG_NATI mand_line_item
1509 { START(NATI, NULL) }
1510 indiv_attr_event_subs
1514 indiv_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
1515 { START(NCHI, NULL) }
1516 indiv_attr_event_subs
1520 indiv_nmr_sect : OPEN DELIM TAG_NMR mand_line_item
1521 { START(NMR, NULL) }
1522 indiv_attr_event_subs
1526 indiv_occu_sect : OPEN DELIM TAG_OCCU mand_line_item
1527 { START(OCCU, NULL) }
1528 indiv_attr_event_subs
1532 indiv_prop_sect : OPEN DELIM TAG_PROP mand_line_item
1533 { START(PROP, NULL) }
1534 indiv_attr_event_subs
1538 indiv_reli_sect : OPEN DELIM TAG_RELI mand_line_item
1539 { START(RELI, NULL) }
1540 indiv_attr_event_subs
1544 indiv_resi_sect : OPEN DELIM TAG_RESI
1545 { START(RESI, NULL) }
1546 indiv_attr_event_subs
1550 indiv_ssn_sect : OPEN DELIM TAG_SSN mand_line_item
1551 { START(SSN, NULL) }
1552 indiv_attr_event_subs
1556 indiv_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1557 { START(TITL, NULL) }
1558 indiv_attr_event_subs
1563 indiv_attr_event_subs : /* empty */
1564 | indiv_attr_event_subs indiv_attr_event_sub
1567 indiv_attr_event_sub : event_detail_sub
1571 /* INDIVIDUAL EVENT STRUCTURE */
1572 indiv_even_struc_sub : indiv_birt_sect
1574 | indiv_adop_sect /* 0:M */
1575 | indiv_even_sect /* 0:M */
1578 indiv_birt_sect : OPEN DELIM indiv_birt_tag opt_value indiv_birt_subs
1583 indiv_birt_tag : TAG_BIRT { START(BIRT, NULL) }
1584 | TAG_CHR { START(CHR, NULL) }
1587 indiv_birt_subs : /* empty */
1588 | indiv_birt_subs indiv_birt_sub
1591 indiv_birt_sub : event_detail_sub
1592 | indiv_birt_famc_sect { OCCUR2(FAMC,0, 1) }
1596 indiv_birt_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1597 { START(FAMC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1600 indiv_gen_sect : OPEN DELIM indiv_gen_tag opt_value indiv_gen_subs
1605 indiv_gen_tag : TAG_DEAT { START(DEAT, NULL) }
1606 | TAG_BURI { START(BURI, NULL) }
1607 | TAG_CREM { START(CREM, NULL) }
1608 | TAG_BAPM { START(BAPM, NULL) }
1609 | TAG_BARM { START(BARM, NULL) }
1610 | TAG_BASM { START(BASM, NULL) }
1611 | TAG_BLES { START(BLES, NULL) }
1612 | TAG_CHRA { START(CHRA, NULL) }
1613 | TAG_CONF { START(CONF, NULL) }
1614 | TAG_FCOM { START(FCOM, NULL) }
1615 | TAG_ORDN { START(ORDN, NULL) }
1616 | TAG_NATU { START(NATU, NULL) }
1617 | TAG_EMIG { START(EMIG, NULL) }
1618 | TAG_IMMI { START(IMMI, NULL) }
1619 | TAG_CENS { START(CENS, NULL) }
1620 | TAG_PROB { START(PROB, NULL) }
1621 | TAG_WILL { START(WILL, NULL) }
1622 | TAG_GRAD { START(GRAD, NULL) }
1623 | TAG_RETI { START(RETI, NULL) }
1626 indiv_gen_subs : /* empty */
1627 | indiv_gen_subs indiv_gen_sub
1630 indiv_gen_sub : event_detail_sub
1634 indiv_adop_sect : OPEN DELIM TAG_ADOP opt_value
1635 { START(ADOP, NULL) }
1641 indiv_adop_subs : /* empty */
1642 | indiv_adop_subs indiv_adop_sub
1645 indiv_adop_sub : event_detail_sub
1646 | indiv_adop_famc_sect { OCCUR2(FAMC,0, 1) }
1650 indiv_adop_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1651 { START(FAMC, NULL) }
1652 indiv_adop_famc_subs
1657 indiv_adop_famc_subs : /* empty */
1658 | indiv_adop_famc_subs indiv_adop_famc_sub
1661 indiv_adop_famc_sub : indiv_adop_famc_adop_sect { OCCUR2(ADOP,0, 1) }
1665 indiv_adop_famc_adop_sect : OPEN DELIM TAG_ADOP mand_line_item
1666 { START(ADOP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1669 indiv_even_sect : OPEN DELIM TAG_EVEN
1670 { START(EVEN, NULL) }
1676 /* LDS INDIVIDUAL ORDINANCE */
1677 lds_indiv_ord_sub : lio_bapl_sect /* 0:M */
1678 | lio_slgc_sect /* 0:M */
1681 lio_bapl_sect : OPEN DELIM lio_bapl_tag lio_bapl_subs
1686 lio_bapl_tag : TAG_BAPL { START(BAPL, NULL) }
1687 | TAG_CONL { START(CONL, NULL) }
1688 | TAG_ENDL { START(ENDL, NULL) }
1691 lio_bapl_subs : /* empty */
1692 | lio_bapl_subs lio_bapl_sub
1695 lio_bapl_sub : lio_bapl_stat_sect { OCCUR2(STAT, 0, 1) }
1696 | lio_bapl_date_sect { OCCUR2(DATE, 0, 1) }
1697 | lio_bapl_temp_sect { OCCUR2(TEMP, 0, 1) }
1698 | lio_bapl_plac_sect { OCCUR2(PLAC, 0, 1) }
1704 lio_bapl_stat_sect : OPEN DELIM TAG_STAT mand_line_item
1705 { START(STAT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1707 lio_bapl_date_sect : OPEN DELIM TAG_DATE mand_line_item
1708 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1710 lio_bapl_temp_sect : OPEN DELIM TAG_TEMP mand_line_item
1711 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1713 lio_bapl_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
1714 { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1717 lio_slgc_sect : OPEN DELIM TAG_SLGC
1718 { START(SLGC, NULL) }
1724 lio_slgc_subs : /* empty */
1725 | lio_slgc_subs lio_slgc_sub
1728 lio_slgc_sub : lio_bapl_sub
1729 | lio_slgc_famc_sect { OCCUR2(FAMC, 1, 1) }
1732 lio_slgc_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1733 { START(FAMC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1736 /* LDS SPOUSE SEALING */
1737 lds_spouse_seal_sub : lss_slgs_sect
1740 lss_slgs_sect : OPEN DELIM TAG_SLGS
1741 { START(SLGS, NULL) }
1747 lss_slgs_subs : /* empty */
1748 | lss_slgs_subs lss_slgs_sub
1751 lss_slgs_sub : lss_slgs_stat_sect { OCCUR2(STAT, 0, 1) }
1752 | lss_slgs_date_sect { OCCUR2(DATE, 0, 1) }
1753 | lss_slgs_temp_sect { OCCUR2(TEMP, 0, 1) }
1754 | lss_slgs_plac_sect { OCCUR2(PLAC, 0, 1) }
1760 lss_slgs_stat_sect : OPEN DELIM TAG_STAT mand_line_item
1761 { START(STAT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1763 lss_slgs_date_sect : OPEN DELIM TAG_DATE mand_line_item
1764 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1766 lss_slgs_temp_sect : OPEN DELIM TAG_TEMP mand_line_item
1767 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1769 lss_slgs_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
1770 { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1773 /* MULTIMEDIA LINK */
1774 multim_link_sub : multim_obje_link_sect
1775 | multim_obje_emb_sect
1778 multim_obje_link_sect : OPEN DELIM TAG_OBJE DELIM POINTER
1779 { START(OBJE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1782 multim_obje_emb_sect : OPEN DELIM TAG_OBJE
1783 { START(OBJE, NULL) }
1784 multim_obje_emb_subs
1785 { CHECK2(FORM,FILE) }
1789 multim_obje_emb_subs : /* empty */
1790 | multim_obje_emb_subs multim_obje_emb_sub
1793 multim_obje_emb_sub : multim_obje_form_sect { OCCUR2(FORM, 1, 1) }
1794 | multim_obje_titl_sect { OCCUR2(TITL, 0, 1) }
1795 | multim_obje_file_sect { OCCUR2(FILE, 1, 1) }
1800 multim_obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
1801 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
1803 multim_obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1804 { START(TITL, NULL) } no_std_subs { CHECK0 } CLOSE { }
1806 multim_obje_file_sect : OPEN DELIM TAG_FILE mand_line_item
1807 { START(FILE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1810 /* NOTE STRUCTURE */
1811 note_struc_sub : note_struc_link_sect /* 0:M */
1812 | note_struc_emb_sect /* 0:M */
1815 note_struc_link_sect : OPEN DELIM TAG_NOTE DELIM POINTER
1816 { START(NOTE, NULL) }
1817 note_struc_link_subs
1822 note_struc_link_subs : /* empty */
1823 | note_struc_link_subs note_struc_link_sub
1826 note_struc_link_sub : source_cit_sub
1830 note_struc_emb_sect : OPEN DELIM TAG_NOTE opt_line_item
1831 { START(NOTE, NULL) }
1837 note_struc_emb_subs : /* empty */
1838 | note_struc_emb_subs note_struc_emb_sub
1841 note_struc_emb_sub : continuation_sub
1846 /* PERSONAL NAME STRUCTURE */
1847 pers_name_struc_sub : pers_name_sect /* 0:M */
1850 pers_name_sect : OPEN DELIM TAG_NAME mand_line_item
1851 { START(NAME, NULL) }
1857 pers_name_subs : /* empty */
1858 | pers_name_subs pers_name_sub
1861 pers_name_sub : pers_name_npfx_sect { OCCUR2(NPFX, 0, 1) }
1862 | pers_name_givn_sect { OCCUR2(GIVN, 0, 1) }
1863 | pers_name_nick_sect { OCCUR2(NICK, 0, 1) }
1864 | pers_name_spfx_sect { OCCUR2(SPFX, 0, 1) }
1865 | pers_name_surn_sect { OCCUR2(SURN, 0, 1) }
1866 | pers_name_nsfx_sect { OCCUR2(NSFX, 0, 1) }
1872 pers_name_npfx_sect : OPEN DELIM TAG_NPFX mand_line_item
1873 { START(NPFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
1875 pers_name_givn_sect : OPEN DELIM TAG_GIVN mand_line_item
1876 { START(GIVN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1878 pers_name_nick_sect : OPEN DELIM TAG_NICK mand_line_item
1879 { START(NICK, NULL) } no_std_subs { CHECK0 } CLOSE { }
1881 pers_name_spfx_sect : OPEN DELIM TAG_SPFX mand_line_item
1882 { START(SPFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
1884 pers_name_surn_sect : OPEN DELIM TAG_SURN mand_line_item
1885 { START(SURN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1887 pers_name_nsfx_sect : OPEN DELIM TAG_NSFX mand_line_item
1888 { START(NSFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
1891 /* PLACE STRUCTURE */
1892 place_struc_sub : place_struc_plac_sect /* 0:M */
1895 place_struc_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
1896 { START(PLAC, NULL) }
1897 place_struc_plac_subs
1902 place_struc_plac_subs : /* empty */
1903 | place_struc_plac_subs place_struc_plac_sub
1906 place_struc_plac_sub : place_plac_form_sect { OCCUR2(FORM, 0, 1) }
1912 place_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item
1913 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
1916 /* SOURCE_CITATION */
1917 source_cit_sub : source_cit_link_sect /* 0:M */
1918 | source_cit_emb_sect /* 0:M */
1921 source_cit_link_sect : OPEN DELIM TAG_SOUR DELIM POINTER
1922 { START(SOUR, NULL) }
1923 source_cit_link_subs
1928 source_cit_link_subs : /* empty */
1929 | source_cit_link_subs source_cit_link_sub
1932 source_cit_link_sub : source_cit_page_sect { OCCUR2(PAGE, 0, 1) }
1933 | source_cit_even_sect { OCCUR2(EVEN, 0, 1) }
1934 | source_cit_data_sect { OCCUR2(DATA, 0, 1) }
1935 | source_cit_quay_sect { OCCUR2(QUAY, 0, 1) }
1941 source_cit_page_sect : OPEN DELIM TAG_PAGE mand_line_item
1942 { START(PAGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1945 source_cit_even_sect : OPEN DELIM TAG_EVEN mand_line_item
1946 { START(EVEN, NULL) }
1947 source_cit_even_subs
1952 source_cit_even_subs : /* empty */
1953 | source_cit_even_subs source_cit_even_sub
1956 source_cit_even_sub : source_cit_even_role_sect { OCCUR2(ROLE, 0, 1) }
1960 source_cit_even_role_sect : OPEN DELIM TAG_ROLE mand_line_item
1961 { START(ROLE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1964 source_cit_data_sect : OPEN DELIM TAG_DATA
1965 { START(DATA, NULL) }
1966 source_cit_data_subs
1971 source_cit_data_subs : /* empty */
1972 | source_cit_data_subs source_cit_data_sub
1975 source_cit_data_sub : source_cit_data_date_sect { OCCUR2(DATE, 0, 1) }
1976 | source_cit_text_sect /* 0:M */
1980 source_cit_data_date_sect : OPEN DELIM TAG_DATE mand_line_item
1981 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1984 source_cit_text_sect : OPEN DELIM TAG_TEXT mand_line_item
1985 { START(TEXT, NULL) }
1986 source_cit_text_subs
1991 source_cit_text_subs : /* empty */
1992 | source_cit_text_subs source_cit_text_sub
1995 source_cit_text_sub : continuation_sub
1999 source_cit_quay_sect : OPEN DELIM TAG_QUAY mand_line_item
2000 { START(QUAY, NULL) } no_std_subs { CHECK0 } CLOSE { }
2003 source_cit_emb_sect : OPEN DELIM TAG_SOUR mand_line_item
2004 { START(SOUR, NULL) }
2010 source_cit_emb_subs : /* empty */
2011 | source_cit_emb_subs source_cit_emb_sub
2014 source_cit_emb_sub : continuation_sub
2015 | source_cit_text_sect /* 0:M */
2020 /* SOURCE REPOSITORY CITATION */
2021 source_repos_cit_sub : source_repos_repo_sect { OCCUR2(REPO, 0, 1) }
2024 source_repos_repo_sect : OPEN DELIM TAG_REPO mand_pointer
2025 { START(REPO, NULL) }
2026 source_repos_repo_subs
2031 source_repos_repo_subs : /* empty */
2032 | source_repos_repo_subs source_repos_repo_sub
2035 source_repos_repo_sub : note_struc_sub
2036 | caln_sect /* 0:M */
2040 caln_sect : OPEN DELIM TAG_CALN mand_line_item
2041 { START(CALN, NULL) }
2047 caln_subs : /* empty */
2048 | caln_subs caln_sub
2051 caln_sub : caln_medi_sect { OCCUR2(MEDI, 0, 1) }
2055 caln_medi_sect : OPEN DELIM TAG_MEDI mand_line_item
2056 { START(MEDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
2059 /* SPOUSE TO FAMILY LINK */
2060 spou_fam_link_sub : spou_fam_fams_sect /* 0:M */
2063 spou_fam_fams_sect : OPEN DELIM TAG_FAMS mand_pointer
2064 { START(FAMS, NULL) }
2070 spou_fam_fams_subs : /* empty */
2071 | spou_fam_fams_subs spou_fam_fams_sub
2074 spou_fam_fams_sub : note_struc_sub
2078 /*********************************************************************/
2080 /*********************************************************************/
2082 no_std_subs : /* empty */
2083 | no_std_subs no_std_sub
2086 no_std_sub : user_sect /* 0:M */
2088 | error error_subs CLOSE { HANDLE_ERROR }
2091 no_std_rec : user_rec /* 0:M */
2093 | error error_subs CLOSE { HANDLE_ERROR }
2096 user_rec : OPEN DELIM opt_xref USERTAG
2097 { if ($4[0] != '_') {
2098 gedcom_error("Undefined tag (and not a valid user tag): %s",
2103 opt_value user_sects CLOSE { }
2106 user_sect : OPEN DELIM opt_xref USERTAG
2107 { if ($4[0] != '_') {
2108 gedcom_error("Undefined tag (and not a valid user tag): %s",
2113 opt_value user_sects CLOSE { }
2116 user_sects : /* empty */ { }
2117 | user_sects user_sect { }
2120 opt_xref : /* empty */ { }
2124 opt_value : /* empty */ { }
2125 | DELIM line_value { }
2128 line_value : POINTER { }
2132 mand_pointer : /* empty */ { gedcom_error("Missing pointer"); YYERROR; }
2136 mand_line_item : /* empty */ { gedcom_error("Missing value"); YYERROR; }
2137 | DELIM line_item { gedcom_debug_print("==Val: %s==\n", $2);
2141 opt_line_item : /* empty */ { }
2142 | DELIM line_item { }
2145 line_item : anychar { size_t i;
2146 CLEAR_BUFFER(line_item_buf);
2147 line_item_buf_ptr = line_item_buf;
2148 /* The following also takes care of '@@' */
2149 if (!strncmp($1, "@@", 3))
2150 *line_item_buf_ptr++ = '@';
2152 for (i=0; i < strlen($1); i++)
2153 *line_item_buf_ptr++ = $1[i];
2156 | ESCAPE { CLEAR_BUFFER(line_item_buf);
2157 line_item_buf_ptr = line_item_buf;
2158 /* For now, ignore escapes */
2163 /* The following also takes care of '@@' */
2164 if (!strncmp($2, "@@", 3))
2165 *line_item_buf_ptr++ = '@';
2167 for (i=0; i < strlen($2); i++)
2168 *line_item_buf_ptr++ = $2[i];
2172 { /* For now, ignore escapes */
2177 anychar : ANYCHAR { }
2181 error_subs : /* empty */
2182 | error_subs error_sect
2185 error_sect : OPEN DELIM opt_xref anytag opt_value error_subs CLOSE { }
2187 gen_sect : OPEN DELIM opt_xref anystdtag
2188 { INVALID_TAG($4); }
2189 opt_value opt_sects CLOSE
2193 gen_rec : gen_rec_top
2197 gen_rec_norm : OPEN DELIM opt_xref anystdtag
2198 { INVALID_TOP_TAG($4) }
2199 opt_value opt_sects CLOSE
2203 gen_rec_top : OPEN DELIM anytoptag
2204 { gedcom_error("Missing cross-reference"); YYERROR; }
2205 opt_value opt_sects CLOSE
2209 opt_sects : /* empty */ { }
2210 | opt_sects gen_sect { }
2213 anytag : USERTAG { }
2227 anystdtag : TAG_ABBR
2357 /* Functions that handle the counting of subtags */
2359 int* count_arrays[MAXGEDCLEVEL+1];
2360 char tag_stack[MAXGEDCLEVEL+1][MAXSTDTAGLEN+1];
2361 Gedcom_ctxt ctxt_stack[MAXGEDCLEVEL+1];
2363 void push_countarray()
2366 if (count_level > MAXGEDCLEVEL) {
2367 gedcom_error("Internal error: count array overflow");
2371 count = (int *)calloc(YYNTOKENS, sizeof(int));
2372 if (count == NULL) {
2373 gedcom_error("Internal error: count array calloc error");
2377 count_arrays[count_level] = count;
2382 void set_parenttag(char* tag)
2384 strncpy(tag_stack[count_level], tag, MAXSTDTAGLEN+1);
2387 void set_parentctxt(Gedcom_ctxt ctxt)
2389 ctxt_stack[count_level] = ctxt;
2392 char* get_parenttag()
2394 return tag_stack[count_level];
2397 Gedcom_ctxt get_parentctxt()
2399 return ctxt_stack[count_level];
2402 int count_tag(int tag)
2404 int *count = count_arrays[count_level];
2405 return ++count[tag - GEDCOMTAGOFFSET];
2408 int check_occurrence(int tag)
2410 int *count = count_arrays[count_level];
2411 return (count[tag - GEDCOMTAGOFFSET] > 0);
2414 void pop_countarray()
2417 if (count_level < 0) {
2418 gedcom_error("Internal error: count array underflow");
2422 count = count_arrays[count_level];
2424 count_arrays[count_level] = NULL;
2428 /* Enabling debug mode */
2429 /* level 0: no debugging */
2430 /* level 1: only internal */
2431 /* level 2: also bison */
2434 void gedcom_set_debug_level(int level, FILE* f)
2439 trace_output = stderr;
2441 gedcom_high_level_debug = 1;
2450 int gedcom_debug_print(char* s, ...)
2453 if (gedcom_high_level_debug) {
2456 res = vfprintf(trace_output, s, ap);
2462 /* Setting the error mechanism */
2463 void gedcom_set_error_handling(Gedcom_err_mech mechanism)
2465 error_mechanism = mechanism;
2468 /* Compatibility handling */
2470 void gedcom_set_compat_handling(int enable_compat)
2472 compat_enabled = enable_compat;
2475 void set_compatibility(char* program)
2477 if (compat_enabled) {
2478 gedcom_debug_print("==== Program: %s\n", program);
2479 if (! strncmp(program, "ftree", 6)) {
2480 gedcom_warning("Enabling compatibility with 'ftree'");
2481 compatibility = C_FTREE;
2489 int compat_mode(int compat_flags)
2491 return (compat_flags & compatibility);