cc1d718525a084029d9595196447def81569d806
[gedcom-parse.git] / doc / parser.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4            
5   <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
6   <title>Gedcom parser in Genes</title>
7 </head>
8   <body>
9    
10 <div align="Center">  
11 <h1>Gedcom parser in Genes</h1>
12    
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. &nbsp;Currently, 
15  the parser is in a state that it works, but some parts are still missing, 
16  notably the interface towards applications. &nbsp;First, some practical issues
17  of testing with the parser will be explained.<br>
18   <br>
19    
20 <h2>Basic testing<br>
21   </h2>
22    The parser is located in the "gedcom" subdirectory of the Genes source 
23 code.  &nbsp;You should be able to perform a basic test using the commands:<br>
24    
25 <blockquote><code>make clean<br>
26   make<br>
27    make test</code><br>
28     </blockquote>
29    If everything goes OK, you'll see that some gedcom files are parsed, and 
30  that each parse is successful. &nbsp;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>
33     <br>
34        
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. &nbsp;Some more detailed 
38  tests are possible, via the <code>gedcom-parse</code> program that is generated 
39  by <code>make test</code>. &nbsp;<br>
40     <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. &nbsp;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. &nbsp;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. &nbsp;Any 
47  other distribution that has the same or newer versions for these components 
48  should give the same results.<br>
49     <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). &nbsp;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>
55     <br>
56    For the second issue, you'll need the ISO 10646-1 fonts. &nbsp;These come 
57  also with XFree86 4.0.x.<br>
58     <br>
59    The way to start <code>xterm</code> in unicode mode is then e.g. (put
60 everything  on 1 line !):<br>
61        
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>
64       </blockquote>
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. &nbsp;Some
67  sample UTF-8 plain text files can be found <a href="http://www.cl.cam.ac.uk/%7Emgk25/ucs/examples">
68   here</a>
69   . &nbsp;Just <code>cat</code> them on the command line and see the result.<br>
70       <br>
71            
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. &nbsp;An example of a command 
75 line is (in the <code>gedcom</code> directory):<br>
76            
77     <blockquote><code>./gedcom_parse -dg t/ulhc.ged</code><br>
78         </blockquote>
79   The <code>-dg</code> option instructs the parser to show its own debug
80 messages  &nbsp;(see <code>./gedcom_parse -h</code> for the full set of options).
81 &nbsp;If  everything is OK, you'll see the values from the gedcom file, containing
82 a lot of special characters.<br>
83         <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>
87                
88       <blockquote><code>export GCONV_PATH=./ansel<br>
89   ./gedcom_parse -dg t/ansel.ged<br>
90           </code></blockquote>
91   This is because for the ANSEL character set an extra module is needed for
92  the iconv library (more on this later). &nbsp;But again, this should show
93  a lot of special characters.<br>
94           <br>
95                    
96         <h2>Testing the lexers separately</h2>
97   The lexers themselves can be tested separately. &nbsp;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>
100                    
101         <blockquote><code>make clean<br>
102   make test_1byte<br>
103   cat t/allged.ged | ./test_1byte</code><br>
104             </blockquote>
105   This will show all tokens in the <code>t/allged.ged</code> test file. &nbsp;With
106  the lexers you have to make sure that you use the proper lexer for each
107 test  file. &nbsp;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>
112             <br>
113   This concludes the testing setup. &nbsp;Now for some explanations...<br>
114             <br>
115                        
116           <h2>Structure of the parser</h2>
117   I see the structure of a program using the gedcom parser as follows:<br>
118             <br>
119             <img src="images/schema.png" alt="Gedcom parsing scheme">
120             <br>
121             <br>
122             <br>
123   TO BE COMPLETED...<br>
124           <br>
125             </div>
126             </div>
127                        
128           </body>
129           </html>