parser

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 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 Trie

type Trie[K, V any] struct {
	// contains filtered or unexported fields
}

though generic it is only meant to be used with K = *token.Token and V = ast.Alias

func New

func New[K, V any](key_eq, key_less orderedmap.CompFunc[K]) *Trie[K, V]

create a new trie should only be used with K = *token.Token and V = ast.Alias

func (*Trie[K, V]) Contains

func (t *Trie[K, V]) Contains(keys []K) (bool, V)

strictly checks if the given keys are in the trie returns either the value for the key or nil

func (*Trie[K, V]) Insert

func (t *Trie[K, V]) Insert(key []K, value V)

insert a value into the trie

func (*Trie[K, V]) PrettyPrint

func (t *Trie[K, V]) PrettyPrint(k_print func(K) string, v_print func(V) string)

pretty prints the trie

func (*Trie[K, V]) Search

func (t *Trie[K, V]) Search(keys TrieKeyGen[K]) []V

finds all values that match the given keys and all values encountered on the way

type TrieKeyGen

type TrieKeyGen[K any] func(int, K) (K, bool)

generate keys for the trie it is given a unique, incrementing index for the node visited and the key of the possible child should return false if there are no keys left on the path should not be stateful or be able to revert to a previous state using the index

Jump to

Keyboard shortcuts

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