parser

package module
v0.0.0-...-6f4acf8 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2014 License: MIT Imports: 7 Imported by: 1

README

go-hranoprovod-parser Build Status GoDoc

Go hranoprovod file parser

Sample usage:

prsr := parser.NewParser(parser.NewDefaultOptions())
go prsr.ParseFile("data.yaml")
err := func() error {
	for {
		select {
		case node := <-prsr.Nodes:
			print(node.Header)
		case err := <-prsr.Errors:
			return err
		case <-prsr.Done:
			return nil
		}
	}
}()

Documentation

Overview

Package parser provides function to parse hrandoprovod formatted files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorBadSyntax

type ErrorBadSyntax struct {
	LineNumber int
	Line       string
}

ErrorBadSyntax used when the stream contains bad syntax

func NewErrorBadSyntax

func NewErrorBadSyntax(lineNumber int, line string) *ErrorBadSyntax

NewErrorBadSyntax creates new ErrorBadSyntax error

func (*ErrorBadSyntax) Error

func (e *ErrorBadSyntax) Error() string

Error returns the error message

type ErrorConversion

type ErrorConversion struct {
	Text       string
	LineNumber int
	Line       string
}

ErrorConversion raised when the element value cannot be parsed as float

func NewErrorConversion

func NewErrorConversion(text string, lineNumber int, line string) *ErrorConversion

NewErrorConversion creates new ErrorConversion error

func (*ErrorConversion) Error

func (e *ErrorConversion) Error() string

Error returns the error message

type ErrorIO

type ErrorIO struct {
	FileName string
	// contains filtered or unexported fields
}

ErrorIO raised on IO issue

func NewErrorIO

func NewErrorIO(err error, fileName string) *ErrorIO

NewErrorIO creates new IO Error

func (*ErrorIO) Error

func (e *ErrorIO) Error() string

Error returns the error message

type Options

type Options struct {
	// CommentChar contains the character used to indicate that the line is a comment
	CommentChar uint8
}

Options contains the parser related options

func NewDefaultOptions

func NewDefaultOptions() *Options

NewDefaultOptions returns the default set of parser options

type Parser

type Parser struct {
	Nodes  chan *shared.Node
	Errors chan error
	Done   chan bool
	// contains filtered or unexported fields
}

Parser is the parser data structure

func NewParser

func NewParser(options *Options) *Parser

NewParser returns new parser

func (*Parser) ParseFile

func (p *Parser) ParseFile(fileName string)

ParseFile parsers the contents of file

func (*Parser) ParseStream

func (p *Parser) ParseStream(reader io.Reader)

ParseStream parses the contents of stream

Jump to

Keyboard shortcuts

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