On 2015-09-11 10:39, Gerhard Wolf wrote:
>
> its the first contact with spirit and it seems to be pretty complex.
> The code seems to work as i understand it. But my first change request
> would be to return more details of the failed parse, not only true or
> false. A Position would be fine!
> Any Tips?
Yes, my tip is stay very far away from Spirit if you want to keep your
sanity. A recursive decent parser isn't really that much more code.
While the Spirit code may look simple at first glance, looks can be
very, very deceiving.
Once your parser gets a bit bigger, you will encounter completely
undecipherable error messages from deep within the bowels of insane
Boost template metaprogramming. A single error message can literally be
megabytes in size (IIRC, my record is 5MB). People have reported
inlining depths of several hundred levels deep. Good luck with trying to
debug your grammar, if your parser doesn't quite do what you expect.
IME, Spirit often produces poor code that's rather slow. E.g., my
straightforward JSON recursive decent parser is 50x faster than the 3
different Spirit JSON parsers I tried.
If you insist on using Spirit, make sure to compile your code with all
compilers you can get your hands on. You are almost guaranteed to hit
corner cases of the language.