syzkaller: github.com/google/syzkaller/pkg/ast Index | Files

package ast

import "github.com/google/syzkaller/pkg/ast"

Package ast parses and formats sys files.

Index

Package Files

ast.go clone.go filter.go format.go parser.go scanner.go test_util.go walk.go

func Format Uses

func Format(desc *Description) []byte

func FormatInt Uses

func FormatInt(v uint64, format IntFmt) string

func FormatWriter Uses

func FormatWriter(w io.Writer, desc *Description)

func LoggingHandler Uses

func LoggingHandler(pos Pos, msg string)

func PostRecursive Uses

func PostRecursive(cb func(Node)) func(Node)

func Recursive Uses

func Recursive(cb func(Node)) func(Node)

func SerializeNode Uses

func SerializeNode(n Node) string

type Call Uses

type Call struct {
    Pos      Pos
    Name     *Ident
    CallName string
    NR       uint64
    Args     []*Field
    Ret      *Type
}

func (*Call) Clone Uses

func (n *Call) Clone() Node

func (*Call) Info Uses

func (n *Call) Info() (Pos, string, string)

type Comment Uses

type Comment struct {
    Pos  Pos
    Text string
}

func (*Comment) Clone Uses

func (n *Comment) Clone() Node

func (*Comment) Info Uses

func (n *Comment) Info() (Pos, string, string)

type Define Uses

type Define struct {
    Pos   Pos
    Name  *Ident
    Value *Int
}

func (*Define) Clone Uses

func (n *Define) Clone() Node

func (*Define) Info Uses

func (n *Define) Info() (Pos, string, string)

type Description Uses

type Description struct {
    Nodes []Node
}

Description contains top-level nodes of a parsed sys description.

func Parse Uses

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 Uses

func ParseGlob(glob string, errorHandler ErrorHandler) *Description

func (*Description) Clone Uses

func (desc *Description) Clone() *Description

func (*Description) Filter Uses

func (desc *Description) Filter(predicate func(Node) bool) *Description

func (*Description) Walk Uses

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 Uses

type ErrorHandler func(pos Pos, msg string)

type ErrorMatcher Uses

type ErrorMatcher struct {
    Data []byte
    // contains filtered or unexported fields
}

func NewErrorMatcher Uses

func NewErrorMatcher(t *testing.T, file string) *ErrorMatcher

func (*ErrorMatcher) Check Uses

func (em *ErrorMatcher) Check(t *testing.T)

func (*ErrorMatcher) Count Uses

func (em *ErrorMatcher) Count() int

func (*ErrorMatcher) DumpErrors Uses

func (em *ErrorMatcher) DumpErrors(t *testing.T)

func (*ErrorMatcher) ErrorHandler Uses

func (em *ErrorMatcher) ErrorHandler(pos Pos, msg string)

type Field Uses

type Field struct {
    Pos      Pos
    Name     *Ident
    Type     *Type
    NewBlock bool // separated from previous fields by a new line
    Comments []*Comment
}

func (*Field) Clone Uses

func (n *Field) Clone() Node

func (*Field) Info Uses

func (n *Field) Info() (Pos, string, string)

type Ident Uses

type Ident struct {
    Pos  Pos
    Name string
}

func (*Ident) Clone Uses

func (n *Ident) Clone() Node

func (*Ident) Info Uses

func (n *Ident) Info() (Pos, string, string)

type Incdir Uses

type Incdir struct {
    Pos Pos
    Dir *String
}

func (*Incdir) Clone Uses

func (n *Incdir) Clone() Node

func (*Incdir) Info Uses

func (n *Incdir) Info() (Pos, string, string)

type Include Uses

type Include struct {
    Pos  Pos
    File *String
}

func (*Include) Clone Uses

func (n *Include) Clone() Node

func (*Include) Info Uses

func (n *Include) Info() (Pos, string, string)

type Int Uses

type Int struct {
    Pos Pos
    // Only one of Value, Ident, CExpr is filled.
    Value    uint64
    ValueFmt IntFmt
    Ident    string
    CExpr    string
}

func (*Int) Clone Uses

func (n *Int) Clone() Node

func (*Int) Info Uses

func (n *Int) Info() (Pos, string, string)

type IntFlags Uses

type IntFlags struct {
    Pos    Pos
    Name   *Ident
    Values []*Int
}

func (*IntFlags) Clone Uses

func (n *IntFlags) Clone() Node

func (*IntFlags) Info Uses

func (n *IntFlags) Info() (Pos, string, string)

type IntFmt Uses

type IntFmt int
const (
    IntFmtDec IntFmt = iota
    IntFmtNeg
    IntFmtHex
    IntFmtChar
)

type NewLine Uses

type NewLine struct {
    Pos Pos
}

func (*NewLine) Clone Uses

func (n *NewLine) Clone() Node

func (*NewLine) Info Uses

func (n *NewLine) Info() (Pos, string, string)

type Node Uses

type Node interface {
    Info() (pos Pos, typ string, name string)
    // Clone makes a deep copy of the node.
    Clone() Node
    // contains filtered or unexported methods
}

Node is AST node interface.

type Pos Uses

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.

func (Pos) String Uses

func (pos Pos) String() string

type Resource Uses

type Resource struct {
    Pos    Pos
    Name   *Ident
    Base   *Type
    Values []*Int
}

func (*Resource) Clone Uses

func (n *Resource) Clone() Node

func (*Resource) Info Uses

func (n *Resource) Info() (Pos, string, string)

type StrFlags Uses

type StrFlags struct {
    Pos    Pos
    Name   *Ident
    Values []*String
}

func (*StrFlags) Clone Uses

func (n *StrFlags) Clone() Node

func (*StrFlags) Info Uses

func (n *StrFlags) Info() (Pos, string, string)

type String Uses

type String struct {
    Pos   Pos
    Value string
}

func (*String) Clone Uses

func (n *String) Clone() Node

func (*String) Info Uses

func (n *String) Info() (Pos, string, string)

type Struct Uses

type Struct struct {
    Pos      Pos
    Name     *Ident
    Fields   []*Field
    Attrs    []*Type
    Comments []*Comment
    IsUnion  bool
}

func (*Struct) Clone Uses

func (n *Struct) Clone() Node

func (*Struct) Info Uses

func (n *Struct) Info() (Pos, string, string)

type Type Uses

type Type struct {
    Pos Pos
    // Only one of Value, Ident, String is filled.
    Value     uint64
    ValueFmt  IntFmt
    Ident     string
    String    string
    HasString bool
    // Parts after COLON (for ranges and bitfields).
    Colon []*Type
    // Sub-types in [].
    Args []*Type
}

func (*Type) Clone Uses

func (n *Type) Clone() Node

func (*Type) Info Uses

func (n *Type) Info() (Pos, string, string)

type TypeDef Uses

type TypeDef struct {
    Pos  Pos
    Name *Ident
    // Non-template type aliases have only Type filled.
    // Templates have Args and either Type or Struct filled.
    Args   []*Ident
    Type   *Type
    Struct *Struct
}

func (*TypeDef) Clone Uses

func (n *TypeDef) Clone() Node

func (*TypeDef) Info Uses

func (n *TypeDef) Info() (Pos, string, string)

Package ast imports 12 packages (graph) and is imported by 8 packages. Updated 2019-11-15. Refresh now. Tools for package owners.