parse

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParse  = errors.New("parse error")
	ErrKeyTag = fmt.Errorf("%w: key cannot be tagged", ErrParse)
)

Functions

func GetPositions added in v0.0.6

func GetPositions(opts ...ParseOption) map[*ir.Node]*token.Pos

GetPositions extracts the positions map from the provided options. This allows consumers (like FromTony methods) to access position information.

func Parse

func Parse(d []byte, opts ...ParseOption) (*ir.Node, error)

func ParseMulti added in v0.0.6

func ParseMulti(d []byte, opts ...ParseOption) ([]*ir.Node, error)

ParseMulti parses multiple Tony documents separated by '---' from a single byte slice. It preserves global positions for all documents.

func ParseNodeFromSource added in v0.0.12

func ParseNodeFromSource(source *token.TokenSource, opts ...ParseOption) (*ir.Node, error)

ParseNodeFromSource parses the next complete ir.Node from a TokenSource. It reads tokens until it finds a complete bracketed structure or simple value, then parses and returns it. Returns io.EOF when the source is exhausted.

This is a simplified replacement for NodeParser.ParseNext() that handles the core incremental parsing use case.

Types

type ParseOption

type ParseOption func(*parseOpts)

func NoBrackets

func NoBrackets() ParseOption

func ParseComments

func ParseComments(v bool) ParseOption

func ParseFormat

func ParseFormat(f format.Format) ParseOption

func ParseJSON

func ParseJSON() ParseOption

func ParsePositions

func ParsePositions(m map[*ir.Node]*token.Pos) ParseOption

func ParseTony

func ParseTony() ParseOption

func ParseYAML

func ParseYAML() ParseOption

Jump to

Keyboard shortcuts

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