nix-amer/internal/cnf/parser/nginx/nginx.go

48 lines
787 B
Go

package nginx
import (
"io"
)
type LineType byte
const (
NONE LineType = iota
COMMENT // # comment
COLONCOMMENT // ; comment
ASSIGNMENT
INCLUDE
SECTION
SECTIONEND
)
type Line struct {
// Number of the line in the input file
Number int
// Type of line
Type LineType
// Path is the absolute dot-separated path to this line
// "" | at the root of the file
// "a.b" | inside the 'a' section inside the 'a' section
Path string
// Components of the line
Components []string
// Lines children of the current section (nil if not a section)
Lines []*Line
// Indent is the indentation characters
Indent string
}
type nginx struct {
Lines []*Line
}
func (n *nginx) NewDecoder(r io.Reader) *decoder {
return &decoder{reader: r}
}