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

58 lines
1.0 KiB
Go
Raw Normal View History

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