parser

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: MPL-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package parser contains the main structs for parsing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(h parsley.History, leftRecCtx data.IntMap, r parsley.Reader, pos parsley.Pos) (parsley.Node, parsley.Error, data.IntSet)

Func defines a helper to implement the Parser interface with functions

func Nil added in v0.6.0

func Nil() Func

Nil always matches and returns with an nil node result

func (Func) Name added in v0.6.0

func (f Func) Name() string

Name returns with an empty name

func (Func) Parse

func (f Func) Parse(h parsley.History, leftRecCtx data.IntMap, r parsley.Reader, pos parsley.Pos) (parsley.Node, parsley.Error, data.IntSet)

Parse parses the input using the function

func (Func) WithName added in v0.6.0

func (f Func) WithName(name interface{}) *NamedFunc

WithName returns with the same parser function but with the given name If a function is passed then it will be called when Name() is called

type History

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

History records information about parser calls

func NewHistory

func NewHistory() *History

NewHistory creates a history instance

func (*History) CallCount

func (h *History) CallCount() int

CallCount returns with the call count

func (*History) GetResult added in v0.6.0

func (h *History) GetResult(parserIndex int, pos parsley.Pos, leftRecCtx data.IntMap) (*parsley.Result, bool)

GetResult return with a previously saved result

func (*History) RegisterCall

func (h *History) RegisterCall()

RegisterCall registers a call

func (*History) SaveResult added in v0.6.0

func (h *History) SaveResult(parserIndex int, pos parsley.Pos, result *parsley.Result)

SaveResult registers a parser result for a certain position

type NamedFunc added in v0.6.0

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

NamedFunc is a parser function with a custom name

func End

func End() *NamedFunc

End matches the end of the input

func (*NamedFunc) Name added in v0.6.0

func (nf *NamedFunc) Name() string

Name returns with the parser name

func (*NamedFunc) Parse added in v0.6.0

func (nf *NamedFunc) Parse(h parsley.History, leftRecCtx data.IntMap, r parsley.Reader, pos parsley.Pos) (parsley.Node, parsley.Error, data.IntSet)

Parse parses the input using the function

Jump to

Keyboard shortcuts

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