58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
package nginx
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
// LineType enumerates available line types
|
|
type LineType byte
|
|
|
|
const (
|
|
// NONE is the default line type (invalid syntax)
|
|
NONE LineType = iota
|
|
// COMMENT represents a #-comment
|
|
COMMENT
|
|
// COLONCOMMENT represents a ;-comment
|
|
COLONCOMMENT
|
|
// ASSIGNMENT line
|
|
ASSIGNMENT
|
|
// INCLUDE line
|
|
INCLUDE
|
|
// SECTION start
|
|
SECTION
|
|
// SECTIONEND line '}'
|
|
SECTIONEND
|
|
)
|
|
|
|
// Line represents a meaningful line
|
|
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
|
|
}
|
|
|
|
// NewDecoder implements parser.T
|
|
func (n *nginx) NewDecoder(r io.Reader) *decoder {
|
|
return &decoder{reader: r}
|
|
}
|