Documentation ¶
Overview ¶
Package ast parses and formats sys files.
Index ¶
- func Format(desc *Description) []byte
- func FormatInt(v uint64, format IntFmt) string
- func FormatWriter(w io.Writer, desc *Description)
- func LoggingHandler(pos Pos, msg string)
- func Recursive(cb func(Node)) func(Node)
- func SerializeNode(n Node) string
- type Call
- type Comment
- type Define
- type Description
- type ErrorHandler
- type ErrorMatcher
- type Field
- type Ident
- type Incdir
- type Include
- type Int
- type IntFlags
- type IntFmt
- type NewLine
- type Node
- type Pos
- type Resource
- type StrFlags
- type String
- type Struct
- type Type
- type TypeDef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Format ¶
func Format(desc *Description) []byte
func FormatWriter ¶
func FormatWriter(w io.Writer, desc *Description)
func LoggingHandler ¶
func SerializeNode ¶
Types ¶
type Description ¶
type Description struct {
Nodes []Node
}
Description contains top-level nodes of a parsed sys description.
func Parse ¶
func Parse(data []byte, filename string, errorHandler ErrorHandler) *Description
Parse parses sys description into AST and returns top-level nodes. If any errors are encountered, returns nil.
func ParseGlob ¶
func ParseGlob(glob string, errorHandler ErrorHandler) *Description
func (*Description) Clone ¶
func (desc *Description) Clone() *Description
func (*Description) Filter ¶
func (desc *Description) Filter(predicate func(Node) bool) *Description
func (*Description) Walk ¶
func (desc *Description) Walk(cb func(Node))
Walk calls callback cb for every top-level node in description. Note: it's not recursive. Use Recursive helper for recursive walk.
type ErrorHandler ¶
type ErrorMatcher ¶
type ErrorMatcher struct { Data []byte // contains filtered or unexported fields }
func NewErrorMatcher ¶
func NewErrorMatcher(t *testing.T, file string) *ErrorMatcher
func (*ErrorMatcher) Check ¶
func (em *ErrorMatcher) Check(t *testing.T)
func (*ErrorMatcher) Count ¶
func (em *ErrorMatcher) Count() int
func (*ErrorMatcher) DumpErrors ¶
func (em *ErrorMatcher) DumpErrors(t *testing.T)
func (*ErrorMatcher) ErrorHandler ¶
func (em *ErrorMatcher) ErrorHandler(pos Pos, msg string)
type Field ¶
type Int ¶
type Node ¶
type Node interface { Info() (pos Pos, typ string, name string) // Clone makes a deep copy of the node. Clone() Node // Walk calls callback cb for all child nodes of this node. // Note: it's not recursive. Use Recursive helper for recursive walk. Walk(cb func(Node)) }
Node is AST node interface.
type Pos ¶
type Pos struct { File string Off int // byte offset, starting at 0 Line int // line number, starting at 1 Col int // column number, starting at 1 (byte count) }
Pos represents source info for AST nodes.
type Struct ¶
type Type ¶
Click to show internal directories.
Click to hide internal directories.