parser

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: MPL-2.0 Imports: 5 Imported by: 2

Documentation

Overview

Package parser contains the main structs for parsing

Index

Constants

View Source
const EOF = "EOF"

EOF is the end-of-file token

Variables

This section is empty.

Functions

This section is empty.

Types

type EndNode added in v0.17.0

type EndNode parsley.Pos

EndNode represents an eof node

func (EndNode) Pos added in v0.17.0

func (e EndNode) Pos() parsley.Pos

Pos returns with the position

func (EndNode) ReaderPos added in v0.17.0

func (e EndNode) ReaderPos() parsley.Pos

ReaderPos returns the reader position

func (EndNode) Schema added in v0.17.0

func (e EndNode) Schema() interface{}

Schema returns with nil

func (EndNode) SetReaderPos added in v0.17.0

func (e EndNode) SetReaderPos(func(parsley.Pos) parsley.Pos)

SetReaderPos changes the reader position

func (EndNode) String added in v0.17.0

func (e EndNode) String() string

String returns with a string representation of the node

func (EndNode) Token added in v0.17.0

func (e EndNode) Token() string

Token returns with EOF

func (EndNode) Value added in v0.17.0

func (e EndNode) Value(userCtx interface{}) (interface{}, parsley.Error)

Value returns with nil

type Func

type Func func(ctx *parsley.Context, leftRecCtx data.IntMap, pos parsley.Pos) (parsley.Node, data.IntSet, parsley.Error)

Func defines a helper to implement the Parser interface with functions

func Empty

func Empty() Func

Empty always matches and returns with an empty node result

func End

func End() Func

End matches the end of the input

func ReturnError added in v0.17.0

func ReturnError(p parsley.Parser, customErr error) Func

ReturnError will override the returned error by the parser if its position is the same as the reader's position

func (Func) Name added in v0.6.0

func (f Func) Name(name string) Func

Name returns with a new parser function which overrides the returned error if its position is the same as the reader's position The error will be: "was expecting <name>"

func (Func) Parse

func (f Func) Parse(ctx *parsley.Context, leftRecCtx data.IntMap, pos parsley.Pos) (parsley.Node, data.IntSet, parsley.Error)

Parse parses the input using the function

type FuncWrapper added in v0.17.0

type FuncWrapper struct {
	F Func
}

FuncWrapper is a parser which wraps a parser function as a struct It's useful when you have to use a parser recursively as that's not possible with functions

func (FuncWrapper) Parse added in v0.17.0

func (f FuncWrapper) Parse(ctx *parsley.Context, leftRecCtx data.IntMap, pos parsley.Pos) (parsley.Node, data.IntSet, parsley.Error)

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