Beispiel #1
0
        public GedParser(string gedPath)
        {
            // TODO dunno yet if the path to the GED is useful

            _masterTagCache = new StringCache();
            gs = new GEDSplitter(_masterTagCache);

            _IndiParseSingleton  = new IndiParse();
            _HeadParseSingleton  = new HeadParse();
            _FamParseSingleton   = new FamParse();
            _SourParseSingleton  = new SourceRecParse();
            _RepoParseSingleton  = new RepoParse();
            _NoteParseSingleton  = new NoteParse();
            _MediaParseSingleton = new MediaParse();

            _GedSplitFactory = new GSFactory(_masterTagCache);
        }
Beispiel #2
0
        public void Parse(GEDCommon rec, GedRecord Lines, GSFactory gsfact)
        {
            ParseContext2 ctx = new ParseContext2();

            ctx.gs       = gsfact.Alloc(); // new GEDSplitter(GedParser._masterTagCache);
            ctx.tagCache = GedParser._masterTagCache;

            ctx.Lines  = Lines;
            ctx.Parent = rec;
            int max = Lines.Max;

            for (int i = 1; i < max; i++)
            {
                var line = Lines.GetLine(i);
                ctx.Begline = i;
                ctx.Endline = i; // assume it is one line long, parser might change it

                ctx.gs.LevelTagAndRemain(line, ctx);
                TagProc2 tagProc;
                if (ctx.Tag != null && _tagSet2.TryGetValue(ctx.Tag, out tagProc))
                {
                    tagProc(ctx);
                }
                else
                {
                    // Custom and invalid treated as 'unknowns': let the consumer figure it out
                    // TODO gedr5419_blood_type_events.ged has garbage characters in SOUR/ABBR tags: incorrect line terminator, blank lines etc.
                    LookAhead(ctx);
                    rec.Unknowns.Add(new UnkRec(ctx.Tag, Lines.Beg + ctx.Begline, Lines.Beg + ctx.Endline));
                }
                i = ctx.Endline;
            }

            // TODO post parse error checking on sub-structures
            PostCheck(ctx.Parent); // post parse error checking

            gsfact.Free(ctx.gs);
            ctx.gs = null;
        }