ast

package
v0.0.0-...-ebc58a5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Slash source.Pos // position of "/" starting the comment
	Text  string     // comment text (excluding '\n' for //-style comments)
}

A Comment node represents a single //-style or /*-style comment.

func (*Comment) End

func (c *Comment) End() source.Pos

End returns the position of first character immediately after the comment.

func (*Comment) Pos

func (c *Comment) Pos() source.Pos

Pos returns the position of the comment's slash.

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() source.Pos

End returns the position of last comment's end position.

func (*CommentGroup) Pos

func (g *CommentGroup) Pos() source.Pos

Pos returns the position of the first comment.

func (*CommentGroup) Text

func (g *CommentGroup) Text() string

Text returns the text of the comment. Comment markers (//, /*, and */), 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 DataNoder

type DataNoder interface {
	Node
	SetData(key, value any)
	GetData(key any) (value any, ok bool)
}

type Literal

type Literal struct {
	Value string
	Pos   source.Pos
}

func (Literal) End

func (l Literal) End() source.Pos

type Node

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

Node represents a node in the AST.

type NodeData

type NodeData struct {
	// contains filtered or unexported fields
}

func (*NodeData) GetData

func (nd *NodeData) GetData(key any) (value any, ok bool)

func (*NodeData) SetData

func (nd *NodeData) SetData(key, value any)

Jump to

Keyboard shortcuts

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