treeificator – git.mstar.dev/mstar/treeificator Index | Files

package treeificator

import "git.mstar.dev/mstar/treeificator"

Index

Types

type DefaultInformer

type DefaultInformer struct{}

Defa

func (*DefaultInformer) GetName

func (defaultinformer *DefaultInformer) GetName() string

func (*DefaultInformer) GetPrefix

func (defaultinformer *DefaultInformer) GetPrefix() string

func (*DefaultInformer) GetSuffix

func (defaultinformer *DefaultInformer) GetSuffix() string

type Informer

type Informer interface {
	// Get the prefix starting the informer's node type
	GetPrefix() string
	// Get the suffix starting the informer's node type
	GetSuffix() string
	// Get the name of the node type.
	// Each name (in lowercase) may only exist once. The parser will enforce this.
	// No guaranteed order for which informer will be used if multiple with the same name are in use.
	// The name "default" is occupied by the built-in default informer for just strings
	GetName() string
}

Informers inform the parser about the prefix and suffix that make up a node

type Node

type Node struct {
	// What kind of node this is
	NodeType Informer
	// The elements in this node, ordered by appearance
	Elements []NodeElement
}

func Marshal

func Marshal(raw string, informers ...Informer) Node

func (*Node) Unmarshal

func (n *Node) Unmarshal() string

Unmarshal a node into the string it got constructed from

type NodeElement

type NodeElement struct {
	Text *string
	Node *Node
}

An element in a node. Either a string or another node. Leaf elements will always be a string. Root element will always be a [DefaultInformaer].

func (*NodeElement) Unmarshal

func (e *NodeElement) Unmarshal() string

Unmarshal an element into the string it got constructed from

Source Files

informer.go node.go parser.go

Version
v1.0.1 (latest)
Published
May 2, 2025
Platform
linux/amd64
Imports
2 packages
Last checked
now

Tools for package owners.