Documentation
¶
Overview ¶
Package parse handles parsing of various layout file formats
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format int
Format represents the supported file formats
func DetectFormat ¶
DetectFormat determines the format based on file extension
type IndentationError ¶
type IndentationError struct {
ParseError
Expected int // Expected indentation
Got int // Actual indentation
}
IndentationError represents an inconsistent indentation error
func NewIndentationError ¶
func NewIndentationError(line, column, expected, got int) *IndentationError
NewIndentationError creates a new IndentationError
func (*IndentationError) Error ¶
func (e *IndentationError) Error() string
Error implements the error interface
type Node ¶
type Node struct {
Name string // Name of the file or directory
IsDir bool // True if this is a directory
Children []*Node // Child nodes (only for directories)
Path string // Full path from root (for error reporting)
Line int // Line number in source file (for error reporting)
}
Node represents a single entry in the directory tree
func ParseWithIndent ¶
ParseWithIndent reads from the reader with a specific indent width for plain-text
func (*Node) CountNodes ¶
CountNodes returns the total number of nodes in the tree
type ParseError ¶
type ParseError struct {
Line int // Line number where error occurred (1-indexed)
Column int // Column number where error occurred (1-indexed)
Message string // Error message
File string // File being parsed (optional)
}
ParseError represents an error that occurred during parsing
func NewParseError ¶
func NewParseError(line int, message string) *ParseError
NewParseError creates a new ParseError
type PlainTextParser ¶
type PlainTextParser struct {
IndentWidth int // Expected width of indentation (default 2)
AutoDetect bool // Auto-detect indent width from first indented line
}
PlainTextParser parses plain-text tree format
func NewPlainTextParser ¶
func NewPlainTextParser(indentWidth int) *PlainTextParser
NewPlainTextParser creates a new plain-text parser
func (*PlainTextParser) Parse ¶
func (p *PlainTextParser) Parse(reader io.Reader) ([]*Node, error)
Parse implements the Parser interface
func (*PlainTextParser) ValidateIndentation ¶
func (p *PlainTextParser) ValidateIndentation(lines []string) error
ValidateIndentation checks if all lines use consistent indentation
type SyntaxError ¶
type SyntaxError struct {
ParseError
Context string // Additional context about what was expected
}
SyntaxError represents a syntax error in the input
func NewSyntaxError ¶
func NewSyntaxError(line int, message, context string) *SyntaxError
NewSyntaxError creates a new SyntaxError
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
Error implements the error interface