586 lines
13 KiB
Go
586 lines
13 KiB
Go
// GENERATED FILE. DO NOT EDIT.
|
|
|
|
// SPDX-License-Identifier: Unlicense
|
|
|
|
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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
r4, err := p4(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
|
success, val4, next := r4.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3, val4)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
r4, err := p4(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
|
success, val4, next := r4.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
|
}
|
|
|
|
r5, err := p5(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r5.Consumed()
|
|
success, val5, next := r5.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r5.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3, val4, val5)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
func Seq6[In, Out, T, T2, T3, T4, T5, T6 any](
|
|
p Parser[In, T],
|
|
p2 Parser[In, T2],
|
|
p3 Parser[In, T3],
|
|
p4 Parser[In, T4],
|
|
p5 Parser[In, T5],
|
|
p6 Parser[In, T6],
|
|
f func(T, T2, T3, T4, T5, T6) 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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
r4, err := p4(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
|
success, val4, next := r4.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
|
}
|
|
|
|
r5, err := p5(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r5.Consumed()
|
|
success, val5, next := r5.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r5.Message()), nil
|
|
}
|
|
|
|
r6, err := p6(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r6.Consumed()
|
|
success, val6, next := r6.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r6.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3, val4, val5, val6)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
func Seq7[In, Out, T, T2, T3, T4, T5, T6, T7 any](
|
|
p Parser[In, T],
|
|
p2 Parser[In, T2],
|
|
p3 Parser[In, T3],
|
|
p4 Parser[In, T4],
|
|
p5 Parser[In, T5],
|
|
p6 Parser[In, T6],
|
|
p7 Parser[In, T7],
|
|
f func(T, T2, T3, T4, T5, T6, T7) 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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
r4, err := p4(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
|
success, val4, next := r4.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
|
}
|
|
|
|
r5, err := p5(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r5.Consumed()
|
|
success, val5, next := r5.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r5.Message()), nil
|
|
}
|
|
|
|
r6, err := p6(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r6.Consumed()
|
|
success, val6, next := r6.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r6.Message()), nil
|
|
}
|
|
|
|
r7, err := p7(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r7.Consumed()
|
|
success, val7, next := r7.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r7.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3, val4, val5, val6, val7)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
func Seq8[In, Out, T, T2, T3, T4, T5, T6, T7, T8 any](
|
|
p Parser[In, T],
|
|
p2 Parser[In, T2],
|
|
p3 Parser[In, T3],
|
|
p4 Parser[In, T4],
|
|
p5 Parser[In, T5],
|
|
p6 Parser[In, T6],
|
|
p7 Parser[In, T7],
|
|
p8 Parser[In, T8],
|
|
f func(T, T2, T3, T4, T5, T6, T7, T8) 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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
r4, err := p4(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
|
success, val4, next := r4.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
|
}
|
|
|
|
r5, err := p5(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r5.Consumed()
|
|
success, val5, next := r5.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r5.Message()), nil
|
|
}
|
|
|
|
r6, err := p6(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r6.Consumed()
|
|
success, val6, next := r6.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r6.Message()), nil
|
|
}
|
|
|
|
r7, err := p7(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r7.Consumed()
|
|
success, val7, next := r7.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r7.Message()), nil
|
|
}
|
|
|
|
r8, err := p8(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r8.Consumed()
|
|
success, val8, next := r8.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r8.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3, val4, val5, val6, val7, val8)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|
|
|
|
func Seq9[In, Out, T, T2, T3, T4, T5, T6, T7, T8, T9 any](
|
|
p Parser[In, T],
|
|
p2 Parser[In, T2],
|
|
p3 Parser[In, T3],
|
|
p4 Parser[In, T4],
|
|
p5 Parser[In, T5],
|
|
p6 Parser[In, T6],
|
|
p7 Parser[In, T7],
|
|
p8 Parser[In, T8],
|
|
p9 Parser[In, T9],
|
|
f func(T, T2, T3, T4, T5, T6, T7, T8, T9) 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()
|
|
success, val, next := r.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r.Message()), nil
|
|
}
|
|
|
|
r2, err := p2(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r2.Consumed()
|
|
success, val2, next := r2.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r2.Message()), nil
|
|
}
|
|
|
|
r3, err := p3(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r3.Consumed()
|
|
success, val3, next := r3.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r3.Message()), nil
|
|
}
|
|
|
|
r4, err := p4(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r4.Consumed()
|
|
success, val4, next := r4.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r4.Message()), nil
|
|
}
|
|
|
|
r5, err := p5(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r5.Consumed()
|
|
success, val5, next := r5.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r5.Message()), nil
|
|
}
|
|
|
|
r6, err := p6(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r6.Consumed()
|
|
success, val6, next := r6.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r6.Message()), nil
|
|
}
|
|
|
|
r7, err := p7(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r7.Consumed()
|
|
success, val7, next := r7.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r7.Message()), nil
|
|
}
|
|
|
|
r8, err := p8(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r8.Consumed()
|
|
success, val8, next := r8.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r8.Message()), nil
|
|
}
|
|
|
|
r9, err := p9(next)
|
|
if err != nil {
|
|
return Result[In, Out]{}, err
|
|
}
|
|
anyConsumed = anyConsumed || r9.Consumed()
|
|
success, val9, next := r9.Status()
|
|
if !success {
|
|
return Fail[In, Out](anyConsumed, r9.Message()), nil
|
|
}
|
|
|
|
final := f(val, val2, val3, val4, val5, val6, val7, val8, val9)
|
|
return Succeed(anyConsumed, final, next, MessageOK(s.Pos())), nil
|
|
}
|
|
}
|