parse

package
v1.67.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PluralOne   = PluralCategory("one")
	PluralOther = PluralCategory("other")
	PluralValue = PluralCategory("value")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ListNode

type ListNode struct {
	NodeType
	Nodes []Node
}

func (*ListNode) String

func (l *ListNode) String() string

type Node

type Node interface {
	Type() NodeType
	String() string
}

type NodeType

type NodeType int

NodeType identifies the type of a parse tree node.

const (
	NodeText NodeType = iota
	NodeList
	NodeVariable
	NodePlural
	NodePluralCase
)

func (NodeType) Type

func (t NodeType) Type() NodeType

Type returns itself and provides an easy default implementation for embedding in a Node. Embedded in all non-trivial Nodes.

type PluralCase

type PluralCase struct {
	NodeType
	Value    int
	Category PluralCategory
	Content  *ListNode
}

func (*PluralCase) String

func (p *PluralCase) String() string

type PluralCategory

type PluralCategory string

type PluralNode

type PluralNode struct {
	NodeType
	Variable string
	Cases    []*PluralCase
	Offset   int
}

func (*PluralNode) String

func (p *PluralNode) String() string

type TextNode

type TextNode struct {
	NodeType
	Text string
}

func (*TextNode) String

func (node *TextNode) String() string

type Tree

type Tree struct {
	Root *ListNode
	// contains filtered or unexported fields
}

func Parse

func Parse(text string) (*Tree, error)

func (*Tree) String

func (t *Tree) String() string

type VariableNode

type VariableNode struct {
	NodeType
	Name string
}

func (*VariableNode) String

func (v *VariableNode) String() string

Jump to

Keyboard shortcuts

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