Re: The new GEDCOM parser

[email protected] (Ron Savage) Wed, 07 Nov 2012 09:31:39 +1100
Newsgroups perl.gedcom
Message-ID <[email protected]>
Hi Jeremy

On 07/11/12 05:17, Jeremy Slade wrote:
> I think you missed my point: The parser's job should not be to store
> anything in memory. You deal with all the nitty-gritty of handling
> different formats, understanding the grammar, etc, then provide a rich
> set of callbacks so a client can implement whatever they need on top of
> it. Parser != model.

Have you considered sub-classing Genealogy::Gedcom, a module of mine on 
CPAN?

Attached is a run with sample data which ships in the data/ dir:

As for new work, you /could/ use that module, since 
Genealogy::Gedcom::Reader::Lexer already has a long list of methods 
called tag_*() which you could override.

The input data is stored in an array for any further processing desired.

I encourage people to play with it, at least.

What I'm talking about is new code, which would have 1, but better 2, 
data structures holding parsed data.

o A representation of the literal contents of the input file, perhaps as 
an array (as above) but probably in a tree structure.

o Interpreted data, probably in the graph structure.

Basically, having a built-in set of callbacks, a la the tag_*() above 
simply save everyone re-inventing the wheel.

And my policy would be to always store the data in memory.

Sub-classes can then use a documented interface to access that data to 
copy it into other formats.

The reason for storing it is to provide a basic set of features such as:

o List all individuals (and optionally their data of course)
o List all families
o For a given individual:
- List all siblings
- List all descendants
- List all ancestors
- List all ancestors siblings
- Etc
o Likewise something for a given family
o Report (display, print) also

-- 
Ron Savage
http://savage.net.au/
Ph: 0421 920 622
ged.report.log (text/x-log, 2.1 KB)
 Count    Line   Level  Tag     Xref    Type          Data
     1       1       0  HEAD            Header        
     2       2       1  SOUR                          Genealogy::Gedcom
     3       3       2  NAME                          Genealogy::Gedcom::Reader
     4       4       2  VERS                          V 1.00
     5       5       2  CORP                          Ron Savage
     6       6       3  ADDR            Address       Box 3055
     7       7       4  STAE            Address       Vic
     8       8       4  POST            Address       3163
     9       9       4  CTRY            Address       Australia
    10      10       3  EMAIL           Address       [email protected]
    11      11       3  WWW             Address       http://savage.net.au
    12      12       2  DATA            Source        
    13      13       3  COPR            Copyright     Copyright 2011, Ron Savage
    14      14       1  NOTE            Note          
    15      15       2  CONT            Continue      This file is based from test data in Paul Johnson's Gedcom.pm
    16      16       2  CONT            Continue      Gedcom.pm is Copyright 1999-2009, Paul Johnson ([email protected])
    17      17       2  CONT            Continue      Version 1.16 - 24th April 2009
    18      18       2  CONT            Continue      
    19      19       2  CONT            Continue      Ron's modules under the Genealogy::Gedcom namespace are free
    20      20       2  CONT            Continue      
    21      21       2  CONT            Continue      The latest versions of these modules is available from
    22      22       2  CONT            Continue      my homepage http://savage.net.au and http://metacpan.org
    23      23       1  GEDC            Header        
    24      24       2  VERS                          5.5.1-5
    25      25       2  FORM                          LINEAGE-LINKED
    26      26       1  DATE            Date          10-08-2011
    27      27       1  CHAR            Header        ANSEL
    28      28       1  SUBM            Submission    SUBM1
    29      30       0  TRLR            Trailer