dlugolecki.net.pl
Dziennik
Polecane
Software
projects
/
gedcom-parse.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added some more callbacks.
[gedcom-parse.git]
/
gedcom
/
gedcom.y
diff --git
a/gedcom/gedcom.y
b/gedcom/gedcom.y
index 3765b7b25090f090bebba66c6f641ebec5a3f350..c8aaed00805bbf9f994914e8ae417f0da9da2ee3 100644
(file)
--- a/
gedcom/gedcom.y
+++ b/
gedcom/gedcom.y
@@
-197,7
+197,7
@@
int compat_mode(int flags);
#define CHK(TAG) \
{ if (!check_occurrence(TAG_##TAG)) { \
char* parenttag = get_parenttag(); \
#define CHK(TAG) \
{ if (!check_occurrence(TAG_##TAG)) { \
char* parenttag = get_parenttag(); \
- gedcom_error(
"The tag '%s' is mandatory within '%s', but missing",
\
+ gedcom_error(
_("The tag '%s' is mandatory within '%s', but missing"),
\
#TAG, parenttag); \
HANDLE_ERROR; \
} \
#TAG, parenttag); \
HANDLE_ERROR; \
} \
@@
-219,20
+219,19
@@
int compat_mode(int flags);
{ int num = count_tag(TAG_##CHILDTAG); \
if (num > MAX) { \
char* parenttag = get_parenttag(); \
{ int num = count_tag(TAG_##CHILDTAG); \
if (num > MAX) { \
char* parenttag = get_parenttag(); \
- gedcom_error("The tag '%s' can maximally occur %d " \
- "time(s) within '%s'", \
+ gedcom_error(_("The tag '%s' can maximally occur %d time(s) within '%s'"), \
#CHILDTAG, MAX, parenttag); \
HANDLE_ERROR; \
} \
}
#define INVALID_TAG(CHILDTAG) \
{ char* parenttag = get_parenttag(); \
#CHILDTAG, MAX, parenttag); \
HANDLE_ERROR; \
} \
}
#define INVALID_TAG(CHILDTAG) \
{ char* parenttag = get_parenttag(); \
- gedcom_error(
"The tag '%s' is not a valid tag within '%s'",
\
+ gedcom_error(
_("The tag '%s' is not a valid tag within '%s'"),
\
CHILDTAG, parenttag); \
HANDLE_ERROR; \
}
#define INVALID_TOP_TAG(CHILDTAG) \
CHILDTAG, parenttag); \
HANDLE_ERROR; \
}
#define INVALID_TOP_TAG(CHILDTAG) \
- { gedcom_error(
"The tag '%s' is not a valid top-level tag",
\
+ { gedcom_error(
_("The tag '%s' is not a valid top-level tag"),
\
CHILDTAG); \
HANDLE_ERROR; \
}
CHILDTAG); \
HANDLE_ERROR; \
}
@@
-855,32
+854,67
@@
fam_sub : fam_event_struc_sub /* 0:M */
/* FAM.HUSB */
fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer
/* FAM.HUSB */
fam_husb_sect : OPEN DELIM TAG_HUSB mand_pointer
- { START(HUSB, NULL) } no_std_subs { CHECK0 } CLOSE
- { }
+ { $<ctxt>$ = start_element(ELT_FAM_HUSB,
+ PARENT, $1, $3, $4, $4);
+ START(HUSB, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_FAM_HUSB, PARENT, $<ctxt>5, NULL);
+ }
;
/* FAM.WIFE */
fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer
;
/* FAM.WIFE */
fam_wife_sect : OPEN DELIM TAG_WIFE mand_pointer
- { START(WIFE, NULL) } no_std_subs { CHECK0 } CLOSE
- { }
+ { $<ctxt>$ = start_element(ELT_FAM_WIFE,
+ PARENT, $1, $3, $4, $4);
+ START(WIFE, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_FAM_WIFE, PARENT, $<ctxt>5, NULL);
+ }
;
/* FAM.CHIL */
fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer
;
/* FAM.CHIL */
fam_chil_sect : OPEN DELIM TAG_CHIL mand_pointer
- { START(CHIL, NULL) } no_std_subs { CHECK0 } CLOSE
- { }
+ { $<ctxt>$ = start_element(ELT_FAM_CHIL,
+ PARENT, $1, $3, $4, $4);
+ START(CHIL, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_FAM_CHIL, PARENT, $<ctxt>5, NULL);
+ }
;
/* FAM.NCHI */
fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
;
/* FAM.NCHI */
fam_nchi_sect : OPEN DELIM TAG_NCHI mand_line_item
- { START(NCHI, NULL) } no_std_subs { CHECK0 } CLOSE
- { }
+ { $<ctxt>$ = start_element(ELT_FAM_NCHI,
+ PARENT, $1, $3, $4, $4);
+ START(NCHI, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_FAM_NCHI, PARENT, $<ctxt>5, NULL);
+ }
;
/* FAM.SUBM */
fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
;
/* FAM.SUBM */
fam_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
- { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE
- { }
+ { $<ctxt>$ = start_element(ELT_FAM_SUBM,
+ PARENT, $1, $3, $4, $4);
+ START(SUBM, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_FAM_SUBM, PARENT, $<ctxt>5, NULL);
+ }
;
/*********************************************************************/
;
/*********************************************************************/
@@
-927,42
+961,106
@@
indi_sub : indi_resn_sect { OCCUR2(RESN, 0, 1) }
/* INDI.RESN */
indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item
/* INDI.RESN */
indi_resn_sect : OPEN DELIM TAG_RESN mand_line_item
- { START(RESN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_RESN,
+ PARENT, $1, $3, $4, $4);
+ START(RESN, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_RESN, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.SEX */
indi_sex_sect : OPEN DELIM TAG_SEX mand_line_item
;
/* INDI.SEX */
indi_sex_sect : OPEN DELIM TAG_SEX mand_line_item
- { START(SEX, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_SEX,
+ PARENT, $1, $3, $4, $4);
+ START(SEX, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_SEX, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.SUBM */
indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
;
/* INDI.SUBM */
indi_subm_sect : OPEN DELIM TAG_SUBM mand_pointer
- { START(SUBM, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_SUBM,
+ PARENT, $1, $3, $4, $4);
+ START(SUBM, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_SUBM, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.ALIA */
indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer
;
/* INDI.ALIA */
indi_alia_sect : OPEN DELIM TAG_ALIA mand_pointer
- { START(ALIA, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_ALIA,
+ PARENT, $1, $3, $4, $4);
+ START(ALIA, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_ALIA, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.ANCI */
indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer
;
/* INDI.ANCI */
indi_anci_sect : OPEN DELIM TAG_ANCI mand_pointer
- { START(ANCI, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_ANCI,
+ PARENT, $1, $3, $4, $4);
+ START(ANCI, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_ANCI, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.DESI */
indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer
;
/* INDI.DESI */
indi_desi_sect : OPEN DELIM TAG_DESI mand_pointer
- { START(DESI, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_DESI,
+ PARENT, $1, $3, $4, $4);
+ START(DESI, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_DESI, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.RFN */
indi_rfn_sect : OPEN DELIM TAG_RFN mand_line_item
;
/* INDI.RFN */
indi_rfn_sect : OPEN DELIM TAG_RFN mand_line_item
- { START(RFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_RFN,
+ PARENT, $1, $3, $4, $4);
+ START(RFN, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_RFN, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.AFN */
indi_afn_sect : OPEN DELIM TAG_AFN mand_line_item
;
/* INDI.AFN */
indi_afn_sect : OPEN DELIM TAG_AFN mand_line_item
- { START(AFN, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_INDI_AFN,
+ PARENT, $1, $3, $4, $4);
+ START(AFN, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_INDI_AFN, PARENT, $<ctxt>5, NULL);
+ }
;
/* INDI.ADDR (Only for 'ftree' compatibility) */
;
/* INDI.ADDR (Only for 'ftree' compatibility) */
@@
-997,20
+1095,41
@@
obje_sub : obje_form_sect { OCCUR2(FORM, 1, 1) }
/* OBJE.FORM */
obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
/* OBJE.FORM */
obje_form_sect : OPEN DELIM TAG_FORM mand_line_item
- { START(FORM, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_OBJE_FORM,
+ PARENT, $1, $3, $4, $4);
+ START(FORM, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_OBJE_FORM, PARENT, $<ctxt>5, NULL);
+ }
;
/* OBJE.TITL */
obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
;
/* OBJE.TITL */
obje_titl_sect : OPEN DELIM TAG_TITL mand_line_item
- { START(TITL, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_OBJE_TITL,
+ PARENT, $1, $3, $4, $4);
+ START(TITL, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_OBJE_TITL, PARENT, $<ctxt>5, NULL);
+ }
;
/* OBJE.BLOB */
obje_blob_sect : OPEN DELIM TAG_BLOB
;
/* OBJE.BLOB */
obje_blob_sect : OPEN DELIM TAG_BLOB
- { START(BLOB, NULL) }
+ { $<ctxt>$ = start_element(ELT_OBJE_BLOB,
+ PARENT, $1, $3, NULL, NULL);
+ START(BLOB, $<ctxt>$)
+ }
obje_blob_subs
{ CHECK1(CONT) }
obje_blob_subs
{ CHECK1(CONT) }
- CLOSE { }
+ CLOSE
+ { end_element(ELT_OBJE_BLOB, PARENT, $<ctxt>4, NULL);
+ }
;
obje_blob_subs : /* empty */
;
obje_blob_subs : /* empty */
@@
-1022,12
+1141,29
@@
obje_blob_sub : obje_blob_cont_sect { OCCUR1(CONT, 1) }
;
obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item
;
obje_blob_cont_sect : OPEN DELIM TAG_CONT mand_line_item
- { START(CONT, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_OBJE_BLOB_CONT,
+ PARENT, $1, $3, $4, $4);
+ START(CONT, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_OBJE_BLOB_CONT, PARENT,
+ $<ctxt>5, NULL);
+ }
;
/* OBJE.OBJE */
obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer
;
/* OBJE.OBJE */
obje_obje_sect : OPEN DELIM TAG_OBJE mand_pointer
- { START(OBJE, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { $<ctxt>$ = start_element(ELT_OBJE_OBJE,
+ PARENT, $1, $3, $4, $4);
+ START(OBJE, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_OBJE_OBJE, PARENT, $<ctxt>5, NULL);
+ }
;
/*********************************************************************/
;
/*********************************************************************/
@@
-1044,11
+1180,11
@@
note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item
note_line_item : /* empty */
{ if (!compat_mode(C_FTREE)) {
note_line_item : /* empty */
{ if (!compat_mode(C_FTREE)) {
- gedcom_error(
"Missing value"
); YYERROR;
+ gedcom_error(
_("Missing value")
); YYERROR;
}
}
| DELIM line_item
}
}
| DELIM line_item
- { gedcom_debug_print("==Val: %s==
\n
", $2);
+ { gedcom_debug_print("==Val: %s==", $2);
$$ = $2; }
;
$$ = $2; }
;
@@
-1089,7
+1225,15
@@
repo_sub : repo_name_sect { OCCUR2(NAME, 0, 1) }
/* REPO.NAME */
repo_name_sect : OPEN DELIM TAG_NAME mand_line_item
/* REPO.NAME */
repo_name_sect : OPEN DELIM TAG_NAME mand_line_item
- { START(NAME, NULL) } no_std_subs { CHECK0 } CLOSE {}
+ { $<ctxt>$ = start_element(ELT_REPO_NAME,
+ PARENT, $1, $3, $4, $4);
+ START(NAME, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { end_element(ELT_REPO_NAME, PARENT, $<ctxt>5, NULL);
+ }
;
/*********************************************************************/
;
/*********************************************************************/
@@
-2245,6
+2389,10
@@
spou_fam_fams_sub : note_struc_sub
| no_std_sub
;
| no_std_sub
;
+/*********************************************************************/
+/**** Special values ****/
+/*********************************************************************/
+
/*********************************************************************/
/**** General ****/
/*********************************************************************/
/*********************************************************************/
/**** General ****/
/*********************************************************************/
@@
-2265,7
+2413,7
@@
no_std_rec : user_rec /* 0:M */
user_rec : OPEN DELIM opt_xref USERTAG
{ if ($4[0] != '_') {
user_rec : OPEN DELIM opt_xref USERTAG
{ if ($4[0] != '_') {
- gedcom_error(
"Undefined tag (and not a valid user tag): %s"
,
+ gedcom_error(
_("Undefined tag (and not a valid user tag): %s")
,
$4);
YYERROR;
}
$4);
YYERROR;
}
@@
-2281,7
+2429,7
@@
user_rec : OPEN DELIM opt_xref USERTAG
;
user_sect : OPEN DELIM opt_xref USERTAG
{ if ($4[0] != '_') {
;
user_sect : OPEN DELIM opt_xref USERTAG
{ if ($4[0] != '_') {
- gedcom_error(
"Undefined tag (and not a valid user tag): %s"
,
+ gedcom_error(
_("Undefined tag (and not a valid user tag): %s")
,
$4);
YYERROR;
}
$4);
YYERROR;
}
@@
-2313,14
+2461,14
@@
line_value : POINTER { $$ = $1; }
| line_item { $$ = $1; }
;
| line_item { $$ = $1; }
;
-mand_pointer : /* empty */ { gedcom_error(
"Missing pointer"
); YYERROR; }
- | DELIM POINTER { gedcom_debug_print("==Ptr: %s==
\n
", $2);
- $$ = $2; }
+mand_pointer : /* empty */ { gedcom_error(
_("Missing pointer")
); YYERROR; }
+ | DELIM POINTER { gedcom_debug_print("==Ptr: %s==", $2);
+
$$ = $2; }
;
;
-mand_line_item : /* empty */ { gedcom_error(
"Missing value"
); YYERROR; }
- | DELIM line_item { gedcom_debug_print("==Val: %s==
\n
", $2);
- $$ = $2; }
+mand_line_item : /* empty */ { gedcom_error(
_("Missing value")
); YYERROR; }
+ | DELIM line_item { gedcom_debug_print("==Val: %s==", $2);
+
$$ = $2; }
;
opt_line_item : /* empty */ { }
;
opt_line_item : /* empty */ { }
@@
-2386,7
+2534,7
@@
gen_rec_norm : OPEN DELIM opt_xref anystdtag
;
gen_rec_top : OPEN DELIM anytoptag
;
gen_rec_top : OPEN DELIM anytoptag
- { gedcom_error(
"Missing cross-reference"
); YYERROR; }
+ { gedcom_error(
_("Missing cross-reference")
); YYERROR; }
opt_value opt_sects CLOSE
{ }
;
opt_value opt_sects CLOSE
{ }
;
@@
-2549,13
+2697,13
@@
void push_countarray()
{
int *count = NULL;
if (count_level > MAXGEDCLEVEL) {
{
int *count = NULL;
if (count_level > MAXGEDCLEVEL) {
- gedcom_error(
"Internal error: count array overflow"
);
+ gedcom_error(
_("Internal error: count array overflow")
);
exit(1);
}
else {
count = (int *)calloc(YYNTOKENS, sizeof(int));
if (count == NULL) {
exit(1);
}
else {
count = (int *)calloc(YYNTOKENS, sizeof(int));
if (count == NULL) {
- gedcom_error(
"Internal error: count array calloc error"
);
+ gedcom_error(
_("Internal error: count array calloc error")
);
exit(1);
}
else {
exit(1);
}
else {
@@
-2600,7
+2748,7
@@
void pop_countarray()
{
int *count;
if (count_level < 0) {
{
int *count;
if (count_level < 0) {
- gedcom_error(
"Internal error: count array underflow"
);
+ gedcom_error(
_("Internal error: count array underflow")
);
exit(1);
}
else {
exit(1);
}
else {
@@
-2640,6
+2788,7
@@
int gedcom_debug_print(char* s, ...)
va_start(ap, s);
res = vfprintf(trace_output, s, ap);
va_end(ap);
va_start(ap, s);
res = vfprintf(trace_output, s, ap);
va_end(ap);
+ fprintf(trace_output, "\n");
}
return(res);
}
}
return(res);
}
@@
-2660,9
+2809,8
@@
void gedcom_set_compat_handling(int enable_compat)
void set_compatibility(char* program)
{
if (compat_enabled) {
void set_compatibility(char* program)
{
if (compat_enabled) {
- gedcom_debug_print("==== Program: %s\n", program);
if (! strncmp(program, "ftree", 6)) {
if (! strncmp(program, "ftree", 6)) {
- gedcom_warning(
"Enabling compatibility with 'ftree'"
);
+ gedcom_warning(
_("Enabling compatibility with 'ftree'")
);
compatibility = C_FTREE;
}
else {
compatibility = C_FTREE;
}
else {