1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
6 <title>Gedcom parser in Genes</title>
11 <h1>Gedcom parser in Genes</h1>
13 <div align="Left">The intention of this page is to provide some explanation
14 of the gedcom parser, to aid development on and with it. Currently,
15 the parser is in a state that it works, but some parts are still missing,
16 notably the interface towards applications. First, some practical issues
17 of testing with the parser will be explained.<br>
22 The parser is located in the "gedcom" subdirectory of the Genes source
23 code. You should be able to perform a basic test using the commands:<br>
25 <blockquote><code>make clean<br>
29 If everything goes OK, you'll see that some gedcom files are parsed, and
30 that each parse is successful. Note that the used gedcom files are
31 made by <a href="http://heiner-eichmann.de/gedcom/gedcom.htm">Heiner Eichmann</a>
32 and are an excellent way to test gedcom parsers thoroughly.<br>
35 <h2>Preparing for further testing</h2>
36 The basic testing described above doesn't show anything else than "Parse
37 succeeded", which is nice, but not very interesting. Some more detailed
38 tests are possible, via the <code>gedcom-parse</code> program that is generated
39 by <code>make test</code>. <br>
41 However, since the output that <code>gedcom-parse</code> generates is
42 in UTF-8 format (more on this later), some preparation is necessary to have
43 a full view on it. Basically, you need a terminal that understands and
44 can display UTF-8 encoded characters, and you need to proper fonts installed
45 to display them. I'll give some advice on this here, based on the Red
46 Hat 7.1 distribution that I use, with glibc 2.2 and XFree86 4.0.x. Any
47 other distribution that has the same or newer versions for these components
48 should give the same results.<br>
50 For the first issue, the UTF-8 capable terminal, the safest bet is to
51 use <code>xterm</code> in its unicode mode (which is supported by the
52 <code> xterm</code> coming with XFree86 4.0.x). UTF-8 capabilities
53 have only recently been added to <code>gnome-terminal</code>, so probably
54 that is not in your distribution yet (it certainly isn't in Red Hat 7.1).<br>
56 For the second issue, you'll need the ISO 10646-1 fonts. These come
57 also with XFree86 4.0.x.<br>
59 The way to start <code>xterm</code> in unicode mode is then e.g. (put
60 everything on 1 line !):<br>
62 <blockquote><code>LANG=en_GB.UTF-8 xterm -bg 'black' -fg 'DarkGrey' -cm
63 -fn '-Misc-Fixed-Medium-R-SemiCondensed--13-120-75-75-C-60-ISO10646-1'</code><br>
65 This first sets the <code>LANG</code> variable to a locale that uses
66 UTF-8, and then starts <code>xterm</code> with a proper Unicode font. Some
67 sample UTF-8 plain text files can be found <a href="http://www.cl.cam.ac.uk/%7Emgk25/ucs/examples">
69 . Just <code>cat</code> them on the command line and see the result.<br>
72 <h2>Testing the parser with debugging</h2>
73 Given the UTF-8 capable terminal, you can now let the <code>gedcom-parse</code>
74 program print the values that it parses. An example of a command
75 line is (in the <code>gedcom</code> directory):<br>
77 <blockquote><code>./gedcom_parse -dg t/ulhc.ged</code><br>
79 The <code>-dg</code> option instructs the parser to show its own debug
80 messages (see <code>./gedcom_parse -h</code> for the full set of options).
81 If everything is OK, you'll see the values from the gedcom file, containing
82 a lot of special characters.<br>
84 For the ANSEL test file (<code>t/ansel.ged</code>), you have to set the
85 environment variable <code>GCONV_PATH</code> to the <code>ansel</code> subdirectory
86 of the gedcom directory:<br>
88 <blockquote><code>export GCONV_PATH=./ansel<br>
89 ./gedcom_parse -dg t/ansel.ged<br>
91 This is because for the ANSEL character set an extra module is needed for
92 the iconv library (more on this later). But again, this should show
93 a lot of special characters.<br>
96 <h2>Testing the lexers separately</h2>
97 The lexers themselves can be tested separately. For the 1-byte lexer
98 (i.e. supporting the encodings with 1 byte per characters, such as ASCII,
99 ANSI and ANSEL), the sequence of commands would be:<br>
101 <blockquote><code>make clean<br>
103 cat t/allged.ged | ./test_1byte</code><br>
105 This will show all tokens in the <code>t/allged.ged</code> test file. With
106 the lexers you have to make sure that you use the proper lexer for each
107 test file. The <code>test_1byte</code> test program is OK for <code>
108 allged.ged</code> and <code>ansel.ged</code> (the last one again with the
109 environment variable set); for the <code>uhl*.ged</code> files you need
110 the <code>test_hilo</code> test program; for the <code>ulh*.ged</code>
111 files you need the <code>test_lohi</code> program.<br>
113 This concludes the testing setup. Now for some explanations...<br>
116 <h2>Structure of the parser</h2>
117 I see the structure of a program using the gedcom parser as follows:<br>
119 <img src="images/schema.png" alt="Gedcom parsing scheme">
123 TO BE COMPLETED...<br>