Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d1f4940ce | ||
|
|
7560d53d62 | ||
|
|
18ad9c301a |
@@ -1,6 +1,5 @@
|
||||
Think about not requiring so much Pos() when making messages
|
||||
Think about changing "consume" to "commit"
|
||||
Document Seq
|
||||
Should MakeState be private now that there's Run?
|
||||
What's Megaparsec got that we ain't got?
|
||||
chainl
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ func Token[Out, WSOut any](whitespace gigaparsec.Parser[byte, WSOut]) func(p gig
|
||||
return result.Consume(false), err
|
||||
}
|
||||
return func(p gigaparsec.Parser[byte, Out]) gigaparsec.Parser[byte, Out] {
|
||||
return gigaparsec.Seq2(p, gigaparsec.Repeat(0, ignoreWS), func(val Out, _ []struct{}) Out { return val })
|
||||
return gigaparsec.Seq(p, gigaparsec.Repeat(0, ignoreWS), func(val Out, _ []struct{}) Out { return val })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{{/* SPDX-License-Identifier: Unlicense */ -}}
|
||||
|
||||
{{define "func"}}{{if gt . 1 -}}
|
||||
// Seq{{if gt . 2}}{{.}}{{end}} runs {{.}} parsers in sequence and maps their collected results with f.
|
||||
func Seq{{if gt . 2}}{{.}}{{end}}[In, Out{{range .Count}}, T{{.}}{{end}} any](
|
||||
{{- range .Count}}
|
||||
p{{.}} Parser[In, T{{.}}],{{end}}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ func Bind9[In, Out, T, T2, T3, T4, T5, T6, T7, T8, T9 any](
|
||||
return gp.Bind(gp.Bind(gp.Bind(gp.Bind(gp.Bind(gp.Bind(gp.Bind(gp.Bind(gp.Bind(p, f), f2), f3), f4), f5), f6), f7), f8), f9)
|
||||
}
|
||||
|
||||
func Seq2[In, Out, T, T2 any](
|
||||
func Seq[In, Out, T, T2 any](
|
||||
p gp.Parser[In, T],
|
||||
p2 gp.Parser[In, T2],
|
||||
f func(T, T2) Out,
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import (
|
||||
"pgregory.net/rapid"
|
||||
)
|
||||
|
||||
func Todo(t *testing.T) {
|
||||
func Todo[T interface{Errorf(string,...any)}](t T) {
|
||||
t.Errorf("TODO")
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ func TestBind(t *testing.T) {
|
||||
t.Run("returns an error if the second parser returns an error", Todo)
|
||||
t.Run("succeeds if both parsers succeed", rapid.MakeCheck(func(t *rapid.T) {
|
||||
// s := rapid.SliceOfN(rapid.Byte(), 0, 100)
|
||||
t.Errorf("TODO")
|
||||
Todo(t)
|
||||
}))
|
||||
/*
|
||||
If the first parser fails, then consumption depends on the first parser.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
package gigaparsec
|
||||
|
||||
// Seq runs 2 parsers in sequence and maps their collected results with f.
|
||||
func Seq[In, Out, T, T2 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -38,6 +39,7 @@ func Seq[In, Out, T, T2 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq3 runs 3 parsers in sequence and maps their collected results with f.
|
||||
func Seq3[In, Out, T, T2, T3 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -83,6 +85,7 @@ func Seq3[In, Out, T, T2, T3 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq4 runs 4 parsers in sequence and maps their collected results with f.
|
||||
func Seq4[In, Out, T, T2, T3, T4 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -139,6 +142,7 @@ func Seq4[In, Out, T, T2, T3, T4 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq5 runs 5 parsers in sequence and maps their collected results with f.
|
||||
func Seq5[In, Out, T, T2, T3, T4, T5 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -206,6 +210,7 @@ func Seq5[In, Out, T, T2, T3, T4, T5 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq6 runs 6 parsers in sequence and maps their collected results with f.
|
||||
func Seq6[In, Out, T, T2, T3, T4, T5, T6 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -284,6 +289,7 @@ func Seq6[In, Out, T, T2, T3, T4, T5, T6 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq7 runs 7 parsers in sequence and maps their collected results with f.
|
||||
func Seq7[In, Out, T, T2, T3, T4, T5, T6, T7 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -373,6 +379,7 @@ func Seq7[In, Out, T, T2, T3, T4, T5, T6, T7 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq8 runs 8 parsers in sequence and maps their collected results with f.
|
||||
func Seq8[In, Out, T, T2, T3, T4, T5, T6, T7, T8 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
@@ -473,6 +480,7 @@ func Seq8[In, Out, T, T2, T3, T4, T5, T6, T7, T8 any](
|
||||
}
|
||||
}
|
||||
|
||||
// Seq9 runs 9 parsers in sequence and maps their collected results with f.
|
||||
func Seq9[In, Out, T, T2, T3, T4, T5, T6, T7, T8, T9 any](
|
||||
p Parser[In, T],
|
||||
p2 Parser[In, T2],
|
||||
|
||||
Reference in New Issue
Block a user