Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
func Format(f *FileSyntax) []byte
Types ¶
type Allower ¶
Allower defines if a given verb and block combination is valid for configuration parsing.
If this is intended to be a statement-like verb, block should be set to false. If this is intended to be a block-like verb, block should be set to true.
type AllowerFunc ¶
AllowerFunc implements Allower for inline definitions.
type Comment ¶
type Comment struct { Start Position Token string // without trailing newline Suffix bool // an end of line (not whole line) comment }
A Comment represents a single // comment.
type CommentBlock ¶
A CommentBlock represents a top-level block of comments separate from any rule.
func (*CommentBlock) Span ¶
func (x *CommentBlock) Span() (start, end Position)
type Comments ¶
type Comments struct { Before []Comment // whole-line comments before this expression Suffix []Comment // end-of-line comments after this expression // For top-level expressions only, After lists whole-line // comments following the expression. After []Comment }
Comments collects the comments associated with an expression.
type Expr ¶
type Expr interface { // Span returns the start and end position of the expression, // excluding leading or trailing comments. Span() (start, end Position) // Comment returns the comments attached to the expression. // This method would normally be named 'Comments' but that // would interfere with embedding a type of the same name. Comment() *Comments }
An Expr represents an input element.
type FileSyntax ¶
A FileSyntax represents an entire go.mod file.
func (*FileSyntax) Span ¶
func (x *FileSyntax) Span() (start, end Position)
type LParen ¶
An LParen represents the beginning of a parenthesized line block. It is a place to store suffix comments.
type LineBlock ¶
type LineBlock struct { Comments Start Position LParen LParen Token []string Line []*Line RParen RParen }
A LineBlock is a factored block of lines, like
require ( "x" "y" )
type MapConfig ¶
MapConfig is a simple wrapper around a map.
type Position ¶
type Position struct { Line int // line in input (starting at 1) LineRune int // rune in line (starting at 1) Byte int // byte in input (starting at 0) }
A Position describes the position between two bytes of input.
type RParen ¶
An RParen represents the end of a parenthesized line block. It is a place to store whole-line (before) comments.
type Reader ¶
type Reader interface {
Read(errs *bytes.Buffer, fs *FileSyntax, line *Line, verb string, args []string)
}
Reader is called when individual lines of the configuration file are being read. This is where you should populate any relevant structures with information.
If something goes wrong in the file parsing step, add data to the errs buffer describing what went wrong.
type ReaderFunc ¶
ReaderFunc implements Reader for inline definitions.
func (ReaderFunc) Read ¶
func (r ReaderFunc) Read(errs *bytes.Buffer, fs *FileSyntax, line *Line, verb string, args []string)
Directories ¶
Path | Synopsis |
---|---|
Package flagconfyg is a hack around confyg.
|
Package flagconfyg is a hack around confyg. |