errors

package
v0.0.0-...-1dacd80 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unexpected

func Unexpected[T stream.Token](message string) parser.Func[T, any]

Unexpected always fails with `message` as an unexpected error. Never consumes any input.

Example
package main

import (
	"fmt"

	"github.com/flier/gocombine/pkg/parser/char"
	"github.com/flier/gocombine/pkg/parser/choice"
	"github.com/flier/gocombine/pkg/parser/combinator"
	"github.com/flier/gocombine/pkg/parser/errors"
)

func main() {
	p := choice.Or(combinator.Ignore(char.Char('a')), errors.Unexpected[rune]("token"))

	fmt.Println(p([]rune("b")))

}
Output:

<nil> [98] or, 2 errors occurred:
	* ignore, char, expected 'a', actual 'b', unexpected
	* token, unexpected

Types

This section is empty.

Jump to

Keyboard shortcuts

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