3

In my experience, programs which use parser generators to parse domain-specific languages tend to spew cryptic and unhelpful "syntax errors" in case an input cannot be parsed correctly.

Now that I need to write a parser for a domain-specific data language myself (as part of a C++ program), I'd like to hold myself to a higher standard regarding user-friendly error reporting - and I'm hoping to find a parser generator/framework which can help me with that.

I'd like to avoid frameworks where the simple and elegant way to write a grammar comes with terrible error reporting, and where adding good error reporting entails so much unintuitive/unelegant refactoring and so much glue code, that it defeats the point of using a framework in the first place.

So I'm hoping that someone more experienced can tell me:

  • Which parser generators/frameworks are built with good error reporting in mind?
  • What facilities do they provide for error reporting?
    (Examples or documentation links appreciated!)

Requirements for the generated parser:

  • Callable from C++ code.
  • Possible to include in an open-source project (license-wise).
  • Cross-platform (Win/Mac/Linux).
  • Able to parse a context-free language that could be parsed with a traditional recursive descent parser. (No need for fancy things like left-recursion.)
  • I'm not sure this meets your requirements, but have you looked into Boost Spirit framework? (If you've heard of Qi, Karma and Lex, those are names for components of that framework.) – einpoklum Jan 16 '16 at 15:13
  • 1
    @einpoklum Thanks for commenting! I haven't looked at Spirit too closely yet, but I'm planning to. :) – allat Jan 17 '16 at 17:35
  • Also, are you sure you need the parser generator itself to be in C++? It's not quite clear how the DSL is part of your C++ program. Perhaps you should elaborate on that some more. – einpoklum Jan 17 '16 at 18:15
  • You're right, the generator doesn't have to be in C++. Updated the question to clarify. – allat Jan 20 '16 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.