ast

package
v0.0.0-...-0effba1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: BSD-3-Clause Imports: 3 Imported by: 0

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.

func (*Comment) End

func (c *Comment) End() token.Position

func (*Comment) Pos

func (c *Comment) Pos() token.Position

func (*Comment) String

func (c *Comment) String() string

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.

func (*File) End

func (f *File) End() token.Position

func (*File) Pos

func (f *File) Pos() token.Position

func (*File) String

func (f *File) String() string

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.

func (*List) End

func (x *List) End() token.Position

func (*List) Pos

func (x *List) Pos() token.Position

func (*List) String

func (x *List) String() string

func (*List) Width

func (x *List) Width() int

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.

func (*Number) End

func (x *Number) End() token.Position

func (*Number) Pos

func (x *Number) Pos() token.Position

func (*Number) String

func (x *Number) String() string

func (*Number) Width

func (x *Number) Width() int

type Pointer

type Pointer struct {
	AsteriskPos token.Position
	NotePos     token.Position
	Note        string
}

Pointer represents a pointer type with mutability note.

func (*Pointer) End

func (x *Pointer) End() token.Position

func (*Pointer) Pos

func (x *Pointer) Pos() token.Position

func (*Pointer) String

func (x *Pointer) String() string

func (*Pointer) Width

func (x *Pointer) Width() int

type String

type String struct {
	QuotePos token.Position // Position of the opening double quote.
	Text     string         // String's content, including quotes: e.g. `"foo"`.
}

String represents a basic string literal.

func (*String) End

func (x *String) End() token.Position

func (*String) Pos

func (x *String) Pos() token.Position

func (*String) String

func (x *String) String() string

func (*String) Width

func (x *String) Width() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL