peachcomb

module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: MIT

README

peachcomb

Go Reference

Go Parser Combinator with Go Generics.

Roadmap

  • stream input type
  • complete input type
  • custom input types
  • combinator
  • string parser
  • bytes parser
  • examples
    • JSON parser
    • HTTP parser
    • tiny tree-walked interpreter

How to use

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

  • initializes parser.Parser[I, O]
  • call the parser

Examples

(WIP) JSON Parser
$ go run ./examples/jsonparser/ examples/jsonparser/example.json
{[{[a b] 2} {[c d] 2} {[e f] 2}] 3}
Simplest Case
package main

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

func main() {
	element := strparse.Digit1()
	separator := strparse.Rune('|')
	p := combinator.Separated1(element, separator)

	i := strparse.NewCompleteInput("123|456|789Drumato")
	_, o, err := p(i)
	fmt.Printf("%d\n", len(o))
	fmt.Printf("%s %s %s\n", o[0], o[1], o[2])
	fmt.Println(err)
}
$ go run main.go
3
123 456 789
<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