ast

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndPos

func EndPos(n Node) token.Pos

EndPos returns the position of the final character in a Node.

func StartPos

func StartPos(n Node) token.Pos

StartPos returns the position of the first character belonging to a Node.

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 Body

type Body []Stmt

Body is a list of statements.

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.

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.

type UnaryExpr

type UnaryExpr struct {
	Kind    token.Token
	KindPos token.Pos
	Value   Expr
}

UnaryExpr performs a unary operation on a single value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳