Opened 11 years ago
Closed 20 months ago
#6050 closed Patches (invalid)
Make spirit::transform_attribute::post return bool instead of void
Reported by: | Owned by: | Joel de Guzman | |
---|---|---|---|
Milestone: | To Be Determined | Component: | spirit |
Version: | Boost 1.47.0 | Severity: | Problem |
Keywords: | Cc: | hkaiser@… |
Description
Currently, when doing attribute transformations, spirit::qi assumes that if "Transformed" attribute parsing succeedes, then assignment to "Exposed" attribute value will inevitably succeed as well, hence transform_attribute::post return value is not provided nor checked for.
However, there are many classes of problems (especially those involving restricted numeric types, such as ranges and strongly typed enums) which can benefit from recoverable parser failures during attribute transformation, if post() was allowed to signal a failure.
The proposed patch to spirit::qi is attached.
Attachments (7)
Change History (13)
by , 11 years ago
Attachment: | spirit-transform-attribute-post-bool.diff added |
---|
by , 11 years ago
Attachment: | spirit-transform-attribute-post-bool-v2.diff added |
---|
Patch to allow transform_attribute::post to fail the parser; compared to previous version this will set back the input iterator if conversion fails.
by , 11 years ago
Attachment: | test_attr.cpp added |
---|
A short example demonstrating a basic use case for the propoesed change.
comment:1 by , 11 years ago
Compared to my initial submission, -v2 version of the patch will hold a copy of the input iterator and won't advance it until it can be sure that attribute conversion succeeded. This is analogous to what as<> directive does. Without this minor quirk the facility is not that useful. :-)
I also attached a smallish example which demonstrates the expected functionality.
by , 11 years ago
Attachment: | spirit-transform-attribute-post-bool-v3.patch added |
---|
Added test cases, example and updated documentation
by , 11 years ago
Attachment: | spirit-transform-attribute-post-bool-v4.patch added |
---|
Backtracking in qi::rule now saves the position before the skipper; support for qi::action new attribute transformation behaviour.
comment:2 by , 10 years ago
I tried to apply this patch but there are some parts being rejected. Could you please update the patch? Thanks!
by , 10 years ago
Attachment: | spirit-transform-attribute-post-bool-v5.patch added |
---|
Updated v4 patch to account for some cosmetic differences in the recent qi version + added some examples missing from the v4 patch.
comment:3 by , 10 years ago
The only problem I encountered with my patch was slightly shifted line numbers due to some header changes.
Unfortunately, I could not retest it as I'm currently traveling abroad.
by , 10 years ago
Attachment: | spirit-transform-attribute-post-bool-v6.patch added |
---|
Fix an unfortunately missed "bit rot" in v5 arising from changed function attribute names.
comment:5 by , 10 years ago
Replying to djowel:
I get lots of errors running the tests
Sorry for that. I should have not acted hastily when fixing this patch up. All tests seem to pass just fine with the update, apart from match_manip1.cpp (some problem on my side, may be - it fails with bad_alloc) and regression_stream_eof.cpp (seem to be broken as it is).
comment:6 by , 20 months ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
breaking change, examples are inconclusive for a feature request as the same can be done with exceptions, semantic actions or custom parsers.
Patch to make attribute_transform::post return bool