Documentation
¶
Overview ¶
Package ast exposes AST elements used by River.
The various interfaces exposed by ast are all closed; only types within this package can satisfy an AST interface.
Index ¶
- func EndPos(n Node) token.Pos
- func StartPos(n Node) token.Pos
- func Walk(v Visitor, node Node)
- type AccessExpr
- type ArrayExpr
- type AttributeStmt
- type BinaryExpr
- type BlockStmt
- type Body
- type CallExpr
- type Comment
- type CommentGroup
- type Expr
- type File
- type Ident
- type IdentifierExpr
- type IndexExpr
- type LiteralExpr
- type Node
- type ObjectExpr
- type ObjectField
- type ParenExpr
- type Stmt
- type UnaryExpr
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Walk ¶ added in v0.27.0
Walk traverses an AST in depth-first order: it starts by calling v.Visit(node); node must not be nil. If the visitor w returned by v.Visit(node) is not nil, Walk is invoked recursively with visitor w for each of the non-nil children of node, followed by a call of w.Visit(nil).
Types ¶
type AccessExpr ¶
AccessExpr accesses a field in an object value by name.
type AttributeStmt ¶
AttributeStmt is a key-value pair being set in a Body or BlockStmt.
type BinaryExpr ¶
BinaryExpr performs a binary operation against two values.
type BlockStmt ¶
type BlockStmt struct { Name []string NamePos token.Pos Label string LabelPos token.Pos Body Body LCurlyPos, RCurlyPos token.Pos }
BlockStmt declares a block.
type Comment ¶
type Comment struct { StartPos token.Pos // Starting position of comment // Text of the comment. Text will not contain '\n' for line comments. Text string }
A Comment represents a single line or block comment.
The Text field contains the comment text without any carriage returns (\r) that may have been present in the source. Since carriage returns get removed, EndPos will not be accurate for any comment which contained carriage returns.
type CommentGroup ¶
type CommentGroup []*Comment
A CommentGroup represents a sequence of comments that are not separated by any empty lines or other non-comment tokens.
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr is an expression within the AST.
type File ¶
type File struct { Name string // Filename provided to parser Body Body // Content of File Comments []CommentGroup // List of all comments in the File }
File is a parsed file.
type IdentifierExpr ¶
type IdentifierExpr struct {
Ident *Ident
}
IdentifierExpr refers to a named value.
type LiteralExpr ¶
type LiteralExpr struct { Kind token.Token ValuePos token.Pos // Value holds the unparsed literal value. For example, if Kind == // token.STRING, then Value would be wrapped in the original quotes (e.g., // `"foobar"`). Value string }
LiteralExpr is a constant value of a specific token kind.
type Node ¶
type Node interface {
// contains filtered or unexported methods
}
Node represents any node in the AST.
type ObjectExpr ¶
type ObjectExpr struct { Fields []*ObjectField LCurlyPos, RCurlyPos token.Pos }
ObjectExpr declares an object of key-value pairs.
type ObjectField ¶
type ObjectField struct { Name *Ident Quoted bool // True if the name was wrapped in quotes Value Expr }
ObjectField defines an individual key-value pair within an object. ObjectField does not implement Node.
type Stmt ¶
type Stmt interface { Node // contains filtered or unexported methods }
Stmt is a type of statement wthin the body of a file or block.