protected void NoteProc(ParseContext2 ctx) { // Common note processing var note = NoteStructParse.NoteParser(ctx, ctx.Begline, ctx.Level); (ctx.Parent as NoteHold).Notes.Add(note); }
protected void SourCitProc(ParseContext2 ctx) { // Common source citation processing var cit = SourceCitParse.SourceCitParser(ctx); (ctx.Parent as SourceCitHold).Cits.Add(cit); }
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); }
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)); }
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); }
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]; } }
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; }
protected void ChanProc(ParseContext2 ctx) { // Common CHAN processing ChanStructParse.ChanProc(ctx); }
protected void RinProc(ParseContext2 ctx) { // Common RIN processing ctx.Parent.RIN = ctx.Remain; }
protected void RefnProc(ParseContext2 ctx) { ctx.Parent.REFNs.Add(makeId(ctx)); }
protected void RfnProc(ParseContext2 ctx) { ctx.Parent.RFN = CheckAndMakeId(ctx, ctx.Parent.RFN); }
protected static void ObjeProc(ParseContext2 ctx) { MediaLink mlink = MediaStructParse.MediaParser(ctx); (ctx.Parent as MediaHold).Media.Add(mlink); }