I think you can use opt
to allow parseCount
to not find a count if there isn't one:
let parseCount = parseTerm .>>. opt (choice [ skipChar '*'>>% (MinCount 0) skipChar '+'>>% (MinCount 1) skipChar '?'>>% (RangeCount(0, 1)) ]) |>> function | term, None -> term | term, Some count -> Count (term, count)let parseTerms = many parseCount .>> eof