Documentation ¶
Overview ¶
Package ast contains the types representing Plan syntax trees.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct { Semicolon token.Position // Position of ';' starting the comment. Text string // Comment text (including the ';', excluding any trailing '\n'). }
A Comment node represents a single ;-style comment.
type CommentGroup ¶
type CommentGroup struct {
List []*Comment // len(List) > 0
}
A CommentGroup represents a sequence of comments with no other tokens and no empty lines between.
func (*CommentGroup) End ¶
func (g *CommentGroup) End() token.Position
func (*CommentGroup) Lines ¶
func (g *CommentGroup) Lines() []string
Lines returns the text of the comment group, as a sequence of lines.
Comment markers (';'), the first space of a line comment, and leading and trailing empty lines are removed. Multiple empty lines are reduced to one, and trailing space on lines is trimmed.
func (*CommentGroup) Pos ¶
func (g *CommentGroup) Pos() token.Position
func (*CommentGroup) String ¶
func (g *CommentGroup) String() string
func (*CommentGroup) Text ¶
func (g *CommentGroup) Text() string
Text returns the text of the comment group.
Comment markers (';'), the first space of a line comment, and leading and trailing empty lines are removed. Multiple empty lines are reduced to one, and trailing space on lines is trimmed. Unless the result is empty, it is newline-terminated.
type Expr ¶
type Expr interface { Node // Width returns the number of bytes needed to // store the expression, assuming it is printed // on one line. // Width() int }
Expr represents an expression in the syntax tree.
type File ¶
type File struct { Comments []*CommentGroup // All comments in the file. Lists []*List // Top-level expressions, or nil. }
File represents a file of Plan source.
type Identifier ¶
type Identifier struct { NamePos token.Position // Identifier position. Name string // Identifier name. }
Identifier represents a Plan identifier.
func (*Identifier) End ¶
func (x *Identifier) End() token.Position
func (*Identifier) Pos ¶
func (x *Identifier) Pos() token.Position
func (*Identifier) String ¶
func (x *Identifier) String() string
func (*Identifier) Width ¶
func (x *Identifier) Width() int
type List ¶
type List struct { ParenOpen token.Position // Position of "(". Elements []Expr // List elements. ParenClose token.Position // Position of ")". }
List represents a parenthesised list.
type Node ¶
type Node interface { String() string // A textual description of the node. Pos() token.Position // Location of the first character of the node. End() token.Position // Location of the first character after the node. }
Node represents a node in the syntax tree.
type Number ¶
type Number struct { ValuePos token.Position // Position of the start of the value. Value string // Number's digits: e.g. `1234`. }
Number represents a basic number literal.