Documentation ¶
Overview ¶
Package uast defines a UAST (Universal Abstract Syntax Tree) representation and operations to manipulate them.
Index ¶
- Constants
- Variables
- func HashNoPos(n nodes.External) nodes.Hash
- func LookupType(typ string) (reflect.Type, bool)
- func NewObjectByType(typ string) nodes.Object
- func NewObjectByTypeOpt(typ string) (obj, opt nodes.Object)
- func NewPositionalIterator(root nodes.External) nodes.Iterator
- func NewValue(typ string) (reflect.Value, error)
- func NodeAs(n nodes.External, dst interface{}) error
- func RegisterPackage(ns string, types ...interface{})
- func RoleList(roles ...role.Role) nodes.Array
- func RolesOf(m nodes.Object) role.Roles
- func ToNode(o interface{}) (nodes.Node, error)
- func TokenOf(m nodes.Object) string
- func Tokens(n nodes.Node) []string
- func TypeOf(o interface{}) string
- type Alias
- type Any
- type Argument
- type Block
- type Comment
- type Function
- type FunctionGroup
- type FunctionType
- type GenNode
- type Group
- type Identifier
- type Import
- type Position
- type Positions
- type QualifiedIdentifier
- type RuntimeImport
- type RuntimeReImport
- type Scope
- type String
Constants ¶
const ( KeyType = "@type" // InternalType KeyToken = "@token" // Token KeyRoles = "@role" // Roles, for representations see RoleList KeyPos = "@pos" // All positional information is stored in this field )
Special field keys for nodes.Object
const ( // NS is a namespace for the UAST types. NS = "uast" // TypePosition is a node type for positional information in AST. See AsPosition. TypePosition = NS + ":Position" // TypePositions is a node type for a root node of positional information in AST. See AsPositions. TypePositions = NS + ":Positions" // TypeOperator is a node type for an operator AST node. See Operator. TypeOperator = NS + ":Operator" // KeyPosOff is a name for a Position object field that stores a bytes offset. KeyPosOff = "offset" // KeyPosLine is a name for a Position object field that stores a source line. KeyPosLine = "line" // KeyPosCol is a name for a Position object field that stores a source column. KeyPosCol = "col" KeyStart = "start" // StartPosition KeyEnd = "end" // EndPosition )
Variables ¶
var ( ErrIncorrectType = errors.NewKind("incorrect object type: %q, expected: %q") ErrTypeNotRegistered = errors.NewKind("type is not registered: %q") )
Functions ¶
func NewObjectByType ¶
func NewObjectByTypeOpt ¶
func NewPositionalIterator ¶ added in v2.2.0
NewPositionalIterator creates a new iterator that enumerates all object nodes, sorting them by positions in the source file. Nodes with no positions will be enumerated last.
func RegisterPackage ¶
func RegisterPackage(ns string, types ...interface{})
func ToNode ¶
ToNode converts objects returned by schema-less encodings such as JSON to Node objects. It also supports types from packages registered via RegisterPackage.
Types ¶
type Alias ¶
type Alias struct { GenNode Name Identifier `json:"Name"` Node Any `json:"Node"` }
type Function ¶
type Function struct { GenNode Type FunctionType `json:"Type"` Body *Block `json:"Body"` }
type FunctionGroup ¶
type FunctionGroup Group
type FunctionType ¶
type Identifier ¶
type Position ¶
type Position struct { // Offset is the position as an absolute byte offset. It is a 0-based index. Offset uint32 `json:"offset"` // Line is the line number. It is a 1-based index. Line uint32 `json:"line"` // Col is the column number (the byte offset of the position relative to // a line. It is a 1-based index. Col uint32 `json:"col"` }
Position represents a position in a source code file.
func AsPosition ¶
AsPosition transforms a generic AST node to a Position object.
func (Position) HasLineCol ¶ added in v2.2.0
type Positions ¶
Positions is a container object that stores all positional information for a node.
func PositionsOf ¶
PositionsOf returns an object with all positional information for a node.
type QualifiedIdentifier ¶
type QualifiedIdentifier struct { GenNode Names []Identifier `json:"Names"` }
type RuntimeImport ¶
type RuntimeImport Import
type RuntimeReImport ¶
type RuntimeReImport RuntimeImport
Directories ¶
Path | Synopsis |
---|---|
nodesproto
Package nodesproto is a generated protocol buffer package.
|
Package nodesproto is a generated protocol buffer package. |
Package role is a generated protocol buffer package.
|
Package role is a generated protocol buffer package. |