tzlaine / parser

A C++ parser combinator library.
Boost Software License 1.0
81 stars 12 forks source link

state of the output argument upon unsuccessful parse #78

Closed akrzemi1 closed 8 months ago

akrzemi1 commented 8 months ago

The docs should document that upon unsuccessful parse the value of the output parameter (where the result is supposed to be written) is in an unspecified state (potentially changed).

An example illustrating this: https://godbolt.org/z/a5vb8E87o

tzlaine commented 8 months ago

Will do.

tzlaine commented 8 months ago

I rethought this. Instead of just documenting the behavior, I made the parse() API clear the out-param on failure (via attr = Attr()). This is more consistent with what parsers do; when they fail, they do attr = Attr().