Hi all,

This might be a Lexi question, but perhaps someone else will have some
insight as well.

I'm wrestling with how to get errors to propagate down in megaparsack. For
example:

(define convert/p
  (do (string/p "convert")
     ...
      [assigns ← (many/p #:min 0
                         assignment-statement/p
                         )]
     ...
      (pure ...)))

(Assume I have a bunch of other parsing bits around the call to
`assignment-statement/p`.)

Currently, if I have a malformed assignment statement, the error is at the
top level of `convert`. `convert/p` is part of a backtracking conditional:

(define conversion/p
  (do
    [result ← (many/p (or/p (try/p base-type/p)
                            (try/p convert/p)
                            (try/p chain/p)
                            )
                      #:sep space0+/p
                      )]
    eof/p
    (pure result)))

What should I do to get the error to report/fail down the parse tree, as
opposed to the top? I would rather know that there's something wrong down
in my assignment statement, as opposed to getting an error that "c" was
unexpected (because the entire conversion/p failed on account of an error
somewhere down inside).

I need to give the docs a more careful read, but I thought I'd ask, as it
seems both simple and, given the nature of the parsing tools, possibly
subtle.

Many thanks,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAAGM45761tRo%2Bj0Rh078ngriYiMDum%3DyDyRgwQ1LLiuPZDFj6A%40mail.gmail.com.

Reply via email to