node

package
v0.396.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoundaryTokensInRange

func BoundaryTokensInRange(position Position, start lexer.Token, end lexer.Token) bool

Due to the way we have structured our parser fields Collection blocks with no content such as fields {} return no nodes which means we cant purely rely on node.inRange check so it is necessary to examine the underlying tokens emitted by the parser

Types

type Node

type Node struct {
	Pos    lexer.Position
	EndPos lexer.Position
	Tokens []lexer.Token
}

func (Node) GetPositionRange

func (n Node) GetPositionRange() (start lexer.Position, end lexer.Position)

GetPositionRange returns a start and end position that correspond to Node The behaviour of start position is exactly the same as the Pos field that participle provides but the end position is calculated from the position of the last token in this node, which is more useful if you want to know where _this_ node starts and ends.

func (Node) GetTokens

func (n Node) GetTokens() []lexer.Token

func (Node) HasEndPosition

func (n Node) HasEndPosition() bool

func (Node) InRange

func (n Node) InRange(position Position) bool

type ParserNode

type ParserNode interface {
	GetPositionRange() (start lexer.Position, end lexer.Position)
	InRange(position Position) bool
	HasEndPosition() bool
	GetTokens() []lexer.Token
}

type Position

type Position struct {
	Filename string `json:"filename"`
	Column   int    `json:"column"`
	Line     int    `json:"line"`
}

Jump to

Keyboard shortcuts

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