parser

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package parser provides entities and methods to perform Parsing Expression Grammer parsing on scientific names.

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) Debug added in v1.1.0

func (p *Engine) Debug(s string) []byte

Debug takes a string, parsers it, and returns a byte representation of the node tree

func (*Engine) Init

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

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,
	capitalize bool,
	enableCultivars bool,
	preserveDiaereses 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) SprintSyntaxTree added in v1.1.0

func (p *Engine) SprintSyntaxTree() string

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, capitalize, enableCultivars, preserveDiaereses bool,
	) ScientificNameNode
	Debug(name string) []byte
}

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 New

func New() Parser

New creates implementation of Parser interface.

type ScientificNameNode

type ScientificNameNode interface {
	// ToOutput converts AST into final output object.
	ToOutput(withDetails, withSpGr bool) parsed.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