parser

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Pretty

func Pretty(pretty bool) func(*Engine) error

func Size

func Size(size int) func(*Engine) error

Types

type Engine

type Engine struct {
	Buffer string

	Pretty bool
	// contains filtered or unexported fields
}

func (*Engine) AST

func (t *Engine) AST() *node32

func (*Engine) Add

func (t *Engine) Add(rule pegRule, begin, end, index uint32)

func (*Engine) Init

func (p *Engine) Init(options ...func(*Engine) error) error

func (*Engine) OutputAST

func (p *Engine) OutputAST()

OutputAST assembles PEG nodes AST structure.

func (*Engine) Parse

func (p *Engine) Parse(rule ...int) error

func (*Engine) ParsedName

func (p *Engine) ParsedName() string

ParseName returns the name the nodes. In case of parsing errors returns string 'noparse'.

func (*Engine) PreprocessAndParse

func (p *Engine) PreprocessAndParse(
	s, ver string,
	keepHTML bool,
) ScientificNameNode

PreprocessAndParse takes a string and returns back the Abstract Syntax Tree of the scientific names. The AST is later used to create the final output.

func (*Engine) PrettyPrintSyntaxTree

func (t *Engine) PrettyPrintSyntaxTree(buffer string)

func (*Engine) Print

func (t *Engine) Print()

func (*Engine) PrintOutputSyntaxTree

func (p *Engine) PrintOutputSyntaxTree(w io.Writer)

PrintOutputSyntaxTree outputs a simplified version of a nodes Abstract Syntax Tree. This method can be used for debugging purposes.

func (*Engine) PrintSyntaxTree

func (p *Engine) PrintSyntaxTree()

func (*Engine) Reset

func (p *Engine) Reset()

func (*Engine) Tokens

func (t *Engine) Tokens() []token32

func (*Engine) Trim

func (t *Engine) Trim(length uint32)

func (*Engine) WriteSyntaxTree

func (p *Engine) WriteSyntaxTree(w io.Writer)

type Parser

type Parser interface {
	// PreprocessAndParse takes a scientific name and returns back Abstract
	// Syntax Tree of the name-string.
	PreprocessAndParse(name, version string, keepHTML bool) ScientificNameNode
}

Parser is an interface that is responsible for parsing of a scientific name and creation of the Abstract Syntax Tree of the name-string.

func NewParser

func NewParser() Parser

NewParser creates implementation of Parser interface.

type ScientificNameNode

type ScientificNameNode interface {
	// ToOutput converts AST into final output object.
	ToOutput(withDetails bool) o.Parsed
}

ScientificNameNode is the Abstract Syntax Tree of a name-string. It contains a method to convert AST into final output.

Jump to

Keyboard shortcuts

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