compast

package
v0.0.0-...-e19543c Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenCommand = iota
	TokenLiteral
	TokenLabel
	TokenHelp

	// This is used as an expected type.
	TokenAny
)
View Source
const (
	NodeRoot = iota
	NodeCommand
	NodeLabel
	NodeCall
	NodeFinish
	NodeLoop
	NodeSwitch
	NodeSwitchLoop
	NodeAny
	NodeBreak
	NodeContinue
	NodeGoCall
	NodeCandidate
	NodeLiteral
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

Node implements a tree of Tokens. This tree is a basic AST of the completion spec.

func NewAny

func NewAny(this *Token, help *Token) *Node

func NewBreak

func NewBreak(this, label *Token) *Node

func NewCall

func NewCall(this, label *Token) *Node

func NewCandidate

func NewCandidate(this, funcName *Token, args []*Token) *Node

func NewCommand

func NewCommand(this, command, label *Token) *Node

func NewContinue

func NewContinue(this, label *Token) *Node

func NewFinish

func NewFinish(this *Token) *Node

func NewGoCall

func NewGoCall(this, funcName *Token, args []*Token) *Node

func NewLabel

func NewLabel(this, label *Token) *Node

func NewLiteral

func NewLiteral(this, help *Token) *Node

func NewLoop

func NewLoop(this, pattern, label *Token) *Node

func NewRoot

func NewRoot() *Node

func NewSwitch

func NewSwitch(this *Token, pattern, label *Token) *Node

func NewSwitchLoop

func NewSwitchLoop(this, pattern, label *Token) *Node

func (*Node) AddChild

func (n *Node) AddChild(new *Node)

AddChild adds a child new to node n.

func (*Node) Args

func (n *Node) Args() []string

func (*Node) AsCandidates

func (n *Node) AsCandidates() []compromise.Candidate

func (*Node) Child

func (n *Node) Child() *Node

func (*Node) Command

func (n *Node) Command() *Token

func (*Node) Dump

func (n *Node) Dump(multiLine bool) string

Dump returns a human readable dump of a Node tree.

func (*Node) FuncName

func (n *Node) FuncName() *Token

func (*Node) GetLabeledNode

func (n *Node) GetLabeledNode(label string, referrer *Token) *Node

GetLabeledNode returns the NodeLabel with a given label. Only supported by a root node.

func (*Node) GetStartNodeForCommand

func (n *Node) GetStartNodeForCommand(command string) *Node

GetStartNodeForCommand takes a command name given by completion and returns the starting NodeLabel for the command, taking @command's into account.

func (*Node) Help

func (n *Node) Help() *Token

func (*Node) HelpText

func (n *Node) HelpText() string

func (*Node) IsRoot

func (n *Node) IsRoot() bool

func (*Node) Label

func (n *Node) Label() *Token

func (*Node) LabelWord

func (n *Node) LabelWord() string

func (*Node) Literal

func (n *Node) Literal() *Token

func (*Node) Next

func (n *Node) Next() *Node

func (*Node) NodeType

func (n *Node) NodeType() int

func (*Node) NodeTypeString

func (n *Node) NodeTypeString() string

func (*Node) Parent

func (n *Node) Parent() *Node

func (*Node) Pattern

func (n *Node) Pattern() *Token

func (*Node) PatternMatches

func (n *Node) PatternMatches(s string) bool

func (*Node) Root

func (n *Node) Root() *Node

func (*Node) SelfToken

func (n *Node) SelfToken() *Token

func (*Node) String

func (n *Node) String() string

func (*Node) TargetCommands

func (n *Node) TargetCommands() []string

Return command name listed with @command.

func (*Node) UpdateLastVisitedWordIndex

func (n *Node) UpdateLastVisitedWordIndex(index int)

type Token

type Token struct {
	TokenType int
	Word      string
	RawWord   string

	IndexInLine int

	SourceFile string
	Line       int
	Column     int
}

func (*Token) SourceLocation

func (t *Token) SourceLocation() (string, int, int)

func (*Token) String

func (t *Token) String() string

Jump to

Keyboard shortcuts

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