parser

package
v0.0.0-...-bb33fa6 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParseOptions

type ParseOptions struct {
	LogFunc func(format string, args ...any)
}

type Parser

type Parser[T any] struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser[T any](rules ...*Rule[T]) *Parser[T]

func (*Parser[T]) AddRule

func (parser *Parser[T]) AddRule(rule *Rule[T])

func (*Parser[T]) Parse

func (parser *Parser[T]) Parse(options ParseOptions, tokens ...Token[T]) (Token[T], error)

type ParserToken

type ParserToken[T any] struct {
	// contains filtered or unexported fields
}

func NewParserToken

func NewParserToken[T any](name string, value T) *ParserToken[T]

func (ParserToken[T]) Name

func (token ParserToken[T]) Name() string

func (ParserToken[T]) String

func (token ParserToken[T]) String() string

func (ParserToken[T]) Value

func (token ParserToken[T]) Value() T

type Rule

type Rule[T any] struct {
	// contains filtered or unexported fields
}

func NewRule

func NewRule[T any](name string, pattern string, handler func(tokens []Token[T]) T) *Rule[T]

func (Rule[T]) CompareTokens

func (rule Rule[T]) CompareTokens(tokens []Token[T]) bool

func (Rule[T]) String

func (rule Rule[T]) String() string

type Token

type Token[T any] interface {
	Name() string
	Value() T
	String() string
}

Jump to

Keyboard shortcuts

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