Re: attpoarsec and recursive parsing
Olaf Klinke <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <[email protected]> |
Hi Frederic,
Essentially, the '|' character acts like a binary operator in parsing
arithmetical expression trees. To that end, the most ergonomic module I
know of is provided by parsec [1], which has a port [2] to attoparsec.
You have to decide whether the '|' operator should be left- or right-
associative. That question vanishes if you decide to re-design your
data type as
data MaskLocation = MaskLocation Text
| MaskLocation'Tmpl Text
| MaskLocation'Or (NonEmpty MaskLocation)
and use the sepBy1 combinator. Also you should think about whether and
how to escape the separator Char inside ordinary MaskLocation strings.
Olaf
[1] https://hackage.haskell.org/package/parsec-3.1.17.0/docs/Text-ParserCombinators-Parsec-Expr.html
[2] https://hackage.haskell.org/package/attoparsec-expr
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.