comb

package
v0.0.0-...-89dfc66 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser func() (interface{}, error)

Parser is a type of parsers as a function which returns a parsing result or an error.

type State

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

State represents a parser state.

func NewState

func NewState(source string) *State

NewState creates a parser state.

func (*State) And

func (s *State) And(ps ...Parser) Parser

And creates a parser combining given parsers sequentially.

func (*State) App

func (s *State) App(f func(interface{}) interface{}, p Parser) Parser

App applies a function to results of a given parser.

func (*State) Char

func (s *State) Char(r rune) Parser

Char creates a parser parsing a character.

func (*State) Chars

func (s *State) Chars(cs string) Parser

Chars creates a parser parsing a character in a given string.

func (*State) Exhaust

func (s *State) Exhaust(p Parser, f func(State) error) Parser

Exhaust creates a parser which fails when a source string is not exhausted after running a given parser.

func (*State) Lazy

func (s *State) Lazy(f func() Parser) Parser

Lazy evaluates and runs a given parser constructor. This is useful to define recursive parsers.

func (*State) Line

func (s *State) Line() string

Line returns a current line.

func (*State) LineNumber

func (s *State) LineNumber() int

LineNumber returns a current line number.

func (State) LinePosition

func (s State) LinePosition() int

LinePosition returns a position in a current line.

func (*State) Many

func (s *State) Many(p Parser) Parser

Many creates a parser of more than or equal to 0 reptation of a given parser.

func (*State) Many1

func (s *State) Many1(p Parser) Parser

Many1 creates a parser of more than 0 reptation of a given parser.

func (*State) Maybe

func (s *State) Maybe(p Parser) Parser

Maybe creates a parser which runs a given parser or parses nothing when it fails.

func (*State) None

func (s *State) None() Parser

None creates a parser which parses nothing and succeeds always.

func (*State) NotChar

func (s *State) NotChar(r rune) Parser

NotChar creates a parser parsing a character which is not one of an argument.

func (*State) NotChars

func (s *State) NotChars(str string) Parser

NotChars creates a parser parsing a character not in a given string.

func (*State) Or

func (s *State) Or(ps ...Parser) Parser

Or creates a selectional parser from given parsers.

func (*State) Prefix

func (s *State) Prefix(pre, p Parser) Parser

Prefix creates a parser with a prefix parser and content parser and returns the latter's result.

func (*State) String

func (s *State) String(str string) Parser

String creates a parser parsing a string.

func (*State) Stringify

func (s *State) Stringify(p Parser) Parser

Stringify creates a parser which returns a string converted from a result of a given parser. The result of a given parser must be a rune, a string or a sequence of them in []interface{}.

func (State) Void

func (State) Void(p Parser) Parser

Void creates a parser whose result is always nil from a given parser.

func (*State) Wrap

func (s *State) Wrap(l, m, r Parser) Parser

Wrap wraps a parser with parsers which parse something on the leftside and rightside of it and creates a new parser. Its parsing result will be m's.

Jump to

Keyboard shortcuts

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