Documentation ¶
Overview ¶
Package ast parses and formats sys files.
Index ¶
- Constants
- func Format(desc *Description) []byte
- func FormatInt(v uint64, format IntFmt) string
- func FormatStr(v string, format StrFmt) string
- func FormatWriter(w io.Writer, desc *Description)
- func LoggingHandler(pos Pos, msg string)
- func PostRecursive(cb func(Node)) func(Node)
- func Recursive(cb func(Node) bool) func(Node)
- func SerializeNode(n Node) string
- type BinaryExpression
- type Call
- type Comment
- type Define
- type Description
- type ErrorHandler
- type ErrorMatcher
- type Field
- type FlagValue
- type Flags
- type Ident
- type Incdir
- type Include
- type Int
- type IntFlags
- type IntFmt
- type Meta
- type NewLine
- type Node
- type Operator
- type Pos
- type Resource
- type StrFlags
- type StrFmt
- type String
- type Struct
- type Type
- type TypeDef
Constants ¶
View Source
const ( OperatorCompareEq = iota + 1 OperatorCompareNeq OperatorBinaryAnd OperatorOr )
View Source
const BuiltinFile = "BUILTINS"
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 PostRecursive ¶
func SerializeNode ¶
Types ¶
type BinaryExpression ¶
func (*BinaryExpression) Clone ¶
func (n *BinaryExpression) Clone() Node
type Call ¶
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/PostRecursive helpers 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()
func (*ErrorMatcher) Count ¶
func (em *ErrorMatcher) Count() int
func (*ErrorMatcher) DumpErrors ¶
func (em *ErrorMatcher) DumpErrors()
func (*ErrorMatcher) ErrorHandler ¶
func (em *ErrorMatcher) ErrorHandler(pos Pos, msg string)
type Field ¶
type Int ¶
type Node ¶
type Node interface { Info() (pos Pos, typ, name string) // Clone makes a deep copy of the node. Clone() Node // contains filtered or unexported methods }
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 ¶
type Type struct { Pos Pos // Only one of Value, Ident, String, Expression is filled. Value uint64 ValueFmt IntFmt Ident string String string StringFmt StrFmt HasString bool Expression *BinaryExpression // Parts after COLON (for ranges and bitfields). Colon []*Type // Sub-types in []. Args []*Type }
Click to show internal directories.
Click to hide internal directories.