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
- type AccessExpr
- type ArrayExpr
- type AttributeStmt
- type BinaryExpr
- type BlockStmt
- type Body
- type CallExpr
- type Comment
- type CommentGroup
- type Expr
- type File
- type IdentifierExpr
- type IndexExpr
- type LiteralExpr
- type Node
- type ObjectExpr
- type ObjectField
- type ParenExpr
- type Stmt
- type UnaryExpr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AccessExpr ¶
type AccessExpr struct {
Value Expr
Name *IdentifierExpr
}
AccessExpr accesses a field in an object value by name.
type ArrayExpr ¶
type ArrayExpr struct {
Elements []Expr
LBrack, RBrack token.Pos
}
ArrayExpr is an array of values.
type AttributeStmt ¶
type AttributeStmt struct {
Name *IdentifierExpr
Value Expr
}
AttributeStmt is a key-value pair being set in a Body or BlockStmt.
type BinaryExpr ¶
type BinaryExpr struct {
Kind token.Token
KindPos token.Pos
Left, Right Expr
}
BinaryExpr performs a binary operation against two values.
type BlockStmt ¶
type BlockStmt struct {
Name []string
NamePos token.Pos
Label string
Body Body
LCurly, RCurly token.Pos
}
BlockStmt declares a block.
type CallExpr ¶
type CallExpr struct {
Value Expr
Args []Expr
LParen, RParen token.Pos
}
CallExpr invokes a function value with a set of arguments.
type Comment ¶
type Comment struct {
Start 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 {
Name string
NamePos token.Pos
}
IdentifierExpr refers to a named value.
type IndexExpr ¶
type IndexExpr struct {
Value, Index Expr
LBrack, RBrack token.Pos
}
IndexExpr accesses an index in an array 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
LCurly, RCurly token.Pos
}
ObjectExpr declares an object of key-value pairs.
type ObjectField ¶
type ObjectField struct {
Name *IdentifierExpr
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 ParenExpr ¶
type ParenExpr struct {
Inner Expr
LParen, RParen token.Pos
}
ParenExpr represents an expression wrapped in parenthesis.