I found a case where it might be useful to add a parser combinator which returns two things:
- a value built with what is meant to recognize
- a parser or a value useful for continuing parsing after that string
This can happen when you have a clause in SQL like SELECT column0, … column_N (FROM | ORDER BY), where you might have a function for parsing the column list, and then different functions for parsing what comes after FROM or ORDER BY.
I explain that situation with more detail here
sepBy1Cont could be used the following way
type Either<'a, 'b> =
| Left of 'a
| Right of 'b
let sepCont =
parse {
do! symbol S.Comma
return Left ()
}
<|> parse {
do! keyword K.From
return Right From
}
<|> parse {
do! keyword K.Order
do! keyword K.By
return Right OrderBy
}
let! xs, next = sepBy1Cont identifier sepCont
I found a case where it might be useful to add a parser combinator which returns two things:
This can happen when you have a clause in SQL like
SELECT column0, … column_N (FROM | ORDER BY), where you might have a function for parsing the column list, and then different functions for parsing what comes afterFROMorORDER BY.I explain that situation with more detail here
sepBy1Contcould be used the following way