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) Init(options ...func(*Engine) error) error
- func (p *Engine) OutputAST()
- func (p *Engine) Parse(rule ...int) error
- func (p *Engine) ParsedName() string
- func (p *Engine) PreprocessAndParse(s, ver string, keepHTML 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 (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) OutputAST ¶
func (p *Engine) OutputAST()
OutputAST assembles PEG nodes AST structure.
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, 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) 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) 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, 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.
type ScientificNameNode ¶
type ScientificNameNode interface { // ToOutput converts AST into final output object. ToOutput(withDetails bool) parsed.Parsed }
ScientificNameNode is the Abstract Syntax Tree of a name-string. It contains a method to convert AST into final output.