goparsecomb

module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT

README

goparsecomb

Go Reference

Go Parser Combinator with Go Generics.

How to use

currently this library is so simple. you only should follow 2 steps as below.

  • initializes parser.Parser[I, O]
  • call func (p Parser[I, O]) Parse(input I) (I, O, parser.ParseError) method

Example

package main

import (
    "github.com/Drumato/goparsecomb/pkg/strparse"
    "github.com/Drumato/goparsecomb/pkg/combinator"
)

func main() {
	element := strparse.Digit1()
	separator := strparse.Rune('|')
	p := combinator.Separated1(element, separator)
	i, o, err := p.Parse([]rune("123|456|789Drumato"))
	fmt.Println(i)
	fmt.Printf("%d\n", o)
	fmt.Printf("%s %s %s\n", o[0], o[1], o[2])
	fmt.Println(err)
}
$ go run main.go
Drumato
123 456 789
3
<nil>

Directories

Path Synopsis
examples
pkg
byteparse
package byteparse provides a binary parser and utilities.
package byteparse provides a binary parser and utilities.
combinator
package combinator provides additional parsers that combines parsers.
package combinator provides additional parsers that combines parsers.
parser
package parser provides abstract interfaces.
package parser provides abstract interfaces.
strparse
package strparse provides a string parser and utilities.
package strparse provides a string parser and utilities.

Jump to

Keyboard shortcuts

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