Documentation ¶
Overview ¶
Package parser provides entities and methods to perform Parsing Expression Grammer parsing on scientific names.
Index ¶
- func Pretty(pretty bool) func(*Engine) error
- func Size(size int) func(*Engine) error
- type Engine
- func (t *Engine) AST() *node32
- func (t *Engine) Add(rule pegRule, begin, end, index uint32)
- func (p *Engine) Debug(s string) []byte
- func (p *Engine) Init(options ...func(*Engine) error) error
- func (p *Engine) Parse(rule ...int) error
- func (p *Engine) ParsedName() string
- func (p *Engine) PreprocessAndParse(s, ver string, code nomcode.Code, keepHTML bool, capitalize bool, ...) ScientificNameNode
- func (t *Engine) PrettyPrintSyntaxTree(buffer string)
- func (t *Engine) Print()
- func (p *Engine) PrintOutputSyntaxTree(w io.Writer)
- func (p *Engine) PrintSyntaxTree()
- func (p *Engine) Reset()
- func (p *Engine) SprintSyntaxTree() string
- func (t *Engine) Tokens() []token32
- func (t *Engine) Trim(length uint32)
- func (p *Engine) WriteSyntaxTree(w io.Writer)
- type Parser
- type ScientificNameNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Engine ¶
func (*Engine) Debug ¶ added in v1.1.0
Debug takes a string, parsers it, and returns a byte representation of the node tree
func (*Engine) ParsedName ¶
ParseName returns the name the nodes. In case of parsing errors returns string 'noparse'.
func (*Engine) PreprocessAndParse ¶
func (p *Engine) PreprocessAndParse( s, ver string, code nomcode.Code, keepHTML bool, capitalize 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) PrintOutputSyntaxTree ¶
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) SprintSyntaxTree ¶ added in v1.1.0
func (*Engine) WriteSyntaxTree ¶
type Parser ¶
type Parser interface { // PreprocessAndParse takes a scientific name and returns back Abstract // Syntax Tree of the name-string. PreprocessAndParse( name, version string, code nomcode.Code, keepHTML, capitalize, 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.
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.