gnparser

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: MIT Imports: 9 Imported by: 3

README

gnparser

Documentation

Index

Constants

View Source
const (
	Compact format = iota
	Pretty
	Simple
	Debug
)

Variables

This section is empty.

Functions

func AvailableFormats

func AvailableFormats() []string

AvailableFormats function returns a string representation of supported output formats.

func StrToFormat

func StrToFormat(s string) format

StrToFormat function creates an internal type of a supported format out of string.

Types

type GNparser

type GNparser struct {
	// contains filtered or unexported fields
}

GNparser is responsible for parsing operations.

func NewGNparser

func NewGNparser(opts ...Option) GNparser

NewGNparser constructor function takes options and returns configured GNparser.

func (*GNparser) Build

func (gnp *GNparser) Build() string

Build returns date and time when gnparser was built

func (*GNparser) Debug

func (gnp *GNparser) Debug(s string) []byte

Debug returns byte representation of complete and 'output' syntax trees.

func (*GNparser) OutputFormat

func (gnp *GNparser) OutputFormat() string

OutputForat returns string representation of the current output format for GNparser

func (*GNparser) Parse

func (gnp *GNparser) Parse(s string)

Parse function parses input using GNparser's supplied options. The abstract syntax tree formed by the parser is stored in an `gnp.parser.SN` field.

func (*GNparser) ParseAndFormat

func (gnp *GNparser) ParseAndFormat(s string) (string, error)

ParseAndFormat function parses input and formats results according to format setting of GNparser.

func (*GNparser) ParseStream

func (gnp *GNparser) ParseStream(in <-chan string, out chan<- *ParseResult,
	opts ...Option)

ParseStream function takes input/output channels to do concurrent parsing jobs. Output is pushed as ParseResult objects.

func (*GNparser) ParsedName

func (gnp *GNparser) ParsedName() string

ParsedName returns the string of parsed result without a tail.

func (GNparser) String

func (of GNparser) String() string

func (*GNparser) ToJSON

func (gnp *GNparser) ToJSON() ([]byte, error)

ToJSON function creates a 'compact' output out of parsed results.

func (*GNparser) ToPrettyJSON

func (gnp *GNparser) ToPrettyJSON() ([]byte, error)

ToPrettyJSON function creates pretty JSON output out of parsed results.

func (*GNparser) ToSlice

func (gnp *GNparser) ToSlice() []string

ToSlice function creates a flat simplified output of parsed results.

func (*GNparser) Version

func (gnp *GNparser) Version() string

Version function returns version number of `gnparser`.

func (*GNparser) WorkersNum

func (gnp *GNparser) WorkersNum() int

type Option

type Option func(*GNparser)

Option is a function that creates a new option for GNparser.

func Format

func Format(f string) Option

Format Option sets the output format to return/display parsing results.

func IsTest

func IsTest() Option

func WorkersNum

func WorkersNum(wn int) Option

WorkersNum Option sets the quantity of workers to run parsing jobs.

type ParseResult

type ParseResult struct {
	Output string
	Error  error
}

ParseResult structure contains parsing output and/or error generated by the parser.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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