Documentation
¶
Overview ¶
Package parser provides low-level GEDCOM line parsing functionality.
This package handles the tokenization and parsing of individual GEDCOM lines, converting them into Line structures with level, tag, value, and cross-reference information. It supports all standard GEDCOM formats and provides detailed error reporting with line numbers.
Example usage:
p := parser.NewParser(reader)
for {
line, err := p.ParseLine()
if err == io.EOF {
break
}
if err != nil {
log.Fatal(err)
}
fmt.Printf("Level %d: %s = %s\n", line.Level, line.Tag, line.Value)
}
Index ¶
Constants ¶
const MaxNestingDepth = 100
MaxNestingDepth is the maximum allowed nesting depth to prevent stack overflow.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Line ¶
type Line struct {
// Level indicates the hierarchical depth (0, 1, 2, etc.)
Level int
// Tag is the GEDCOM tag (e.g., HEAD, INDI, NAME, BIRT)
Tag string
// Value is the optional value associated with the tag
Value string
// XRef is the optional cross-reference identifier (e.g., @I1@)
XRef string
// LineNumber is the line number in the source file (1-based)
// Used for error reporting
LineNumber int
}
Line represents a single parsed line from a GEDCOM file. GEDCOM files use a line-based format with hierarchical levels. Each line format: LEVEL [XREF] TAG [VALUE]
type ParseError ¶
type ParseError struct {
// Line is the line number where the error occurred (1-based)
Line int
// Message describes what went wrong
Message string
// Context provides the actual line content that caused the error
Context string
// Err is the underlying error, if any
Err error
}
ParseError represents an error that occurred during parsing. It includes line number and context for better error reporting.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses GEDCOM files into Line structures.