예제 #1
0
        protected void NoteProc(ParseContext2 ctx)
        {
            // Common note processing
            var note = NoteStructParse.NoteParser(ctx, ctx.Begline, ctx.Level);

            (ctx.Parent as NoteHold).Notes.Add(note);
        }
예제 #2
0
        protected void SourCitProc(ParseContext2 ctx)
        {
            // Common source citation processing
            var cit = SourceCitParse.SourceCitParser(ctx);

            (ctx.Parent as SourceCitHold).Cits.Add(cit);
        }
예제 #3
0
        private StringPlus makeId(ParseContext2 ctx)
        {
            var sp = new StringPlus();

            sp.Value = ctx.Remain;
            LookAhead(ctx);
            sp.Extra.Beg = ctx.Begline + 1;
            sp.Extra.End = ctx.Endline;
            return(sp);
        }
예제 #4
0
 private StringPlus CheckAndMakeId(ParseContext2 ctx, StringPlus who)
 {
     if (who != null)
     {
         var rec = new UnkRec(ctx.Tag, ctx.Begline + ctx.Lines.Beg, ctx.Endline + ctx.Lines.Beg);
         rec.Error = UnkRec.ErrorCode.MultId;
         ctx.Parent.Errors.Add(rec);
         return(who);
     }
     return(makeId(ctx));
 }
예제 #5
0
        protected static string parseForXref(ParseContext2 context, UnkRec.ErrorCode errVal = UnkRec.ErrorCode.MissIdent)
        {
            string xref;
            string extra;

            StructParser.parseXrefExtra(context.Remain, out xref, out extra);
            if (string.IsNullOrEmpty(xref))
            {
                UnkRec err = new UnkRec();
                err.Error = errVal;
                err.Beg   = err.End = context.Begline + context.Parent.BegLine;
                err.Tag   = context.Tag;
                context.Parent.Errors.Add(err);
            }
            return(xref);
        }
예제 #6
0
        protected void UidProc(ParseContext2 ctx)
        {
            if (ctx.Parent._uid != null)
            {
                var rec = new UnkRec(ctx.Tag, ctx.Begline + ctx.Lines.Beg, ctx.Endline + ctx.Lines.Beg);
                rec.Error = UnkRec.ErrorCode.MultId;
                ctx.Parent.Errors.Add(rec);
                return;
            }
            int len = ctx.Remain1.Length;

            ctx.Parent._uid = new byte[len];
            for (int i = 0; i < len; i++)
            {
                ctx.Parent._uid[i] = (byte)ctx.Remain1[i];
            }
        }
예제 #7
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;
        }
예제 #8
0
 protected void ChanProc(ParseContext2 ctx)
 {
     // Common CHAN processing
     ChanStructParse.ChanProc(ctx);
 }
예제 #9
0
 protected void RinProc(ParseContext2 ctx)
 {
     // Common RIN processing
     ctx.Parent.RIN = ctx.Remain;
 }
예제 #10
0
 protected void RefnProc(ParseContext2 ctx)
 {
     ctx.Parent.REFNs.Add(makeId(ctx));
 }
예제 #11
0
 protected void RfnProc(ParseContext2 ctx)
 {
     ctx.Parent.RFN = CheckAndMakeId(ctx, ctx.Parent.RFN);
 }
예제 #12
0
        protected static void ObjeProc(ParseContext2 ctx)
        {
            MediaLink mlink = MediaStructParse.MediaParser(ctx);

            (ctx.Parent as MediaHold).Media.Add(mlink);
        }