Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add debug combinator #28

Open
mattfenwick opened this issue Sep 17, 2016 · 0 comments
Open

add debug combinator #28

mattfenwick opened this issue Sep 17, 2016 · 0 comments

Comments

@mattfenwick
Copy link
Owner

mattfenwick commented Sep 17, 2016

Purpose: add some debugging output during parsing, without changing anything else.
Something like:

def debug[E, S, T, A](parser: Parser[E, S, T, A], message: String): Parser[E, S, T, A] = {
    Parser.seq2R(Parser.bind(Parser.getState(), (s: S) => {
        println(s"state for $message: $s")
        Parser.pure(Unit)
      }), parser)
  }

Questions:

  • how to test whether output has been written to console?
  • should the token state and state both be dumped to console? Should there be extra, optional arguments to control that?
  • what's the best argument order?

First pass:

// b -> Parser e s (m t) a -> Parser e s (m t) a
function debug(message, parser) {
    return seq2R(bind(getState, (s) => console.log("state for " + message + ": " + s)),
                      parser);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant