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
Better interface for setup of encoding.
[gedcom-parse.git]
/
gedcom.y
diff --git
a/gedcom.y
b/gedcom.y
index 68b2f488755b53b04c286bebbc3a0f7ddb522e65..8aad4fd9f02ed3726ac82eaf78c800fbc3568f65 100644
(file)
--- a/
gedcom.y
+++ b/
gedcom.y
@@
-122,13
+122,15
@@
%{
#include "gedcom.h"
%{
#include "gedcom.h"
+#include "multilex.h"
int count_level = 0;
int fail = 0;
int compat_enabled = 1;
int count_level = 0;
int fail = 0;
int compat_enabled = 1;
+int gedcom_high_level_debug = 0;
int compatibility = 0;
int compatibility = 0;
-MECHANISM
cur
r_mechanism=IMMED_FAIL;
-char string_buf[MAXGEDCLINELEN+1];
+MECHANISM
erro
r_mechanism=IMMED_FAIL;
+char string_buf[MAXGEDCLINELEN
*4
+1];
char *string_buf_ptr;
enum _COMPAT {
char *string_buf_ptr;
enum _COMPAT {
@@
-149,13
+151,13
@@
int compat_mode(int flags);
#define HANDLE_ERROR \
{ \
#define HANDLE_ERROR \
{ \
- if (
cur
r_mechanism == IMMED_FAIL) { \
+ if (
erro
r_mechanism == IMMED_FAIL) { \
YYABORT; \
} \
YYABORT; \
} \
- else if (
cur
r_mechanism == DEFER_FAIL) { \
+ else if (
erro
r_mechanism == DEFER_FAIL) { \
yyerrok; fail = 1; \
} \
yyerrok; fail = 1; \
} \
- else if (
cur
r_mechanism == IGNORE_ERRORS) { \
+ else if (
erro
r_mechanism == IGNORE_ERRORS) { \
yyerrok; \
} \
}
yyerrok; \
} \
}
@@
-388,13
+390,11
@@
record : fam_rec
head_sect : OPEN DELIM TAG_HEAD
{ START(HEAD) }
head_subs
head_sect : OPEN DELIM TAG_HEAD
{ START(HEAD) }
head_subs
- { if (compat_mode(C_FTREE)) {
- CHECK3(SOUR, GEDC, CHAR);
- }
- else {
- CHECK4(SOUR, SUBM, GEDC, CHAR);
- }
- }
+ { if (compat_mode(C_FTREE))
+ CHECK3(SOUR, GEDC, CHAR)
+ else
+ CHECK4(SOUR, SUBM, GEDC, CHAR)
+ }
CLOSE { }
;
CLOSE { }
;
@@
-420,6
+420,7
@@
head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) }
/* HEAD.SOUR */
head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item
{ set_compatibility($4);
/* HEAD.SOUR */
head_sour_sect : OPEN DELIM TAG_SOUR mand_line_item
{ set_compatibility($4);
+ gedcom_debug_print("===Source: '%s'\n", $4);
START(SOUR)
}
head_sour_subs
START(SOUR)
}
head_sour_subs
@@
-440,14
+441,17
@@
head_sour_sub : head_sour_vers_sect { OCCUR2(VERS, 0, 1) }
head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item
{ START(VERS)} no_std_subs { CHECK0 } CLOSE
head_sour_vers_sect : OPEN DELIM TAG_VERS mand_line_item
{ START(VERS)} no_std_subs { CHECK0 } CLOSE
- { }
+ { gedcom_debug_print("===Source version: '%s'\n", $4);
+ }
;
head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item
{ START(NAME) } no_std_subs { CHECK0 } CLOSE
;
head_sour_name_sect : OPEN DELIM TAG_NAME mand_line_item
{ START(NAME) } no_std_subs { CHECK0 } CLOSE
- { }
+ { gedcom_debug_print("===Source name: '%s'\n", $4);
+ }
;
head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item
;
head_sour_corp_sect : OPEN DELIM TAG_CORP mand_line_item
- { START(CORP) }
+ { gedcom_debug_print("===Source corp name: '%s'\n", $4);
+ START(CORP) }
head_sour_corp_subs
{ CHECK0 }
CLOSE
head_sour_corp_subs
{ CHECK0 }
CLOSE
@@
-2106,10
+2110,15
@@
opt_line_item : /* empty */ { }
| DELIM line_item { }
;
| DELIM line_item { }
;
-line_item : anychar { CLEAR_BUFFER(string_buf);
+line_item : anychar { size_t i;
+ CLEAR_BUFFER(string_buf);
string_buf_ptr = string_buf;
/* The following also takes care of '@@' */
string_buf_ptr = string_buf;
/* The following also takes care of '@@' */
- *string_buf_ptr++ = $1[0];
+ if (!strncmp($1, "@@", 3))
+ *string_buf_ptr++ = '@';
+ else
+ for (i=0; i < strlen($1); i++)
+ *string_buf_ptr++ = $1[i];
$$ = string_buf;
}
| ESCAPE { CLEAR_BUFFER(string_buf);
$$ = string_buf;
}
| ESCAPE { CLEAR_BUFFER(string_buf);
@@
-2123,8
+2132,13
@@
line_item : anychar { CLEAR_BUFFER(string_buf);
YYERROR;
}
else {
YYERROR;
}
else {
+ size_t i;
/* The following also takes care of '@@' */
/* The following also takes care of '@@' */
- *string_buf_ptr++ = $2[0];
+ if (!strncmp($2, "@@", 3))
+ *string_buf_ptr++ = '@';
+ else
+ for (i=0; i < strlen($2); i++)
+ *string_buf_ptr++ = $2[i];
$$ = string_buf;
}
}
$$ = string_buf;
}
}
@@
-2375,17
+2389,37
@@
void pop_countarray()
}
/* Enabling debug mode */
}
/* Enabling debug mode */
-void gedcom_enable_debug()
+/* level 0: no debugging */
+/* level 1: only internal */
+/* level 2: also bison */
+void gedcom_set_debug_level(int level)
{
{
+ if (level > 0) {
+ gedcom_high_level_debug = 1;
+ }
+ if (level > 1) {
#if YYDEBUG != 0
#if YYDEBUG != 0
- gedcom_debug = 1;
+
gedcom_debug = 1;
#endif
#endif
+ }
+}
+
+int gedcom_debug_print(char* s, ...)
+{
+ int res;
+ if (gedcom_high_level_debug) {
+ va_list ap;
+ va_start(ap, s);
+ res = vfprintf(stderr, s, ap);
+ va_end(ap);
+ }
+ return(res);
}
/* Setting the error mechanism */
void gedcom_set_error_handling(MECHANISM mechanism)
{
}
/* Setting the error mechanism */
void gedcom_set_error_handling(MECHANISM mechanism)
{
-
cur
r_mechanism = mechanism;
+
erro
r_mechanism = mechanism;
}
/* Compatibility handling */
}
/* Compatibility handling */
@@
-2413,3
+2447,4
@@
int compat_mode(int compat_flags)
{
return (compat_flags & compatibility);
}
{
return (compat_flags & compatibility);
}
+