Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
func Parse(src string) (*File, []*ParseError)
Parse tokenizes src and builds an AST. It returns a (possibly partial) File along with any parse errors encountered.
Types ¶
type Argument ¶
type Argument struct {
Token Token
}
Argument is a single token value used as an argument to a directive.
type Directive ¶
type Directive struct {
Name Token
Args []*Argument
Body []*Directive // sub-directives inside { }
StartLine uint32
EndLine uint32
}
Directive is a named directive with optional arguments and a body block.
type File ¶
type File struct {
GlobalBlock *GlobalBlock // optional; nil if absent
SiteBlocks []*SiteBlock
}
File is the root AST node for a Caddyfile.
type GlobalBlock ¶
GlobalBlock represents the global options block `{ ... }` at the top of a Caddyfile.
func (*GlobalBlock) Range ¶
func (g *GlobalBlock) Range() protocol.Range
type ParseError ¶
ParseError holds a diagnostic-friendly parse error.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
type Token ¶
type Token struct {
Type TokenType
Value string
Line uint32 // 0-based
Char uint32 // 0-based character offset on the line
}
Token is the smallest unit produced by the lexer.
func Tokenize ¶
Tokenize uses Caddy's official Caddyfile tokenizer and enriches each token with column information derived by scanning the source text.
Note: COMMENT and NEWLINE tokens are not produced because Caddy's tokenizer strips comments and does not emit newlines as separate tokens. The NEWLINE and COMMENT enum values are retained for backward compatibility only.