2 Copyright (C) 2001 The Genes Development Team
3 This file is part of the Gedcom parser library.
4 Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
6 The Gedcom parser library is free software; you can redistribute it
7 and/or modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The Gedcom parser library is distributed in the hope that it will be
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the Gedcom parser library; if not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 /* WARNING: THIS PARSER RELIES HEAVILY ON SOME FEATURES OF BISON.
25 DON'T TRY TO USE IT WITH YACC, IT WON'T WORK...
28 /* Design of the parser:
30 In general, a GEDCOM file contains records, each consisting of a line
31 (which we'll call a section), hierarchically containing other lines
32 (subsections of the section).
34 This means that in general we have:
36 A 'record' is a 'section' (sect) containing 'subsections' (subs)
37 Each 'subsection' (sub) is again a specific 'section' (sect)
39 In parser notation, this means:
43 sect : <some prefix> subs <some suffix>
45 subs : <empty> | subs sub
47 sub : sect_a | sect_b | ...
49 This pattern is repeated throughout the parser for the different types of
53 Cardinality of the subsections:
54 -------------------------------
55 Note that in the above, the order of the subsections is of no importance.
56 Indeed, this is the case in the GEDCOM grammar. However, this also makes
57 it difficult to check whether there are not too many subsections of a
58 specific type, or whether a mandatory subsection is indeed there.
60 Suppose there is a section A that can contain 0 or 1 B section and
63 This can be expressed in parser notation as follows:
65 A : CC | BCC | CBC | CCB
67 So, cardinality is indeed expressable. However, as the number of subsection
68 types and the limits grow bigger (and even theoretically limitless), listing
69 all possible permutations becomes quickly unfeasible.
71 Much simpler is to say:
74 subs : <empty> | subs sub
77 and then check the cardinality in the semantic actions, which is the
78 solution chosen in the parser below, using the following macros:
81 Make a new context for the <parent> tag to count child tags in
83 - OCCUR2(<child>, <min>, <max>)
84 Express that the <child> tag should occur at least <min> times and
85 at most <max> tags within its parent
87 What this actually does is the following. It increments the counter
88 for that tag and then checks whether the maximum is exceeded. If so,
89 then a parser error is produced. The minimum is not actually checked
90 by this macro, but it makes the statements more declarative.
92 - OCCUR1(<child>, <min>)
93 Express that the <child> tag should occur at least <min> times within
94 its parent (no upper limit)
96 Actually, this only increments the counter for the tag, but it looks
97 very like the previous macro.
99 If the minimum is 0, it is not necessary to express this constraint.
101 - CHECKn(<child1>, ..., <childn>)
102 This closes the context for the parent tag and checks whether the
103 given <child> tags did effectively occur within the parent (i.e.
104 these are the tags that were mandatory).
106 Since the <min> values above are always 0 or 1 in GEDCOM, this is
107 sufficient. All sub-tags that declare a minimum of 1 in the OCCUR
108 macros should be listed in this macro here.
110 The macros CHECK0 to CHECK4 are defined like this (the first one
111 has no arguments and is only used to close the parent context; note
112 that this is necessary for correct functioning).
116 Only sections that have subsections need to use these macros. This can
117 be done like this (the OPEN and CHECK macros are used as mid-rule
118 actions around the subsections):
120 head_sect : OPEN DELIM TAG_HEAD
124 CLOSE { <semantic actions> }
130 head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) }
131 | head_dest_sect { OCCUR2(DEST, 0, 1) }
132 | head_date_sect { OCCUR2(DATE, 0, 1) }
138 - The syntax analysis doesn't handle the contents of the line values;
139 this is done in the semantic analysis.
144 #include "gedcom_internal.h"
145 #include "multilex.h"
146 #include "encoding.h"
147 #include "interface.h"
151 int compat_enabled = 1;
152 int gedcom_high_level_debug = 0;
153 int compatibility = 0;
154 Gedcom_err_mech error_mechanism = IMMED_FAIL;
156 char line_item_buf[MAXGEDCLINELEN * UTF_FACTOR + 1];
157 char *line_item_buf_ptr;
163 /* These are defined at the bottom of the file */
164 void push_countarray();
165 void set_parenttag(char* tag);
166 char* get_parenttag();
167 void set_parentctxt(Gedcom_ctxt ctxt);
168 Gedcom_ctxt get_parentctxt();
169 void pop_countarray();
170 int count_tag(int tag);
171 int check_occurrence(int tag);
172 void set_compatibility(char* program);
173 int compat_mode(int flags);
175 #define CLEAR_BUFFER(BUF) \
176 memset(BUF, 0, sizeof(BUF));
178 #define HANDLE_ERROR \
179 { if (error_mechanism == IMMED_FAIL) { \
182 else if (error_mechanism == DEFER_FAIL) { \
185 else if (error_mechanism == IGNORE_ERRORS) { \
189 #define START(PARENTTAG,PARENTCTXT) \
191 set_parenttag(#PARENTTAG); \
192 set_parentctxt(PARENTCTXT); \
198 { if (!check_occurrence(TAG_##TAG)) { \
199 char* parenttag = get_parenttag(); \
200 gedcom_error(_("The tag '%s' is mandatory within '%s', but missing"),\
206 { pop_countarray(); \
210 #define CHECK1(TAG1) { CHK(TAG1); POP; }
211 #define CHECK2(TAG1,TAG2) \
212 { CHK(TAG1); CHK(TAG2); POP; }
213 #define CHECK3(TAG1,TAG2,TAG3) \
214 { CHK(TAG1); CHK(TAG2); CHK(TAG3); POP; }
215 #define CHECK4(TAG1,TAG2,TAG3,TAG4) \
216 { CHK(TAG1); CHK(TAG2); CHK(TAG3); CHK(TAG4); POP; }
217 #define OCCUR1(CHILDTAG, MIN) { count_tag(TAG_##CHILDTAG); }
218 #define OCCUR2(CHILDTAG, MIN, MAX) \
219 { int num = count_tag(TAG_##CHILDTAG); \
221 char* parenttag = get_parenttag(); \
222 gedcom_error(_("The tag '%s' can maximally occur %d time(s) within '%s'"), \
223 #CHILDTAG, MAX, parenttag); \
227 #define INVALID_TAG(CHILDTAG) \
228 { char* parenttag = get_parenttag(); \
229 gedcom_error(_("The tag '%s' is not a valid tag within '%s'"), \
230 CHILDTAG, parenttag); \
233 #define INVALID_TOP_TAG(CHILDTAG) \
234 { gedcom_error(_("The tag '%s' is not a valid top-level tag"), \
250 %token <string> BADTOKEN
252 %token <string> CLOSE
253 %token <string> ESCAPE
254 %token <string> DELIM
255 %token <string> ANYCHAR
256 %token <string> POINTER
257 %token <string> USERTAG
258 %token <string> TAG_ABBR
259 %token <string> TAG_ADDR
260 %token <string> TAG_ADR1
261 %token <string> TAG_ADR2
262 %token <string> TAG_ADOP
263 %token <string> TAG_AFN
264 %token <string> TAG_AGE
265 %token <string> TAG_AGNC
266 %token <string> TAG_ALIA
267 %token <string> TAG_ANCE
268 %token <string> TAG_ANCI
269 %token <string> TAG_ANUL
270 %token <string> TAG_ASSO
271 %token <string> TAG_AUTH
272 %token <string> TAG_BAPL
273 %token <string> TAG_BAPM
274 %token <string> TAG_BARM
275 %token <string> TAG_BASM
276 %token <string> TAG_BIRT
277 %token <string> TAG_BLES
278 %token <string> TAG_BLOB
279 %token <string> TAG_BURI
280 %token <string> TAG_CALN
281 %token <string> TAG_CAST
282 %token <string> TAG_CAUS
283 %token <string> TAG_CENS
284 %token <string> TAG_CHAN
285 %token <string> TAG_CHAR
286 %token <string> TAG_CHIL
287 %token <string> TAG_CHR
288 %token <string> TAG_CHRA
289 %token <string> TAG_CITY
290 %token <string> TAG_CONC
291 %token <string> TAG_CONF
292 %token <string> TAG_CONL
293 %token <string> TAG_CONT
294 %token <string> TAG_COPR
295 %token <string> TAG_CORP
296 %token <string> TAG_CREM
297 %token <string> TAG_CTRY
298 %token <string> TAG_DATA
299 %token <string> TAG_DATE
300 %token <string> TAG_DEAT
301 %token <string> TAG_DESC
302 %token <string> TAG_DESI
303 %token <string> TAG_DEST
304 %token <string> TAG_DIV
305 %token <string> TAG_DIVF
306 %token <string> TAG_DSCR
307 %token <string> TAG_EDUC
308 %token <string> TAG_EMIG
309 %token <string> TAG_ENDL
310 %token <string> TAG_ENGA
311 %token <string> TAG_EVEN
312 %token <string> TAG_FAM
313 %token <string> TAG_FAMC
314 %token <string> TAG_FAMF
315 %token <string> TAG_FAMS
316 %token <string> TAG_FCOM
317 %token <string> TAG_FILE
318 %token <string> TAG_FORM
319 %token <string> TAG_GEDC
320 %token <string> TAG_GIVN
321 %token <string> TAG_GRAD
322 %token <string> TAG_HEAD
323 %token <string> TAG_HUSB
324 %token <string> TAG_IDNO
325 %token <string> TAG_IMMI
326 %token <string> TAG_INDI
327 %token <string> TAG_LANG
328 %token <string> TAG_LEGA
329 %token <string> TAG_MARB
330 %token <string> TAG_MARC
331 %token <string> TAG_MARL
332 %token <string> TAG_MARR
333 %token <string> TAG_MARS
334 %token <string> TAG_MEDI
335 %token <string> TAG_NAME
336 %token <string> TAG_NATI
337 %token <string> TAG_NATU
338 %token <string> TAG_NCHI
339 %token <string> TAG_NICK
340 %token <string> TAG_NMR
341 %token <string> TAG_NOTE
342 %token <string> TAG_NPFX
343 %token <string> TAG_NSFX
344 %token <string> TAG_OBJE
345 %token <string> TAG_OCCU
346 %token <string> TAG_ORDI
347 %token <string> TAG_ORDN
348 %token <string> TAG_PAGE
349 %token <string> TAG_PEDI
350 %token <string> TAG_PHON
351 %token <string> TAG_PLAC
352 %token <string> TAG_POST
353 %token <string> TAG_PROB
354 %token <string> TAG_PROP
355 %token <string> TAG_PUBL
356 %token <string> TAG_QUAY
357 %token <string> TAG_REFN
358 %token <string> TAG_RELA
359 %token <string> TAG_RELI
360 %token <string> TAG_REPO
361 %token <string> TAG_RESI
362 %token <string> TAG_RESN
363 %token <string> TAG_RETI
364 %token <string> TAG_RFN
365 %token <string> TAG_RIN
366 %token <string> TAG_ROLE
367 %token <string> TAG_SEX
368 %token <string> TAG_SLGC
369 %token <string> TAG_SLGS
370 %token <string> TAG_SOUR
371 %token <string> TAG_SPFX
372 %token <string> TAG_SSN
373 %token <string> TAG_STAE
374 %token <string> TAG_STAT
375 %token <string> TAG_SUBM
376 %token <string> TAG_SUBN
377 %token <string> TAG_SURN
378 %token <string> TAG_TEMP
379 %token <string> TAG_TEXT
380 %token <string> TAG_TIME
381 %token <string> TAG_TITL
382 %token <string> TAG_TRLR
383 %token <string> TAG_TYPE
384 %token <string> TAG_VERS
385 %token <string> TAG_WIFE
386 %token <string> TAG_WILL
388 %type <string> anystdtag
389 %type <string> anytoptag
390 %type <string> line_item
391 %type <string> line_value
392 %type <string> mand_line_item
393 %type <string> mand_pointer
394 %type <string> note_line_item
395 %type <string> anychar
396 %type <string> opt_xref
397 %type <string> opt_value
398 %type <ctxt> head_sect
402 file : head_sect records trlr_sect
403 { if (fail == 1) YYABORT; }
406 records : /* empty */
421 /*********************************************************************/
423 /*********************************************************************/
424 head_sect : OPEN DELIM TAG_HEAD
425 { $<ctxt>$ = start_record(REC_HEAD, $1, NULL, $3);
426 START(HEAD, $<ctxt>$) }
428 { if (compat_mode(C_FTREE))
429 CHECK3(SOUR, GEDC, CHAR)
431 CHECK4(SOUR, SUBM, GEDC, CHAR)
434 { end_record(REC_HEAD, $<ctxt>4); }
437 head_subs : /* empty */
441 head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) }
442 | head_dest_sect { OCCUR2(DEST, 0, 1) }
443 | head_date_sect { OCCUR2(DATE, 0, 1) }
444 | head_subm_sect { OCCUR2(SUBM, 1, 1) }
445 | head_subn_sect { OCCUR2(SUBN, 0, 1) }
446 | head_file_sect { OCCUR2(FILE, 0, 1) }
447 | head_copr_sect { OCCUR2(COPR, 0, 1) }
448 | head_gedc_sect { OCCUR2(GEDC, 1, 1) }
449 | head_char_sect { OCCUR2(CHAR, 1, 1) }
450 | head_lang_sect { OCCUR2(LANG, 0, 1) }
451 | head_plac_sect { OCCUR2(PLAC, 0, 1) }
452 | head_note_sect { OCCUR2(NOTE, 0, 1) }
457 head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item
458 { set_compatibility($4);
459 $<ctxt>$ = start_element(ELT_HEAD_SOUR, PARENT,
461 START(SOUR, $<ctxt>$)
466 { end_element(ELT_HEAD_SOUR, PARENT, $<ctxt>5, NULL); }
469 head_sour_subs : /* empty */
470 | head_sour_subs head_sour_sub
473 head_sour_sub : head_sour_vers_sect { OCCUR2(VERS, 0, 1) }
474 | head_sour_name_sect { OCCUR2(NAME, 0, 1) }
475 | head_sour_corp_sect { OCCUR2(CORP, 0, 1) }
476 | head_sour_data_sect { OCCUR2(DATA, 0, 1) }
480 head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item
481 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_VERS, PARENT,
483 START(VERS, $<ctxt>$)
488 { end_element(ELT_HEAD_SOUR_VERS,
489 PARENT, $<ctxt>5, NULL);
492 head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item
493 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_NAME, PARENT,
495 START(NAME, $<ctxt>$)
500 { end_element(ELT_HEAD_SOUR_NAME,
501 PARENT, $<ctxt>5, NULL);
504 head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item
505 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_CORP, PARENT,
507 START(CORP, $<ctxt>$)
512 { end_element(ELT_HEAD_SOUR_CORP,
513 PARENT, $<ctxt>5, NULL);
517 head_sour_corp_subs : /* empty */
518 | head_sour_corp_subs head_sour_corp_sub
521 head_sour_corp_sub : addr_struc_sub /* 0:1 */
525 head_sour_data_sect : OPEN DELIM TAG_DATA mand_line_item
526 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA, PARENT,
528 START(DATA, $<ctxt>$)
533 { end_element(ELT_HEAD_SOUR_DATA,
534 PARENT, $<ctxt>5, NULL);
538 head_sour_data_subs : /* empty */
539 | head_sour_data_subs head_sour_data_sub
542 head_sour_data_sub : head_sour_data_date_sect { OCCUR2(DATE, 0, 1) }
543 | head_sour_data_copr_sect { OCCUR2(COPR, 0, 1) }
547 head_sour_data_date_sect : OPEN DELIM TAG_DATE mand_line_item
548 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA_DATE,
549 PARENT, $1, $3, $4, $4);
550 START(DATE, $<ctxt>$)
555 { end_element(ELT_HEAD_SOUR_DATA_DATE,
556 PARENT, $<ctxt>5, NULL);
559 head_sour_data_copr_sect : OPEN DELIM TAG_COPR mand_line_item
560 { $<ctxt>$ = start_element(ELT_HEAD_SOUR_DATA_COPR,
561 PARENT, $1, $3, $4, $4);
562 START(COPR, $<ctxt>$)
567 { end_element(ELT_HEAD_SOUR_DATA_COPR,
568 PARENT, $<ctxt>5, NULL);
573 head_dest_sect : OPEN DELIM TAG_DEST mand_line_item
574 { $<ctxt>$ = start_element(ELT_HEAD_DEST,
575 PARENT, $1, $3, $4, $4);
576 START(DEST, $<ctxt>$)
581 { end_element(ELT_HEAD_DEST,
582 PARENT, $<ctxt>5, NULL);
587 head_date_sect : OPEN DELIM TAG_DATE mand_line_item
588 { $<ctxt>$ = start_element(ELT_HEAD_DATE,
589 PARENT, $1, $3, $4, $4);
590 START(DATE, $<ctxt>$)
595 { end_element(ELT_HEAD_DATE,
596 PARENT, $<ctxt>5, NULL);
600 head_date_subs : /* empty */
601 | head_date_subs head_date_sub
604 head_date_sub : head_date_time_sect { OCCUR2(TIME, 0, 1) }
608 head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
609 { $<ctxt>$ = start_element(ELT_HEAD_DATE_TIME,
610 PARENT, $1, $3, $4, $4);
611 START(TIME, $<ctxt>$)
616 { end_element(ELT_HEAD_DATE_TIME,
617 PARENT, $<ctxt>5, NULL);
622 head_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
623 { $<ctxt>$ = start_element(ELT_HEAD_SUBM,
624 PARENT, $1, $3, $4, $4);
625 START(SUBM, $<ctxt>$)
630 { end_element(ELT_HEAD_SUBM,
631 PARENT, $<ctxt>5, NULL);
635 head_subn_sect : OPEN DELIM TAG_SUBN mand_pointer
636 { $<ctxt>$ = start_element(ELT_HEAD_SUBN,
637 PARENT, $1, $3, $4, $4);
638 START(SUBN, $<ctxt>$)
643 { end_element(ELT_HEAD_SUBN,
644 PARENT, $<ctxt>5, NULL);
648 head_file_sect : OPEN DELIM TAG_FILE mand_line_item
649 { $<ctxt>$ = start_element(ELT_HEAD_FILE,
650 PARENT, $1, $3, $4, $4);
651 START(FILE, $<ctxt>$)
656 { end_element(ELT_HEAD_FILE, PARENT, $<ctxt>5, NULL);
660 head_copr_sect : OPEN DELIM TAG_COPR mand_line_item
661 { $<ctxt>$ = start_element(ELT_HEAD_COPR,
662 PARENT, $1, $3, $4, $4);
663 START(COPR, $<ctxt>$)
668 { end_element(ELT_HEAD_COPR, PARENT, $<ctxt>5, NULL);
672 head_gedc_sect : OPEN DELIM TAG_GEDC
673 { $<ctxt>$ = start_element(ELT_HEAD_GEDC,
674 PARENT, $1, $3, NULL, NULL);
675 START(GEDC, $<ctxt>$)
678 { CHECK2(VERS, FORM) }
680 { end_element(ELT_HEAD_GEDC, PARENT, $<ctxt>4, NULL);
684 head_gedc_subs : /* empty */
685 | head_gedc_subs head_gedc_sub
688 head_gedc_sub : head_gedc_vers_sect { OCCUR2(VERS, 1, 1) }
689 | head_gedc_form_sect { OCCUR2(FORM, 1, 1) }
692 head_gedc_vers_sect : OPEN DELIM TAG_VERS mand_line_item
693 { $<ctxt>$ = start_element(ELT_HEAD_GEDC_VERS,
694 PARENT, $1, $3, $4, $4);
695 START(VERS, $<ctxt>$)
700 { end_element(ELT_HEAD_GEDC_VERS,
701 PARENT, $<ctxt>5, NULL);
704 head_gedc_form_sect : OPEN DELIM TAG_FORM mand_line_item
705 { $<ctxt>$ = start_element(ELT_HEAD_GEDC_FORM,
706 PARENT, $1, $3, $4, $4);
707 START(FORM, $<ctxt>$)
712 { end_element(ELT_HEAD_GEDC_FORM,
713 PARENT, $<ctxt>5, NULL);
718 head_char_sect : OPEN DELIM TAG_CHAR mand_line_item
719 { if (open_conv_to_internal($4) == 0) YYERROR;
720 $<ctxt>$ = start_element(ELT_HEAD_CHAR,
721 PARENT, $1, $3, $4, $4);
722 START(CHAR, $<ctxt>$)
727 { end_element(ELT_HEAD_CHAR, PARENT, $<ctxt>5, NULL);
731 head_char_subs : /* empty */
732 | head_char_subs head_char_sub
735 head_char_sub : head_char_vers_sect { OCCUR2(VERS, 0, 1) }
738 head_char_vers_sect : OPEN DELIM TAG_VERS mand_line_item
739 { $<ctxt>$ = start_element(ELT_HEAD_CHAR_VERS,
740 PARENT, $1, $3, $4, $4);
741 START(VERS, $<ctxt>$)
746 { end_element(ELT_HEAD_CHAR_VERS,
747 PARENT, $<ctxt>5, NULL);
752 head_lang_sect : OPEN DELIM TAG_LANG mand_line_item
753 { $<ctxt>$ = start_element(ELT_HEAD_LANG,
754 PARENT, $1, $3, $4, $4);
755 START(LANG, $<ctxt>$)
760 { end_element(ELT_HEAD_LANG, PARENT, $<ctxt>5, NULL);
764 head_plac_sect : OPEN DELIM TAG_PLAC
765 { $<ctxt>$ = start_element(ELT_HEAD_PLAC,
766 PARENT, $1, $3, NULL, NULL);
767 START(PLAC, $<ctxt>$)
772 { end_element(ELT_HEAD_PLAC, PARENT, $<ctxt>4, NULL);
776 head_plac_subs : /* empty */
777 | head_plac_subs head_plac_sub
780 head_plac_sub : head_plac_form_sect { OCCUR2(FORM, 1, 1) }
783 head_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item
784 { $<ctxt>$ = start_element(ELT_HEAD_PLAC_FORM,
785 PARENT, $1, $3, $4, $4);
786 START(FORM, $<ctxt>$)
791 { end_element(ELT_HEAD_PLAC_FORM,
792 PARENT, $<ctxt>5, NULL);
797 head_note_sect : OPEN DELIM TAG_NOTE mand_line_item
798 { $<ctxt>$ = start_element(ELT_HEAD_NOTE,
799 PARENT, $1, $3, $4, $4);
800 START(NOTE, $<ctxt>$)
805 { end_element(ELT_HEAD_NOTE, PARENT, $<ctxt>5, NULL);
809 head_note_subs : /* empty */
810 | head_note_subs head_note_sub
813 head_note_sub : continuation_sub /* 0:M */
817 /*********************************************************************/
819 /*********************************************************************/
820 /* Don't need callbacks here, there is no information... */
821 trlr_sect : OPEN DELIM TAG_TRLR CLOSE { }
824 /*********************************************************************/
825 /**** Family record ****/
826 /*********************************************************************/
827 fam_rec : OPEN DELIM POINTER DELIM TAG_FAM
828 { $<ctxt>$ = start_record(REC_FAM, $1, $3, $5);
829 START(FAM, $<ctxt>$) }
833 { end_record(REC_FAM, $<ctxt>6); }
836 fam_subs : /* empty */
840 fam_sub : fam_event_struc_sub /* 0:M */
841 | fam_husb_sect { OCCUR2(HUSB, 0, 1) }
842 | fam_wife_sect { OCCUR2(WIFE, 0, 1) }
843 | fam_chil_sect /* 0:M */
844 | fam_nchi_sect { OCCUR2(NCHI, 0, 1) }
845 | fam_subm_sect /* 0:M */
846 | lds_spouse_seal_sub /* 0:M */
847 | source_cit_sub /* 0:M */
848 | multim_link_sub /* 0:M */
849 | note_struc_sub /* 0:M */
850 | ident_struc_sub /* 0:1 */
851 | change_date_sub /* 0:1 */
856 fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer
857 { START(HUSB, NULL) } no_std_subs { CHECK0 } CLOSE
862 fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer
863 { START(WIFE, NULL) } no_std_subs { CHECK0 } CLOSE
868 fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer
869 { START(CHIL, NULL) } no_std_subs { CHECK0 } CLOSE
874 fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
875 { START(NCHI, NULL) } no_std_subs { CHECK0 } CLOSE
880 fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
881 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE
885 /*********************************************************************/
886 /**** Individual record ****/
887 /*********************************************************************/
888 indiv_rec : OPEN DELIM POINTER DELIM TAG_INDI
889 { $<ctxt>$ = start_record(REC_INDI, $1, $3, $5);
890 START(INDI, $<ctxt>$) }
894 { end_record(REC_INDI, $<ctxt>6); }
897 indi_subs : /* empty */
901 indi_sub : indi_resn_sect { OCCUR2(RESN, 0, 1) }
902 | pers_name_struc_sub /* 0:M */
903 | indi_sex_sect { OCCUR2(SEX, 0, 1) }
904 | indiv_even_struc_sub /* 0:M */
905 | indiv_attr_struc_sub /* 0:M */
906 | lds_indiv_ord_sub /* 0:M */
907 | chi_fam_link_sub /* 0:M */
908 | spou_fam_link_sub /* 0:M */
909 | indi_subm_sect /* 0:M */
910 | assoc_struc_sub /* 0:M */
911 | indi_alia_sect /* 0:M */
912 | indi_anci_sect /* 0:M */
913 | indi_desi_sect /* 0:M */
914 | source_cit_sub /* 0:M */
915 | multim_link_sub /* 0:M */
916 | note_struc_sub /* 0:M */
917 | indi_rfn_sect { OCCUR2(RFN, 0, 1) }
918 | indi_afn_sect /* 0:M */
919 | ident_struc_sub /* 0:1 */
920 | change_date_sub /* 0:1 */
921 | ftree_addr_sect { if (!compat_mode(C_FTREE))
928 indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item
929 { START(RESN, NULL) } no_std_subs { CHECK0 } CLOSE { }
933 indi_sex_sect : OPEN DELIM TAG_SEX mand_line_item
934 { START(SEX, NULL) } no_std_subs { CHECK0 } CLOSE { }
938 indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
939 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE { }
943 indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer
944 { START(ALIA, NULL) } no_std_subs { CHECK0 } CLOSE { }
948 indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer
949 { START(ANCI, NULL) } no_std_subs { CHECK0 } CLOSE { }
953 indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer
954 { START(DESI, NULL) } no_std_subs { CHECK0 } CLOSE { }
958 indi_rfn_sect : OPEN DELIM TAG_RFN mand_line_item
959 { START(RFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
963 indi_afn_sect : OPEN DELIM TAG_AFN mand_line_item
964 { START(AFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
967 /* INDI.ADDR (Only for 'ftree' compatibility) */
968 ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item
969 { START(ADDR, NULL) } no_std_subs { CHECK0 } CLOSE { }
971 /*********************************************************************/
972 /**** Multimedia record ****/
973 /*********************************************************************/
974 multim_rec : OPEN DELIM POINTER DELIM TAG_OBJE
975 { $<ctxt>$ = start_record(REC_OBJE, $1, $3, $5);
976 START(OBJE, $<ctxt>$) }
978 { CHECK2(FORM, BLOB) }
980 { end_record(REC_OBJE, $<ctxt>6); }
983 obje_subs : /* empty */
987 obje_sub : obje_form_sect { OCCUR2(FORM, 1, 1) }
988 | obje_titl_sect { OCCUR2(TITL, 0, 1) }
989 | note_struc_sub /* 0:M */
990 | obje_blob_sect { OCCUR2(BLOB, 1, 1) }
991 | obje_obje_sect { OCCUR2(OBJE, 0, 1) }
992 | ident_struc_sub /* 0:1 */
993 | change_date_sub /* 0:1 */
998 obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
999 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
1003 obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1004 { START(TITL, NULL) } no_std_subs { CHECK0 } CLOSE { }
1008 obje_blob_sect : OPEN DELIM TAG_BLOB
1009 { START(BLOB, NULL) }
1015 obje_blob_subs : /* empty */
1016 | obje_blob_subs obje_blob_sub
1019 obje_blob_sub : obje_blob_cont_sect { OCCUR1(CONT, 1) }
1023 obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item
1024 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1028 obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer
1029 { START(OBJE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1032 /*********************************************************************/
1033 /**** Note record ****/
1034 /*********************************************************************/
1035 note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item
1036 { $<ctxt>$ = start_record(REC_NOTE, $1, $3, $5);
1037 START(NOTE, $<ctxt>$) }
1041 { end_record(REC_NOTE, $<ctxt>6); }
1044 note_line_item : /* empty */
1045 { if (!compat_mode(C_FTREE)) {
1046 gedcom_error(_("Missing value")); YYERROR;
1050 { gedcom_debug_print("==Val: %s==", $2);
1054 note_subs : /* empty */
1055 | note_subs note_sub
1058 note_sub : continuation_sub /* 0:M */
1059 | source_cit_sub /* 0:M */
1060 | ident_struc_sub /* 0:1 */
1061 | change_date_sub /* 0:1 */
1065 /*********************************************************************/
1066 /**** Repository record ****/
1067 /*********************************************************************/
1068 repos_rec : OPEN DELIM POINTER DELIM TAG_REPO
1069 { $<ctxt>$ = start_record(REC_REPO, $1, $3, $5);
1070 START(REPO, $<ctxt>$) }
1074 { end_record(REC_REPO, $<ctxt>6); }
1077 repo_subs : /* empty */
1078 | repo_subs repo_sub
1081 repo_sub : repo_name_sect { OCCUR2(NAME, 0, 1) }
1082 | addr_struc_sub /* 0:1 */
1083 | note_struc_sub /* 0:M */
1084 | ident_struc_sub /* 0:1 */
1085 | change_date_sub /* 0:1 */
1090 repo_name_sect : OPEN DELIM TAG_NAME mand_line_item
1091 { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE {}
1094 /*********************************************************************/
1095 /**** Source record ****/
1096 /*********************************************************************/
1097 source_rec : OPEN DELIM POINTER DELIM TAG_SOUR
1098 { $<ctxt>$ = start_record(REC_SOUR, $1, $3, $5);
1099 START(SOUR, $<ctxt>$) }
1103 { end_record(REC_SOUR, $<ctxt>6); }
1106 sour_subs : /* empty */
1107 | sour_subs sour_sub
1110 sour_sub : sour_data_sect { OCCUR2(DATA, 0, 1) }
1111 | sour_auth_sect { OCCUR2(AUTH, 0, 1) }
1112 | sour_titl_sect { OCCUR2(TITL, 0, 1) }
1113 | sour_abbr_sect { OCCUR2(ABBR, 0, 1) }
1114 | sour_publ_sect { OCCUR2(PUBL, 0, 1) }
1115 | sour_text_sect { OCCUR2(TEXT, 0, 1) }
1116 | source_repos_cit_sub /* 0:1 */
1117 | multim_link_sub /* 0:M */
1118 | note_struc_sub /* 0:M */
1119 | ident_struc_sub /* 0:1 */
1120 | change_date_sub /* 0:1 */
1125 sour_data_sect : OPEN DELIM TAG_DATA
1126 { START(DATA, NULL) }
1132 sour_data_subs : /* empty */
1133 | sour_data_subs sour_data_sub
1136 sour_data_sub : sour_data_even_sect /* 0:M */
1137 | sour_data_agnc_sect { OCCUR2(AGNC, 0, 1) }
1138 | note_struc_sub /* 0:M */
1142 sour_data_even_sect : OPEN DELIM TAG_EVEN mand_line_item
1143 { START(EVEN, NULL) }
1149 sour_data_even_subs : /* empty */
1150 | sour_data_even_subs sour_data_even_sub
1153 sour_data_even_sub : sour_data_even_date_sect { OCCUR2(DATE, 0, 1) }
1154 | sour_data_even_plac_sect { OCCUR2(PLAC, 0, 1) }
1158 sour_data_even_date_sect : OPEN DELIM TAG_DATE mand_line_item
1159 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1162 sour_data_even_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
1163 { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1166 sour_data_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item
1167 { START(AGNC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1171 sour_auth_sect : OPEN DELIM TAG_AUTH mand_line_item
1172 { START(AUTH, NULL) }
1178 sour_auth_subs : /* empty */
1179 | sour_auth_subs sour_auth_sub
1182 sour_auth_sub : continuation_sub /* 0:M */
1187 sour_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1188 { START(TITL, NULL) }
1194 sour_titl_subs : /* empty */
1195 | sour_titl_subs sour_titl_sub
1198 sour_titl_sub : continuation_sub /* 0:M */
1203 sour_abbr_sect : OPEN DELIM TAG_ABBR mand_line_item
1204 { START(ABBR, NULL) } no_std_subs { CHECK0 } CLOSE { }
1208 sour_publ_sect : OPEN DELIM TAG_PUBL mand_line_item
1209 { START(PUBL, NULL) }
1215 sour_publ_subs : /* empty */
1216 | sour_publ_subs sour_publ_sub
1219 sour_publ_sub : continuation_sub /* 0:M */
1224 sour_text_sect : OPEN DELIM TAG_TEXT mand_line_item
1225 { START(TEXT, NULL) }
1231 sour_text_subs : /* empty */
1232 | sour_text_subs sour_text_sub
1235 sour_text_sub : continuation_sub /* 0:M */
1239 /*********************************************************************/
1240 /**** Submission record ****/
1241 /*********************************************************************/
1242 submis_rec : OPEN DELIM POINTER DELIM TAG_SUBN
1243 { $<ctxt>$ = start_record(REC_SUBN, $1, $3, $5);
1244 START(SUBN, $<ctxt>$) }
1248 { end_record(REC_SUBN, $<ctxt>6); }
1251 subn_subs : /* empty */
1252 | subn_subs subn_sub
1255 subn_sub : subn_subm_sect { OCCUR2(SUBM, 0, 1) }
1256 | subn_famf_sect { OCCUR2(FAMF, 0, 1) }
1257 | subn_temp_sect { OCCUR2(TEMP, 0, 1) }
1258 | subn_ance_sect { OCCUR2(ANCE, 0, 1) }
1259 | subn_desc_sect { OCCUR2(DESC, 0, 1) }
1260 | subn_ordi_sect { OCCUR2(ORDI, 0, 1) }
1261 | subn_rin_sect { OCCUR2(RIN, 0, 1) }
1266 subn_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
1267 { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE { }
1271 subn_famf_sect : OPEN DELIM TAG_FAMF mand_line_item
1272 { START(FAMF, NULL) } no_std_subs { CHECK0 } CLOSE { }
1276 subn_temp_sect : OPEN DELIM TAG_TEMP mand_line_item
1277 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1281 subn_ance_sect : OPEN DELIM TAG_ANCE mand_line_item
1282 { START(ANCE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1286 subn_desc_sect : OPEN DELIM TAG_DESC mand_line_item
1287 { START(DESC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1291 subn_ordi_sect : OPEN DELIM TAG_ORDI mand_line_item
1292 { START(ORDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
1296 subn_rin_sect : OPEN DELIM TAG_RIN mand_line_item
1297 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1300 /*********************************************************************/
1301 /**** Submitter record ****/
1302 /*********************************************************************/
1303 submit_rec : OPEN DELIM POINTER DELIM TAG_SUBM
1304 { $<ctxt>$ = start_record(REC_SUBM, $1, $3, $5);
1305 START(SUBM, $<ctxt>$) }
1309 { end_record(REC_SUBM, $<ctxt>6); }
1312 subm_subs : /* empty */
1313 | subm_subs subm_sub
1316 subm_sub : subm_name_sect { OCCUR2(NAME, 0, 1) }
1317 | addr_struc_sub /* 0:1 */
1318 | multim_link_sub /* 0:M */
1319 | subm_lang_sect { OCCUR2(LANG, 0, 3) }
1320 | subm_rfn_sect { OCCUR2(RFN, 0, 1) }
1321 | subm_rin_sect { OCCUR2(RIN, 0, 1) }
1322 | change_date_sub /* 0:1 */
1327 subm_name_sect : OPEN DELIM TAG_NAME mand_line_item
1328 { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE { }
1332 subm_lang_sect : OPEN DELIM TAG_LANG mand_line_item
1333 { START(LANG, NULL) } no_std_subs { CHECK0 } CLOSE { }
1337 subm_rfn_sect : OPEN DELIM TAG_RFN mand_line_item
1338 { START(RFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1342 subm_rin_sect : OPEN DELIM TAG_RIN mand_line_item
1343 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1346 /*********************************************************************/
1347 /**** Substructures ****/
1348 /*********************************************************************/
1350 /* ADDRESS STRUCTURE */
1351 addr_struc_sub : addr_sect { OCCUR2(ADDR, 0, 1) }
1352 | phon_sect { OCCUR2(PHON, 0, 3) }
1355 addr_sect : OPEN DELIM TAG_ADDR mand_line_item
1356 { START(ADDR, NULL) }
1362 addr_subs : /* empty */
1363 | addr_subs addr_sub
1366 addr_sub : addr_cont_sect /* 0:M */
1367 | addr_adr1_sect { OCCUR2(ADR1, 0, 1) }
1368 | addr_adr2_sect { OCCUR2(ADR2, 0, 1) }
1369 | addr_city_sect { OCCUR2(CITY, 0, 1) }
1370 | addr_stae_sect { OCCUR2(STAE, 0, 1) }
1371 | addr_post_sect { OCCUR2(POST, 0, 1) }
1372 | addr_ctry_sect { OCCUR2(CTRY, 0, 1) }
1376 addr_cont_sect : OPEN DELIM TAG_CONT mand_line_item
1377 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1379 addr_adr1_sect : OPEN DELIM TAG_ADR1 mand_line_item
1380 { START(ADR1, NULL) } no_std_subs { CHECK0 } CLOSE { }
1382 addr_adr2_sect : OPEN DELIM TAG_ADR2 mand_line_item
1383 { START(ADR2, NULL) } no_std_subs { CHECK0 } CLOSE { }
1385 addr_city_sect : OPEN DELIM TAG_CITY mand_line_item
1386 { START(CITY, NULL) } no_std_subs { CHECK0 } CLOSE { }
1388 addr_stae_sect : OPEN DELIM TAG_STAE mand_line_item
1389 { START(STAE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1391 addr_post_sect : OPEN DELIM TAG_POST mand_line_item
1392 { START(POST, NULL) } no_std_subs { CHECK0 } CLOSE { }
1394 addr_ctry_sect : OPEN DELIM TAG_CTRY mand_line_item
1395 { START(CTRY, NULL) } no_std_subs { CHECK0 } CLOSE { }
1398 phon_sect : OPEN DELIM TAG_PHON mand_line_item
1399 { START(PHON, NULL) } no_std_subs { CHECK0 } CLOSE { }
1402 /* ASSOCIATION STRUCTURE */
1403 assoc_struc_sub : asso_sect /* 0:M */
1406 asso_sect : OPEN DELIM TAG_ASSO mand_pointer
1407 { START(ASSO, NULL) }
1409 { CHECK2(TYPE,RELA) }
1413 asso_subs : /* empty */
1414 | asso_type_sect { OCCUR2(TYPE, 1, 1) }
1415 | asso_rela_sect { OCCUR2(RELA, 1, 1) }
1421 asso_type_sect : OPEN DELIM TAG_TYPE mand_line_item
1422 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1425 asso_rela_sect : OPEN DELIM TAG_RELA mand_line_item
1426 { START(RELA, NULL) } no_std_subs { CHECK0 } CLOSE { }
1430 change_date_sub : change_date_chan_sect { OCCUR2(CHAN, 0, 1) }
1433 change_date_chan_sect : OPEN DELIM TAG_CHAN
1434 { START(CHAN, NULL) }
1435 change_date_chan_subs
1440 change_date_chan_subs : /* empty */
1441 | change_date_chan_subs change_date_chan_sub
1444 change_date_chan_sub : change_date_date_sect { OCCUR2(DATE, 1, 1) }
1449 change_date_date_sect : OPEN DELIM TAG_DATE mand_line_item
1450 { START(DATE, NULL) }
1451 change_date_date_subs
1456 change_date_date_subs : /* empty */
1457 | change_date_date_subs change_date_date_sub
1460 change_date_date_sub : change_date_date_time_sect { OCCUR2(TIME, 0, 1) }
1464 change_date_date_time_sect : OPEN DELIM TAG_TIME mand_line_item
1465 { START(TIME, NULL) } no_std_subs { CHECK0 } CLOSE { }
1468 /* CHILD TO FAMILY LINK */
1469 chi_fam_link_sub : famc_sect /* 0:M */
1472 famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1473 { START(FAMC, NULL) }
1479 famc_subs : /* empty */
1480 | famc_subs famc_sub
1483 famc_sub : famc_pedi_sect /* 0:M */
1488 famc_pedi_sect : OPEN DELIM TAG_PEDI mand_line_item
1489 { START(PEDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
1492 /* CONTINUATION SUBSECTIONS */
1493 continuation_sub : cont_sect /* 0:M */
1494 | conc_sect /* 0:M */
1497 cont_sect : OPEN DELIM TAG_CONT mand_line_item
1498 { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1501 conc_sect : OPEN DELIM TAG_CONC mand_line_item
1502 { START(CONC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1506 event_detail_sub : event_detail_type_sect { OCCUR2(TYPE, 0, 1) }
1507 | event_detail_date_sect { OCCUR2(DATE, 0, 1) }
1510 | event_detail_age_sect { OCCUR2(AGE, 0, 1) }
1511 | event_detail_agnc_sect { OCCUR2(AGNC, 0, 1) }
1512 | event_detail_caus_sect { OCCUR2(CAUS, 0, 1) }
1518 event_detail_type_sect : OPEN DELIM TAG_TYPE mand_line_item
1519 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1521 event_detail_date_sect : OPEN DELIM TAG_DATE mand_line_item
1522 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1524 event_detail_age_sect : OPEN DELIM TAG_AGE mand_line_item
1525 { START(AGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1527 event_detail_agnc_sect : OPEN DELIM TAG_AGNC mand_line_item
1528 { START(AGNC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1530 event_detail_caus_sect : OPEN DELIM TAG_CAUS mand_line_item
1531 { START(CAUS, NULL) } no_std_subs { CHECK0 } CLOSE { }
1534 /* FAMILY EVENT STRUCTURE */
1535 fam_event_struc_sub : fam_event_sect
1536 | fam_gen_even_sect /* 0:M */
1539 fam_event_sect : OPEN DELIM fam_event_tag opt_value fam_event_subs
1544 fam_event_tag : TAG_ANUL { START(ANUL, NULL) }
1545 | TAG_CENS { START(CENS, NULL) }
1546 | TAG_DIV { START(DIV, NULL) }
1547 | TAG_DIVF { START(DIVF, NULL) }
1548 | TAG_ENGA { START(ENGA, NULL) }
1549 | TAG_MARR { START(MARR, NULL) }
1550 | TAG_MARB { START(MARB, NULL) }
1551 | TAG_MARC { START(MARC, NULL) }
1552 | TAG_MARL { START(MARL, NULL) }
1553 | TAG_MARS { START(MARS, NULL) }
1556 fam_event_subs : /* empty */
1557 | fam_event_subs fam_event_sub
1560 fam_event_sub : event_detail_sub
1561 | fam_even_husb_sect { OCCUR2(HUSB, 0, 1) }
1562 | fam_even_wife_sect { OCCUR2(WIFE, 0, 1) }
1566 fam_even_husb_sect : OPEN DELIM TAG_HUSB
1567 { START(HUSB, NULL) }
1573 fam_even_husb_subs : /* empty */
1574 | fam_even_husb_subs fam_even_husb_sub
1577 fam_even_husb_sub : fam_even_husb_age_sect { OCCUR2(AGE, 1, 1) }
1581 fam_even_husb_age_sect : OPEN DELIM TAG_AGE mand_line_item
1582 { START(AGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1585 fam_even_wife_sect : OPEN DELIM TAG_WIFE
1586 { START(HUSB, NULL) }
1592 fam_gen_even_sect : OPEN DELIM TAG_EVEN
1593 { START(EVEN, NULL) }
1599 fam_gen_even_subs : /* empty */
1600 | fam_gen_even_subs fam_gen_even_sub
1603 fam_gen_even_sub : event_detail_sub
1604 | fam_even_husb_sect { OCCUR2(HUSB, 0, 1) }
1605 | fam_even_wife_sect { OCCUR2(WIFE, 0, 1) }
1609 /* IDENTIFICATION STRUCTURE */
1610 ident_struc_sub : ident_refn_sect /* 0:M */
1611 | ident_rin_sect { OCCUR2(RIN, 0, 1) }
1614 ident_refn_sect : OPEN DELIM TAG_REFN mand_line_item
1615 { START(REFN, NULL) }
1621 ident_refn_subs : /* empty */
1622 | ident_refn_subs ident_refn_sub
1625 ident_refn_sub : ident_refn_type_sect { OCCUR2(TYPE, 0, 1) }
1629 ident_refn_type_sect : OPEN DELIM TAG_TYPE mand_line_item
1630 { START(TYPE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1633 ident_rin_sect : OPEN DELIM TAG_RIN mand_line_item
1634 { START(RIN, NULL) } no_std_subs { CHECK0 } CLOSE { }
1637 /* INDIVIDUAL ATTRIBUTE STRUCTURE */
1638 indiv_attr_struc_sub : indiv_cast_sect /* 0:M */
1639 | indiv_dscr_sect /* 0:M */
1640 | indiv_educ_sect /* 0:M */
1641 | indiv_idno_sect /* 0:M */
1642 | indiv_nati_sect /* 0:M */
1643 | indiv_nchi_sect /* 0:M */
1644 | indiv_nmr_sect /* 0:M */
1645 | indiv_occu_sect /* 0:M */
1646 | indiv_prop_sect /* 0:M */
1647 | indiv_reli_sect /* 0:M */
1648 | indiv_resi_sect /* 0:M */
1649 | indiv_ssn_sect /* 0:M */
1650 | indiv_titl_sect /* 0:M */
1653 indiv_cast_sect : OPEN DELIM TAG_CAST mand_line_item
1654 { START(CAST, NULL) }
1655 indiv_attr_event_subs
1659 indiv_dscr_sect : OPEN DELIM TAG_DSCR mand_line_item
1660 { START(DSCR, NULL) }
1661 indiv_attr_event_subs
1665 indiv_educ_sect : OPEN DELIM TAG_EDUC mand_line_item
1666 { START(EDUC, NULL) }
1667 indiv_attr_event_subs
1671 indiv_idno_sect : OPEN DELIM TAG_IDNO mand_line_item
1672 { START(IDNO, NULL) }
1673 indiv_attr_event_subs
1677 indiv_nati_sect : OPEN DELIM TAG_NATI mand_line_item
1678 { START(NATI, NULL) }
1679 indiv_attr_event_subs
1683 indiv_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
1684 { START(NCHI, NULL) }
1685 indiv_attr_event_subs
1689 indiv_nmr_sect : OPEN DELIM TAG_NMR mand_line_item
1690 { START(NMR, NULL) }
1691 indiv_attr_event_subs
1695 indiv_occu_sect : OPEN DELIM TAG_OCCU mand_line_item
1696 { START(OCCU, NULL) }
1697 indiv_attr_event_subs
1701 indiv_prop_sect : OPEN DELIM TAG_PROP mand_line_item
1702 { START(PROP, NULL) }
1703 indiv_attr_event_subs
1707 indiv_reli_sect : OPEN DELIM TAG_RELI mand_line_item
1708 { START(RELI, NULL) }
1709 indiv_attr_event_subs
1713 indiv_resi_sect : OPEN DELIM TAG_RESI
1714 { START(RESI, NULL) }
1715 indiv_attr_event_subs
1719 indiv_ssn_sect : OPEN DELIM TAG_SSN mand_line_item
1720 { START(SSN, NULL) }
1721 indiv_attr_event_subs
1725 indiv_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1726 { START(TITL, NULL) }
1727 indiv_attr_event_subs
1732 indiv_attr_event_subs : /* empty */
1733 | indiv_attr_event_subs indiv_attr_event_sub
1736 indiv_attr_event_sub : event_detail_sub
1740 /* INDIVIDUAL EVENT STRUCTURE */
1741 indiv_even_struc_sub : indiv_birt_sect
1743 | indiv_adop_sect /* 0:M */
1744 | indiv_even_sect /* 0:M */
1747 indiv_birt_sect : OPEN DELIM indiv_birt_tag opt_value indiv_birt_subs
1752 indiv_birt_tag : TAG_BIRT { START(BIRT, NULL) }
1753 | TAG_CHR { START(CHR, NULL) }
1756 indiv_birt_subs : /* empty */
1757 | indiv_birt_subs indiv_birt_sub
1760 indiv_birt_sub : event_detail_sub
1761 | indiv_birt_famc_sect { OCCUR2(FAMC,0, 1) }
1765 indiv_birt_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1766 { START(FAMC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1769 indiv_gen_sect : OPEN DELIM indiv_gen_tag opt_value indiv_gen_subs
1774 indiv_gen_tag : TAG_DEAT { START(DEAT, NULL) }
1775 | TAG_BURI { START(BURI, NULL) }
1776 | TAG_CREM { START(CREM, NULL) }
1777 | TAG_BAPM { START(BAPM, NULL) }
1778 | TAG_BARM { START(BARM, NULL) }
1779 | TAG_BASM { START(BASM, NULL) }
1780 | TAG_BLES { START(BLES, NULL) }
1781 | TAG_CHRA { START(CHRA, NULL) }
1782 | TAG_CONF { START(CONF, NULL) }
1783 | TAG_FCOM { START(FCOM, NULL) }
1784 | TAG_ORDN { START(ORDN, NULL) }
1785 | TAG_NATU { START(NATU, NULL) }
1786 | TAG_EMIG { START(EMIG, NULL) }
1787 | TAG_IMMI { START(IMMI, NULL) }
1788 | TAG_CENS { START(CENS, NULL) }
1789 | TAG_PROB { START(PROB, NULL) }
1790 | TAG_WILL { START(WILL, NULL) }
1791 | TAG_GRAD { START(GRAD, NULL) }
1792 | TAG_RETI { START(RETI, NULL) }
1795 indiv_gen_subs : /* empty */
1796 | indiv_gen_subs indiv_gen_sub
1799 indiv_gen_sub : event_detail_sub
1803 indiv_adop_sect : OPEN DELIM TAG_ADOP opt_value
1804 { START(ADOP, NULL) }
1810 indiv_adop_subs : /* empty */
1811 | indiv_adop_subs indiv_adop_sub
1814 indiv_adop_sub : event_detail_sub
1815 | indiv_adop_famc_sect { OCCUR2(FAMC,0, 1) }
1819 indiv_adop_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1820 { START(FAMC, NULL) }
1821 indiv_adop_famc_subs
1826 indiv_adop_famc_subs : /* empty */
1827 | indiv_adop_famc_subs indiv_adop_famc_sub
1830 indiv_adop_famc_sub : indiv_adop_famc_adop_sect { OCCUR2(ADOP,0, 1) }
1834 indiv_adop_famc_adop_sect : OPEN DELIM TAG_ADOP mand_line_item
1835 { START(ADOP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1838 indiv_even_sect : OPEN DELIM TAG_EVEN
1839 { START(EVEN, NULL) }
1845 /* LDS INDIVIDUAL ORDINANCE */
1846 lds_indiv_ord_sub : lio_bapl_sect /* 0:M */
1847 | lio_slgc_sect /* 0:M */
1850 lio_bapl_sect : OPEN DELIM lio_bapl_tag lio_bapl_subs
1855 lio_bapl_tag : TAG_BAPL { START(BAPL, NULL) }
1856 | TAG_CONL { START(CONL, NULL) }
1857 | TAG_ENDL { START(ENDL, NULL) }
1860 lio_bapl_subs : /* empty */
1861 | lio_bapl_subs lio_bapl_sub
1864 lio_bapl_sub : lio_bapl_stat_sect { OCCUR2(STAT, 0, 1) }
1865 | lio_bapl_date_sect { OCCUR2(DATE, 0, 1) }
1866 | lio_bapl_temp_sect { OCCUR2(TEMP, 0, 1) }
1867 | lio_bapl_plac_sect { OCCUR2(PLAC, 0, 1) }
1873 lio_bapl_stat_sect : OPEN DELIM TAG_STAT mand_line_item
1874 { START(STAT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1876 lio_bapl_date_sect : OPEN DELIM TAG_DATE mand_line_item
1877 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1879 lio_bapl_temp_sect : OPEN DELIM TAG_TEMP mand_line_item
1880 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1882 lio_bapl_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
1883 { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1886 lio_slgc_sect : OPEN DELIM TAG_SLGC
1887 { START(SLGC, NULL) }
1893 lio_slgc_subs : /* empty */
1894 | lio_slgc_subs lio_slgc_sub
1897 lio_slgc_sub : lio_bapl_sub
1898 | lio_slgc_famc_sect { OCCUR2(FAMC, 1, 1) }
1901 lio_slgc_famc_sect : OPEN DELIM TAG_FAMC mand_pointer
1902 { START(FAMC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1905 /* LDS SPOUSE SEALING */
1906 lds_spouse_seal_sub : lss_slgs_sect
1909 lss_slgs_sect : OPEN DELIM TAG_SLGS
1910 { START(SLGS, NULL) }
1916 lss_slgs_subs : /* empty */
1917 | lss_slgs_subs lss_slgs_sub
1920 lss_slgs_sub : lss_slgs_stat_sect { OCCUR2(STAT, 0, 1) }
1921 | lss_slgs_date_sect { OCCUR2(DATE, 0, 1) }
1922 | lss_slgs_temp_sect { OCCUR2(TEMP, 0, 1) }
1923 | lss_slgs_plac_sect { OCCUR2(PLAC, 0, 1) }
1929 lss_slgs_stat_sect : OPEN DELIM TAG_STAT mand_line_item
1930 { START(STAT, NULL) } no_std_subs { CHECK0 } CLOSE { }
1932 lss_slgs_date_sect : OPEN DELIM TAG_DATE mand_line_item
1933 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1935 lss_slgs_temp_sect : OPEN DELIM TAG_TEMP mand_line_item
1936 { START(TEMP, NULL) } no_std_subs { CHECK0 } CLOSE { }
1938 lss_slgs_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
1939 { START(PLAC, NULL) } no_std_subs { CHECK0 } CLOSE { }
1942 /* MULTIMEDIA LINK */
1943 multim_link_sub : multim_obje_link_sect
1944 | multim_obje_emb_sect
1947 multim_obje_link_sect : OPEN DELIM TAG_OBJE DELIM POINTER
1948 { START(OBJE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1951 multim_obje_emb_sect : OPEN DELIM TAG_OBJE
1952 { START(OBJE, NULL) }
1953 multim_obje_emb_subs
1954 { CHECK2(FORM,FILE) }
1958 multim_obje_emb_subs : /* empty */
1959 | multim_obje_emb_subs multim_obje_emb_sub
1962 multim_obje_emb_sub : multim_obje_form_sect { OCCUR2(FORM, 1, 1) }
1963 | multim_obje_titl_sect { OCCUR2(TITL, 0, 1) }
1964 | multim_obje_file_sect { OCCUR2(FILE, 1, 1) }
1969 multim_obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
1970 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
1972 multim_obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
1973 { START(TITL, NULL) } no_std_subs { CHECK0 } CLOSE { }
1975 multim_obje_file_sect : OPEN DELIM TAG_FILE mand_line_item
1976 { START(FILE, NULL) } no_std_subs { CHECK0 } CLOSE { }
1979 /* NOTE STRUCTURE */
1980 note_struc_sub : note_struc_link_sect /* 0:M */
1981 | note_struc_emb_sect /* 0:M */
1984 note_struc_link_sect : OPEN DELIM TAG_NOTE DELIM POINTER
1985 { START(NOTE, NULL) }
1986 note_struc_link_subs
1991 note_struc_link_subs : /* empty */
1992 | note_struc_link_subs note_struc_link_sub
1995 note_struc_link_sub : source_cit_sub
1999 note_struc_emb_sect : OPEN DELIM TAG_NOTE opt_line_item
2000 { START(NOTE, NULL) }
2006 note_struc_emb_subs : /* empty */
2007 | note_struc_emb_subs note_struc_emb_sub
2010 note_struc_emb_sub : continuation_sub
2015 /* PERSONAL NAME STRUCTURE */
2016 pers_name_struc_sub : pers_name_sect /* 0:M */
2019 pers_name_sect : OPEN DELIM TAG_NAME mand_line_item
2020 { START(NAME, NULL) }
2026 pers_name_subs : /* empty */
2027 | pers_name_subs pers_name_sub
2030 pers_name_sub : pers_name_npfx_sect { OCCUR2(NPFX, 0, 1) }
2031 | pers_name_givn_sect { OCCUR2(GIVN, 0, 1) }
2032 | pers_name_nick_sect { OCCUR2(NICK, 0, 1) }
2033 | pers_name_spfx_sect { OCCUR2(SPFX, 0, 1) }
2034 | pers_name_surn_sect { OCCUR2(SURN, 0, 1) }
2035 | pers_name_nsfx_sect { OCCUR2(NSFX, 0, 1) }
2041 pers_name_npfx_sect : OPEN DELIM TAG_NPFX mand_line_item
2042 { START(NPFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
2044 pers_name_givn_sect : OPEN DELIM TAG_GIVN mand_line_item
2045 { START(GIVN, NULL) } no_std_subs { CHECK0 } CLOSE { }
2047 pers_name_nick_sect : OPEN DELIM TAG_NICK mand_line_item
2048 { START(NICK, NULL) } no_std_subs { CHECK0 } CLOSE { }
2050 pers_name_spfx_sect : OPEN DELIM TAG_SPFX mand_line_item
2051 { START(SPFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
2053 pers_name_surn_sect : OPEN DELIM TAG_SURN mand_line_item
2054 { START(SURN, NULL) } no_std_subs { CHECK0 } CLOSE { }
2056 pers_name_nsfx_sect : OPEN DELIM TAG_NSFX mand_line_item
2057 { START(NSFX, NULL) } no_std_subs { CHECK0 } CLOSE { }
2060 /* PLACE STRUCTURE */
2061 place_struc_sub : place_struc_plac_sect /* 0:M */
2064 place_struc_plac_sect : OPEN DELIM TAG_PLAC mand_line_item
2065 { START(PLAC, NULL) }
2066 place_struc_plac_subs
2071 place_struc_plac_subs : /* empty */
2072 | place_struc_plac_subs place_struc_plac_sub
2075 place_struc_plac_sub : place_plac_form_sect { OCCUR2(FORM, 0, 1) }
2081 place_plac_form_sect : OPEN DELIM TAG_FORM mand_line_item
2082 { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
2085 /* SOURCE_CITATION */
2086 source_cit_sub : source_cit_link_sect /* 0:M */
2087 | source_cit_emb_sect /* 0:M */
2090 source_cit_link_sect : OPEN DELIM TAG_SOUR DELIM POINTER
2091 { START(SOUR, NULL) }
2092 source_cit_link_subs
2097 source_cit_link_subs : /* empty */
2098 | source_cit_link_subs source_cit_link_sub
2101 source_cit_link_sub : source_cit_page_sect { OCCUR2(PAGE, 0, 1) }
2102 | source_cit_even_sect { OCCUR2(EVEN, 0, 1) }
2103 | source_cit_data_sect { OCCUR2(DATA, 0, 1) }
2104 | source_cit_quay_sect { OCCUR2(QUAY, 0, 1) }
2110 source_cit_page_sect : OPEN DELIM TAG_PAGE mand_line_item
2111 { START(PAGE, NULL) } no_std_subs { CHECK0 } CLOSE { }
2114 source_cit_even_sect : OPEN DELIM TAG_EVEN mand_line_item
2115 { START(EVEN, NULL) }
2116 source_cit_even_subs
2121 source_cit_even_subs : /* empty */
2122 | source_cit_even_subs source_cit_even_sub
2125 source_cit_even_sub : source_cit_even_role_sect { OCCUR2(ROLE, 0, 1) }
2129 source_cit_even_role_sect : OPEN DELIM TAG_ROLE mand_line_item
2130 { START(ROLE, NULL) } no_std_subs { CHECK0 } CLOSE { }
2133 source_cit_data_sect : OPEN DELIM TAG_DATA
2134 { START(DATA, NULL) }
2135 source_cit_data_subs
2140 source_cit_data_subs : /* empty */
2141 | source_cit_data_subs source_cit_data_sub
2144 source_cit_data_sub : source_cit_data_date_sect { OCCUR2(DATE, 0, 1) }
2145 | source_cit_text_sect /* 0:M */
2149 source_cit_data_date_sect : OPEN DELIM TAG_DATE mand_line_item
2150 { START(DATE, NULL) } no_std_subs { CHECK0 } CLOSE { }
2153 source_cit_text_sect : OPEN DELIM TAG_TEXT mand_line_item
2154 { START(TEXT, NULL) }
2155 source_cit_text_subs
2160 source_cit_text_subs : /* empty */
2161 | source_cit_text_subs source_cit_text_sub
2164 source_cit_text_sub : continuation_sub
2168 source_cit_quay_sect : OPEN DELIM TAG_QUAY mand_line_item
2169 { START(QUAY, NULL) } no_std_subs { CHECK0 } CLOSE { }
2172 source_cit_emb_sect : OPEN DELIM TAG_SOUR mand_line_item
2173 { START(SOUR, NULL) }
2179 source_cit_emb_subs : /* empty */
2180 | source_cit_emb_subs source_cit_emb_sub
2183 source_cit_emb_sub : continuation_sub
2184 | source_cit_text_sect /* 0:M */
2189 /* SOURCE REPOSITORY CITATION */
2190 source_repos_cit_sub : source_repos_repo_sect { OCCUR2(REPO, 0, 1) }
2193 source_repos_repo_sect : OPEN DELIM TAG_REPO mand_pointer
2194 { START(REPO, NULL) }
2195 source_repos_repo_subs
2200 source_repos_repo_subs : /* empty */
2201 | source_repos_repo_subs source_repos_repo_sub
2204 source_repos_repo_sub : note_struc_sub
2205 | caln_sect /* 0:M */
2209 caln_sect : OPEN DELIM TAG_CALN mand_line_item
2210 { START(CALN, NULL) }
2216 caln_subs : /* empty */
2217 | caln_subs caln_sub
2220 caln_sub : caln_medi_sect { OCCUR2(MEDI, 0, 1) }
2224 caln_medi_sect : OPEN DELIM TAG_MEDI mand_line_item
2225 { START(MEDI, NULL) } no_std_subs { CHECK0 } CLOSE { }
2228 /* SPOUSE TO FAMILY LINK */
2229 spou_fam_link_sub : spou_fam_fams_sect /* 0:M */
2232 spou_fam_fams_sect : OPEN DELIM TAG_FAMS mand_pointer
2233 { START(FAMS, NULL) }
2239 spou_fam_fams_subs : /* empty */
2240 | spou_fam_fams_subs spou_fam_fams_sub
2243 spou_fam_fams_sub : note_struc_sub
2247 /*********************************************************************/
2249 /*********************************************************************/
2251 no_std_subs : /* empty */
2252 | no_std_subs no_std_sub
2255 no_std_sub : user_sect /* 0:M */
2257 | error error_subs CLOSE { HANDLE_ERROR }
2260 no_std_rec : user_rec /* 0:M */
2262 | error error_subs CLOSE { HANDLE_ERROR }
2265 user_rec : OPEN DELIM opt_xref USERTAG
2266 { if ($4[0] != '_') {
2267 gedcom_error(_("Undefined tag (and not a valid user tag): %s"),
2273 { $<ctxt>$ = start_record(REC_USER, $1, $3, $4);
2279 { end_record(REC_USER, $<ctxt>7); }
2281 user_sect : OPEN DELIM opt_xref USERTAG
2282 { if ($4[0] != '_') {
2283 gedcom_error(_("Undefined tag (and not a valid user tag): %s"),
2289 { $<ctxt>$ = start_element(ELT_USER, PARENT, $1, $4, $6, $6);
2290 START($4, $<ctxt>$);
2295 { end_element(ELT_USER, PARENT, $<ctxt>7, NULL);
2299 user_sects : /* empty */ { }
2300 | user_sects user_sect { }
2303 opt_xref : /* empty */ { $$ = NULL; }
2304 | POINTER DELIM { $$ = $1; }
2307 opt_value : /* empty */ { $$ = NULL; }
2308 | DELIM line_value { $$ = $2; }
2311 line_value : POINTER { $$ = $1; }
2312 | line_item { $$ = $1; }
2315 mand_pointer : /* empty */ { gedcom_error(_("Missing pointer")); YYERROR; }
2316 | DELIM POINTER { gedcom_debug_print("==Ptr: %s==", $2);
2320 mand_line_item : /* empty */ { gedcom_error(_("Missing value")); YYERROR; }
2321 | DELIM line_item { gedcom_debug_print("==Val: %s==", $2);
2325 opt_line_item : /* empty */ { }
2326 | DELIM line_item { }
2329 line_item : anychar { size_t i;
2330 CLEAR_BUFFER(line_item_buf);
2331 line_item_buf_ptr = line_item_buf;
2332 /* The following also takes care of '@@' */
2333 if (!strncmp($1, "@@", 3))
2334 *line_item_buf_ptr++ = '@';
2336 for (i=0; i < strlen($1); i++)
2337 *line_item_buf_ptr++ = $1[i];
2340 | ESCAPE { CLEAR_BUFFER(line_item_buf);
2341 line_item_buf_ptr = line_item_buf;
2342 /* For now, ignore escapes */
2347 /* The following also takes care of '@@' */
2348 if (!strncmp($2, "@@", 3))
2349 *line_item_buf_ptr++ = '@';
2351 for (i=0; i < strlen($2); i++)
2352 *line_item_buf_ptr++ = $2[i];
2356 { /* For now, ignore escapes */
2361 anychar : ANYCHAR { }
2365 error_subs : /* empty */
2366 | error_subs error_sect
2369 error_sect : OPEN DELIM opt_xref anytag opt_value error_subs CLOSE { }
2371 gen_sect : OPEN DELIM opt_xref anystdtag
2372 { INVALID_TAG($4); }
2373 opt_value opt_sects CLOSE
2377 gen_rec : gen_rec_top
2381 gen_rec_norm : OPEN DELIM opt_xref anystdtag
2382 { INVALID_TOP_TAG($4) }
2383 opt_value opt_sects CLOSE
2387 gen_rec_top : OPEN DELIM anytoptag
2388 { gedcom_error(_("Missing cross-reference")); YYERROR; }
2389 opt_value opt_sects CLOSE
2393 opt_sects : /* empty */ { }
2394 | opt_sects gen_sect { }
2397 anytag : USERTAG { }
2411 anystdtag : TAG_ABBR
2541 /* Functions that handle the counting of subtags */
2543 int* count_arrays[MAXGEDCLEVEL+1];
2544 char tag_stack[MAXGEDCLEVEL+1][MAXSTDTAGLEN+1];
2545 Gedcom_ctxt ctxt_stack[MAXGEDCLEVEL+1];
2547 void push_countarray()
2550 if (count_level > MAXGEDCLEVEL) {
2551 gedcom_error(_("Internal error: count array overflow"));
2555 count = (int *)calloc(YYNTOKENS, sizeof(int));
2556 if (count == NULL) {
2557 gedcom_error(_("Internal error: count array calloc error"));
2561 count_arrays[count_level] = count;
2566 void set_parenttag(char* tag)
2568 strncpy(tag_stack[count_level], tag, MAXSTDTAGLEN+1);
2571 void set_parentctxt(Gedcom_ctxt ctxt)
2573 ctxt_stack[count_level] = ctxt;
2576 char* get_parenttag()
2578 return tag_stack[count_level];
2581 Gedcom_ctxt get_parentctxt()
2583 return ctxt_stack[count_level];
2586 int count_tag(int tag)
2588 int *count = count_arrays[count_level];
2589 return ++count[tag - GEDCOMTAGOFFSET];
2592 int check_occurrence(int tag)
2594 int *count = count_arrays[count_level];
2595 return (count[tag - GEDCOMTAGOFFSET] > 0);
2598 void pop_countarray()
2601 if (count_level < 0) {
2602 gedcom_error(_("Internal error: count array underflow"));
2606 count = count_arrays[count_level];
2608 count_arrays[count_level] = NULL;
2612 /* Enabling debug mode */
2613 /* level 0: no debugging */
2614 /* level 1: only internal */
2615 /* level 2: also bison */
2618 void gedcom_set_debug_level(int level, FILE* f)
2623 trace_output = stderr;
2625 gedcom_high_level_debug = 1;
2634 int gedcom_debug_print(char* s, ...)
2637 if (gedcom_high_level_debug) {
2640 res = vfprintf(trace_output, s, ap);
2642 fprintf(trace_output, "\n");
2647 /* Setting the error mechanism */
2648 void gedcom_set_error_handling(Gedcom_err_mech mechanism)
2650 error_mechanism = mechanism;
2653 /* Compatibility handling */
2655 void gedcom_set_compat_handling(int enable_compat)
2657 compat_enabled = enable_compat;
2660 void set_compatibility(char* program)
2662 if (compat_enabled) {
2663 if (! strncmp(program, "ftree", 6)) {
2664 gedcom_warning(_("Enabling compatibility with 'ftree'"));
2665 compatibility = C_FTREE;
2673 int compat_mode(int compat_flags)
2675 return (compat_flags & compatibility);