ast

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expression

type Expression interface {
	Node
	IsUndefinedLiteral() bool
	IsScalarLiteral() bool
	IsCompositeLiteral() bool
	IsCallExpression() bool
	LiteralToValue() (core.Value, bool)
}

Expression represents an expression node in the AST.

type File

type File struct {
	InputFile *SourceFile
	Stmts     []Statement
}

File represents a file unit.

func (*File) End

func (n *File) End() core.Pos

func (*File) Name

func (n *File) Name() string

func (*File) Pos

func (n *File) Pos() core.Pos

func (*File) String

func (n *File) String() string

type Identifier

type Identifier interface {
	Expression
	IdentifierNode()
}

Identifier represents an identifier node in the AST.

type Node

type Node interface {
	Pos() core.Pos  // Returns the position of first character belonging to the node.
	End() core.Pos  // Returns the position of first character immediately after the node.
	String() string // Returns a string representation of the node.
}

Node represents a node in the AST.

type SourceFile

type SourceFile struct {

	// SourceFile name as provided to AddFile
	Name string
	// SourcePos value range for this file is [base...base+size]
	Base int
	// SourceFile size as provided to AddFile
	Size int
	// Lines contains the offset of the first character for each line
	// (the first entry is always 0)
	Lines []int
	// contains filtered or unexported fields
}

SourceFile represents a source file.

func (*SourceFile) AddLine

func (f *SourceFile) AddLine(offset int)

AddLine adds a new line.

func (*SourceFile) FileSetPos

func (f *SourceFile) FileSetPos(offset int) core.Pos

FileSetPos returns the position in the file set.

func (*SourceFile) LineCount

func (f *SourceFile) LineCount() int

LineCount returns the current number of lines.

func (*SourceFile) LineStart

func (f *SourceFile) LineStart(line int) core.Pos

LineStart returns the position of the first character in the line.

func (*SourceFile) Offset

func (f *SourceFile) Offset(p core.Pos) int

Offset translates the file set position into the file offset.

func (*SourceFile) Position

func (f *SourceFile) Position(p core.Pos) (pos SourceFilePos)

Position translates the file set position into the file position.

func (*SourceFile) Set

func (f *SourceFile) Set() *SourceFileSet

Set returns SourceFileSet.

type SourceFilePos

type SourceFilePos struct {
	Filename string // filename, if any
	Offset   int    // offset, starting at 0
	Line     int    // line number, starting at 1
	Column   int    // column number, starting at 1 (byte count)
}

SourceFilePos represents a position information in the file.

func (SourceFilePos) IsValid

func (p SourceFilePos) IsValid() bool

IsValid returns true if the position is valid.

func (SourceFilePos) String

func (p SourceFilePos) String() string

String returns a string in one of several forms:

file:line:column    valid position with file name
file:line           valid position with file name but no column (column == 0)
line:column         valid position without file name
line                valid position without file name and no column (column == 0)
file                invalid position with file name
-                   invalid position without file name

type SourceFileSet

type SourceFileSet struct {
	Base     int           // base offset for the next file
	Files    []*SourceFile // list of files in the order added to the set
	LastFile *SourceFile   // cache of last file looked up
}

SourceFileSet represents a set of source files.

func NewFileSet

func NewFileSet() *SourceFileSet

NewFileSet creates a new file set.

func (*SourceFileSet) AddFile

func (s *SourceFileSet) AddFile(filename string, base, size int) *SourceFile

AddFile adds a new file in the file set.

func (*SourceFileSet) File

func (s *SourceFileSet) File(p core.Pos) (f *SourceFile)

File returns the file that contains the position p. If no such file is found (for instance for p == NoPos), the result is nil.

func (*SourceFileSet) Position

func (s *SourceFileSet) Position(p core.Pos) (pos SourceFilePos)

Position converts a SourcePos p in the file-set into a SourceFilePos value.

func (*SourceFileSet) Size

func (s *SourceFileSet) Size() (size int64)

Size of all files in this set in bytes.

type Statement

type Statement interface {
	Node
	StatementNode()
}

Statement represents a statement in the AST.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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