Neil Mitchell wrote:
> Hi,
>
> I'm using parsec to parse something which is either a "name" or a
> "type". The particular test string I'm using is a type, but isn't a
> name. I want things to default to "name" before "type".

I just finished a parsec grammar for C99, and found this very useful while bringing it up:

 mtrace_enabled = False

 mtrace n p = if mtrace_enabled then
                  trace ("-> trying to match: " ++ n)
$ choice [do {a <- p; return (trace ("<- matched: " ++ n ++ "(" ++ show a ++ ")") a)},
                                   fail ("<- failed to match " ++ n)]
              else
                  p

Usage:

 expression = mtrace "expression"
              (do {a <- chainl1 assignment_expression comma_op; return a})

Oh, and hello-and-delurk :)

- Derek

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to