2024-09-14 02:48:33 +00:00
|
|
|
// GENERATED FILE. DO NOT EDIT.
|
|
|
|
|
2024-09-18 22:28:53 +00:00
|
|
|
// SPDX-License-Identifier: Unlicense
|
|
|
|
|
2024-09-14 02:48:33 +00:00
|
|
|
package gigaparsec
|
|
|
|
|
|
|
|
func Seq2[In, Out, T, T2 any](
|
|
|
|
p Parser[In, T],
|
|
|
|
p2 Parser[In, T2],
|
|
|
|
f func(T, T2) Out,
|
|
|
|
) Parser[In, Out] {
|
|
|
|
return func(s State[In]) (Result[In, Out], error) {
|
|
|
|
var anyConsumed bool
|
|
|
|
var next = s
|
|
|
|
|
|
|
|
r, err := p(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val, next := r.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r2, err := p2(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val2, next := r2.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final := f(val, val2)
|
|
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
|
|
}
|
|
|
|
}
|
2024-09-14 03:03:10 +00:00
|
|
|
|
2024-09-14 02:48:33 +00:00
|
|
|
func Seq3[In, Out, T, T2, T3 any](
|
|
|
|
p Parser[In, T],
|
|
|
|
p2 Parser[In, T2],
|
|
|
|
p3 Parser[In, T3],
|
|
|
|
f func(T, T2, T3) Out,
|
|
|
|
) Parser[In, Out] {
|
|
|
|
return func(s State[In]) (Result[In, Out], error) {
|
|
|
|
var anyConsumed bool
|
|
|
|
var next = s
|
|
|
|
|
|
|
|
r, err := p(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val, next := r.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r2, err := p2(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val2, next := r2.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r3, err := p3(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val3, next := r3.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final := f(val, val2, val3)
|
|
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
|
|
}
|
|
|
|
}
|
2024-09-14 03:03:10 +00:00
|
|
|
|
2024-09-14 02:48:33 +00:00
|
|
|
func Seq4[In, Out, T, T2, T3, T4 any](
|
|
|
|
p Parser[In, T],
|
|
|
|
p2 Parser[In, T2],
|
|
|
|
p3 Parser[In, T3],
|
|
|
|
p4 Parser[In, T4],
|
|
|
|
f func(T, T2, T3, T4) Out,
|
|
|
|
) Parser[In, Out] {
|
|
|
|
return func(s State[In]) (Result[In, Out], error) {
|
|
|
|
var anyConsumed bool
|
|
|
|
var next = s
|
|
|
|
|
|
|
|
r, err := p(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val, next := r.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r2, err := p2(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val2, next := r2.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r3, err := p3(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val3, next := r3.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r4, err := p4(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val4, next := r4.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final := f(val, val2, val3, val4)
|
|
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
|
|
}
|
|
|
|
}
|
2024-09-14 03:03:10 +00:00
|
|
|
|
2024-09-14 02:48:33 +00:00
|
|
|
func Seq5[In, Out, T, T2, T3, T4, T5 any](
|
|
|
|
p Parser[In, T],
|
|
|
|
p2 Parser[In, T2],
|
|
|
|
p3 Parser[In, T3],
|
|
|
|
p4 Parser[In, T4],
|
|
|
|
p5 Parser[In, T5],
|
|
|
|
f func(T, T2, T3, T4, T5) Out,
|
|
|
|
) Parser[In, Out] {
|
|
|
|
return func(s State[In]) (Result[In, Out], error) {
|
|
|
|
var anyConsumed bool
|
|
|
|
var next = s
|
|
|
|
|
|
|
|
r, err := p(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val, next := r.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r2, err := p2(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val2, next := r2.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r3, err := p3(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val3, next := r3.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r4, err := p4(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val4, next := r4.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
r5, err := p5(next)
|
|
|
|
if err != nil {
|
|
|
|
return Result[In, Out]{}, err
|
|
|
|
}
|
|
|
|
anyConsumed = anyConsumed || r5.Consumed()
|
2024-09-24 19:16:30 +00:00
|
|
|
success, val5, next := r5.Status()
|
|
|
|
if !success {
|
2024-09-24 18:56:10 +00:00
|
|
|
return Fail[In, Out](anyConsumed, r5.Message()), nil
|
2024-09-14 02:48:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final := f(val, val2, val3, val4, val5)
|
|
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
|
|
}
|
|
|
|
}
|