This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
Think about changing "consume" to "commit"
|
Think about changing "consume" to "commit"
|
||||||
What's Megaparsec got that we ain't got?
|
What’s Megaparsec got that we ain’t got?
|
||||||
chainl
|
chainl
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
package gigaparsec
|
package gigaparsec
|
||||||
|
|
||||||
// Bind combines p with a parser created by f that depends on p's result value.
|
// Bind combines p with a parser created by f that depends on p’s result value.
|
||||||
func Bind[In, Out, T any](
|
func Bind[In, Out, T any](
|
||||||
p Parser[In, T],
|
p Parser[In, T],
|
||||||
f func(T) Parser[In, Out],
|
f func(T) Parser[In, Out],
|
||||||
|
|||||||
+4
-4
@@ -134,7 +134,7 @@ func MessageEnd(pos uint64, expected ...string) Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MakeState creates a new State.
|
// MakeState creates a new State.
|
||||||
// It's mostly useful for testing. You probably don't need it.
|
// It’s mostly useful for testing. You probably don’t need it.
|
||||||
func MakeState[In any](r ReaderAt[In]) State[In] {
|
func MakeState[In any](r ReaderAt[In]) State[In] {
|
||||||
return State[In]{r: r}
|
return State[In]{r: r}
|
||||||
}
|
}
|
||||||
@@ -145,12 +145,12 @@ type State[In any] struct {
|
|||||||
pos uint64
|
pos uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read fills dst with data from this State's position in the underlying source.
|
// Read fills dst with data from this State’s position in the underlying source.
|
||||||
// It returns the number of data it read and a new State for the position at which
|
// It returns the number of data it read and a new State for the position at which
|
||||||
// the read ended, and an error if the read either (1) failed or (2) reached the
|
// the read ended, and an error if the read either (1) failed or (2) reached the
|
||||||
// end of the source before filling dst. All reads from a given State will return
|
// end of the source before filling dst. All reads from a given State will return
|
||||||
// data from the same position the source.
|
// data from the same position the source.
|
||||||
// If the source had too few data left to fill dst, or if the State's position is
|
// If the source had too few data left to fill dst, or if the State’s position is
|
||||||
// at or past the end of the source, err will be io.EOF.
|
// at or past the end of the source, err will be io.EOF.
|
||||||
func (s State[In]) Read(dst []In) (n uint64, next State[In], err error) {
|
func (s State[In]) Read(dst []In) (n uint64, next State[In], err error) {
|
||||||
if s.pos > math.MaxInt64 {
|
if s.pos > math.MaxInt64 {
|
||||||
@@ -169,7 +169,7 @@ func (s State[In]) Read(dst []In) (n uint64, next State[In], err error) {
|
|||||||
return uint64(nread), s, err
|
return uint64(nread), s, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pos returns this State's position.
|
// Pos returns this State’s position.
|
||||||
func (s State[In]) Pos() uint64 {
|
func (s State[In]) Pos() uint64 {
|
||||||
return s.pos
|
return s.pos
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
{{end}}{{end}}{{end -}}
|
{{end}}{{end}}{{end -}}
|
||||||
|
|
||||||
{{define "func" -}}
|
{{define "func" -}}
|
||||||
{{if eq . 1}}// Bind combines p with a parser created by f that depends on p's result value.
|
{{if eq . 1}}// Bind combines p with a parser created by f that depends on p’s result value.
|
||||||
{{- else}}// Bind{{.}} is equivalent to {{.}} nested calls to Bind.{{end}}
|
{{- else}}// Bind{{.}} is equivalent to {{.}} nested calls to Bind.{{end}}
|
||||||
func Bind{{.}}[In, Out{{range .Count}}, T{{.}}{{end}} any](
|
func Bind{{.}}[In, Out{{range .Count}}, T{{.}}{{end}} any](
|
||||||
p Parser[In, T],
|
p Parser[In, T],
|
||||||
|
|||||||
Reference in New Issue
Block a user