
Hey all, Trying to match C-style comments, I have: between (string "/*") (string "*/") $ many anyChar Which doesn't work, because it is equivalent (ignoring returned values) to do {string "/*"; many anyChar; string "*/"} If the termination criterion was a single character, then I could use noneOf or (satisfy . not), but that doesn't help here. So... what am I missing? Thanks in advance. -- Scott Lawrence

On Sun, Sep 11, 2011 at 1:38 PM, Scott Lawrence
Hey all,
Trying to match C-style comments, I have:
between (string "/*") (string "*/") $ many anyChar
Which doesn't work, because it is equivalent (ignoring returned values) to
do {string "/*"; many anyChar; string "*/"}
Use "manyTill".

On Sunday 11 September 2011, 22:38:30, Scott Lawrence wrote:
Hey all,
Trying to match C-style comments, I have:
between (string "/*") (string "*/") $ many anyChar
Which doesn't work, because it is equivalent (ignoring returned values) to
do {string "/*"; many anyChar; string "*/"}
If the termination criterion was a single character, then I could use noneOf or (satisfy . not), but that doesn't help here.
So... what am I missing?
manyTill A quick example: Prelude Text.Parsec> parse (do {spaces; string "/*"; com <- manyTill anyChar (string "*/"); rmd <- getInput; return (com, rmd);}) "" "/* a comment */ and code /* and another comment */" Right (" a comment "," and code /* and another comment */")
Thanks in advance.
participants (3)
-
Alexander Solla
-
Daniel Fischer
-
Scott Lawrence