Re: The new GEDCOM parser
[email protected] (Ron Savage) Tue, 06 Nov 2012 09:06:44 +1100
| Newsgroups | perl.gedcom |
|---|---|
| Message-ID | <[email protected]> |
Hi Rich On 06/11/12 01:53, [email protected] wrote: > I didn't want to clog the list with this question, unless you feel it it worth it. Post all questions and ideas. I don't want to develop code in a vacuum. I only that if I /really/ know what I'm doing. Not so in this case... > But would this new parser have reporting capabilities? The basic module - no. It would be purely to parse the file and build a data structure. Code for traversing a tree is standard, from which any imaginable output can be produced. In the simplest case, any node is the root of a sub-tree, and the tree can be traversed and (say) printed from that point on. What you're talking about I assume is formatting that output. > For example, I really like the layout of the FamilyTree add-on for GRAMPS, but it looks like it is not longer being updated, and I wish it was a little more modular, that it could display more fields than it does. I googled and found this link: http://www.gramps-project.org/wiki/index.php?title=Family_Tree I have to say that's a very fancy report. Amazingly, to some extent, such a report is (almost) already available from a tree structure. Peruse the 4 links on this page to get the idea: http://savage.net.au/Graph-module-demos.html Hence my preference for trees. > Plus I wish it was written in perl ; ) Don't we all. > Rich > > > ----- Original Message ----- > From: "Ron Savage"<[email protected]> > To: [email protected] > Sent: Monday, November 5, 2012 2:04:42 AM > Subject: The new GEDCOM parser > > Hi > > The new GEDCOM parser > This document is a collection of ideas which have been percolating > in my mind for a long time. > > Comments welcome. > > Ideas > Module name > Genealogy::Gedcom::Parser. > > A place-holder, Genealogy::Gedcom > <http://metacpan.org/release/Genealogy-Gedcom>, is already on CPAN. > > Note: This module was written before the new, major tools now > available were released. See Tools below. > > ETA > There is no ETA for the parser. > > However, certain Perl-based tools are now available which will make > coding a simple task. See Tools below. > > See also 'Famous Last Words' :-). > > UTF-8 > The code will accept input files in utf-8, and generate files > containing utf-8 characters. > > Apache and mod_perl > These will not be required. I only mention these because references > to them appear in the Gedcom.pm distro. > > Logging > The code will have a built-in logger, so debugging, e.g., can be > turned on with a parameter to new(). > > This logger will use Log::Handler. See Tools below. > > Sub-classing > Sub-classing the main module will be trivial, and samples will be > provided. > > Sub-classing will be done with Hash::FieldHash. See Tools and the > FAQ below. > > Grammars and grammar generators > Like Gedcom.pm, the code will read a GEDCOM grammar in BNF from a file. > I'll run this phase before shipping the module, so you don't have to. > See Tools below, specifically Marpa::Rules::Simple. > > Bascially, this means the startling complexity of the code in > Gedcom.pm is a thing of the past. > > Operating the parser > Using Marpa, callbacks are triggered when input is recognized. > > So, when lines like these are encountered: > > 1 @<XREF:FAM>@ FAM > 2 RIN<AUTOMATED_RECORD_ID> > > Marpa will automatically call the callback attached to each tag. > > Callbacks will probably have names like 'do_fam' and 'do_rin', i.e. > of the format 'do_$tag'. > > The parameters passed to the callback include the non-tag text on > the line. > > Default callbacks for all tags will be provided, each one doing its > part in parsing the parameters to the tag, and storing the result. > > The result will probably be stored in a tree. See Tools below, > specifically Tree::DAG_Node. > > Database support > A DBD::SQLite database is possible. > > Tools > o Hash::FieldHash > Simplifies class-building. > > As for the obvious question, why not use Moose, see the FAQ below. > > o Log::Handling > Simplifies logging. > > o Marpa::R2 > This is the modern way to do parsing. > > Home page<http://jeffreykegler.github.com/Marpa-web-site/>. > > Jeffrey's blog about Marpa > <http://jeffreykegler.github.com/Ocean-of-Awareness-blog/>. > > My recent article about lexing and parsing with Marpa > > <http://www.perl.com/pub/2012/10/an-overview-of-lexing-and-parsing.html>. > > o MarpaX::Simple::Rules > This module reads a grammar in BNF and generates a Marpa grammar. > > Hence it will read a BNF version of the GEDCOM spec and output > the matching Marpa grammar. > > o Tree::DAG_Node > The most sophisticated tree-handling code on CPAN. I've recently > become co-maintainer of this module. > > FAQ > Why did you choose Hash::FieldHash over Moose? > My policy is to use the light-weight Hash::FieldHash for stand-alone > modules and Moose for applications. > > Why did you choose to store the data in a tree? > A GEDCOM file's structure can be viewed as a tree, so my initial > plan is to store the data likewise. > > -- Ron Savage http://savage.net.au/ Ph: 0421 920 622