Commit Graph

2382 Commits

Author SHA1 Message Date
Nikita Kniazev
74c0ec310a Fixed cover operators macro redefinition problem 2019-03-07 23:05:32 +03:00
Nikita Kniazev
6c258d506c Fixed macro name clashes with Boost.Endian 2019-03-07 23:05:30 +03:00
Nikita Kniazev
805b050e09 transform_attribute: Disallow references as template parameters
The special handling was used instead of removing references from the
`make_attribute<T,U>::type`. Since `make_attribute` is gone the workaround is
no longer needed.
2019-03-07 22:17:21 +03:00
Nikita Kniazev
0fb76692dd
X3: support/utility/testing.hpp: Propagate prefix and suffix [skip ci] (#476)
X3: support/utility/testing.hpp: Propagate prefix and suffix
2019-03-03 00:04:25 +03:00
Nikita Kniazev
016472c2fb Support: utree: Fixed name shadowing
boost/spirit/home/support/utree/detail/utree_detail2.hpp(936): warning C4458: declaration of 'p' hides class member
boost/spirit/home/support/utree/utree.hpp(603): note: see declaration of 'boost::spirit::utree::p'
2019-03-01 01:12:00 +03:00
Nikita Kniazev
97a13dbdbc Qi: iterator_source: Fixed unused argument warning 2019-03-01 01:12:00 +03:00
Nikita Kniazev
b0eede8435 Qi: utree: Suppress '~' on an expression of type bool warning 2019-03-01 01:12:00 +03:00
Nikita Kniazev
89a3de13f2
Merge pull request #474 from Kojoley/qi-fix-iterator_source-conversion-warning-on-32bit
Qi: iterator_source: Fix conversion warning on 32bit
2019-02-28 14:25:04 +03:00
Nikita Kniazev
c0e06cda9c Qi: iterator_source: Refactor read count clamping
This is specialization for random access iterators, no need for std::difference
2019-02-27 23:06:11 +03:00
Nikita Kniazev
79af31f68e Qi: iterator_source: Fix conversion warning 2019-02-27 23:06:09 +03:00
Nikita Kniazev
32537028f5
Merge pull request #472 from Kojoley/x3-improve-situation-with-move-only-types
X3: Improve situation with move only types
2019-02-27 19:15:16 +03:00
Nikita Kniazev
c36e74be1b X3: Suppress multiple copy constructors warning in x3::variant 2019-02-26 22:14:30 +03:00
Nikita Kniazev
793d89619c X3: Move only types with optional 2019-02-26 21:23:43 +03:00
Nikita Kniazev
8bd9b6ece4 X3: Fixed container of move only types with sequence 2019-02-26 21:23:43 +03:00
Nikita Kniazev
f371ccf6d0 X3: push_back has to forward actual reference type
Added tests for move only types in kleene, plus, list, and repeat parsers
2019-02-26 21:23:43 +03:00
Nikita Kniazev
bfbaa9e224 Qi.Repo: keywords: Fixed self-assignment
This should be here to roll back the skipper
2019-02-26 05:00:33 +03:00
Nikita Kniazev
eb8eeb2fbc extract_uint: Fixed IgnoreOverflowDigits=true problem at overflow
The IgnoreOverflowDigits=true parser always succeeds and because of that it
expects from the digits parser that a number passed as inout argument will be
changed only on success.

Changed negative_accumulator and X3 for consistency.
2019-02-22 15:13:02 +03:00
Nikita Kniazev
4b1b710322 extract_int: Fixed underflow check for (MinOrMax % Base) == 0 2019-02-21 20:21:12 +03:00
Nikita Kniazev
7d3cf1da6d Make extract_int respect std::numeric_limits<T>::digits10 2019-02-21 20:21:12 +03:00
Nikita Kniazev
53469ae846 V2: Use pre/post/fail functions directly from the transform
This will ensure that the same transformation is used for all operations.
2019-02-19 15:40:44 +03:00
Nikita Kniazev
e9b8f15f05 X3: Replaced make_attribute with direct attribute construction
If the attribute has a general way to be constructed it should already have a
default constructor.
2019-02-18 20:25:53 +03:00
Nikita Kniazev
cd4b0f6e13 V2: Merge make_attribute into transform_attribute
This will allow to simplify transform_attribute (e.g. no need to handle
references anymore) and to ensure the pre/post/fail calls are made to the
same transformation.
2019-02-18 20:25:16 +03:00
Nikita Kniazev
e979d61975 utree: Fixed double conversion
The double conversion `spirit::string -> std::string -> spirit::string` was
happening silently in rules because of `transform_attribute` was returning
`std::string` and implicit constructor in `spirit::string`.

The mistake could be prevented if `spirit::basic_string` constructor from
derived class was explicit, but `utree_cast` uses `is_convertible` while
`is_constructible` is not implemented for C++03 (it is possible, but requires
expression SFINAE support from compiler - N2634).
2019-02-14 15:48:39 +03:00
Nikita Kniazev
0810e33c69 Remove broken 1.0#INF parser
It was poorly documented and never worked correctly. None of atof, strtof, and
input streams are accepting such values. Fixing it would be a bigger breaking
change than removing it.

Fixes #415, addresses #163 and https://svn.boost.org/trac10/ticket/8699
2019-02-10 02:43:40 +03:00
Nikita Kniazev
5d40a5b320 X3: tst: Replace iterator_traits<T>::value_type with auto 2019-02-09 18:37:29 +03:00
Nikita Kniazev
d4c0179fa6 X3: parse_rule attribute must always be of rule::attribute_type&
After #456 `parse_rule` is always called with value of `rule::attribute_type&`
type. By removing attribute type deduction we also will turn any possible bug
in `transform_attribute` from a linkage to compile error.

Fixes #454
2019-02-09 14:57:53 +03:00
Nikita Kniazev
9a84e5290f X3: unused_type: Trim included iostream headers 2019-02-09 05:08:05 +03:00
Nikita Kniazev
b5f1552ec2 X3: Perform attribute transformation before calling parse_rule
This will deal with linking problems when rule attribute type is not the same
as the actual attribute type. It will not harm anyone as the transformation
after parse_rule will just pass-through the attribute because it will be the
same there. It will also do not alter rule_definition parsing so other usages
are still valid.
2019-02-08 21:55:11 +03:00
Patrick Welche
9ae4210138 Remove header which is not needed since d6b5f0d925 2019-02-08 18:20:50 +03:00
Nikita Kniazev
afe763b61e X3: Fixed static assert on parse_rule instantiation
During overload resolution disallowed signature can be instantiated leading
to firing the static assertation and overload resolution failure. I could
just remove it, but do not want to leave unbounded by value overloads;
replacing to not deducing Attribute with specifying a default parameter will
not work because we want to allow `BOOST_SPIRIT_DECLARE` without prior
`BOOST_SPIRIT_DEFINE` - this requires having default parameters in both
declaration and definition and the standard seems to forbid it (GCC - fine,
MSVC - warning, Clang - error).

Reverts #437, fixes #453.
2019-02-08 14:51:35 +03:00
Nikita Kniazev
4496caff78 X3: Ensure symmetric transforms
Use transform pre/post directly. Cannot do the same for V2 right now because of
make_attribute, it needs asymmetric transformations.
2019-02-07 14:57:45 +03:00
Nikita Kniazev
c915ac4170 X3: rule: Skip attribute synthesization on unused actual attribute
There is a mistake in `make_attribute` trait that leads to synthesization and
immediately throwing out an attribue, so rule context always was unused_type
when actual attribute is unused_type (added test for this case). Instead of
fixing `make_attribute` trait I just completely removed synthesization in
rule by removing `make_attribute` trait usage (the traits could be removed
after a simple change in 'action' parser). I think the change is better
than fixing the trait because it removes excessive attribute default
construction in every rule and makes rule almost free to use.
2019-02-06 16:42:07 +03:00
Xeverous
4b2b443e58 simplify value_initialize trait
removed use of boost::value_initialized which is obsolete post C++11
2019-02-02 02:24:38 +03:00
Nikita Kniazev
a3cf3f2c3e X3: Fixed wrong parse_rule signature instantiation
When a rule has no attribute (leaves `Attribute` template parameter as default)
the `BOOST_SPIRIT_INSTANTIATE` macro instantiates a `parse_rule` helper function
with a wrong signature because `parse`, `phrase_parse`, and `skip_over` pass as
the attribute `unused` variable which deduces to `unused_type const&` type, but
`BOOST_SPIRIT_INSTANTIATE` instantiates `parse_rule` with `unused_type&` type.
2019-01-26 17:32:04 +03:00
Nikita Kniazev
2c85f6a08a Replace mpl::find_if+is_same with find
From `mpl::find` docs:
> `typedef find<s,t>::type i;`
> Semantics: Equivalent to `typedef find_if<s, is_same<_,t> >::type i;`
2019-01-25 21:56:18 +03:00
Nikita Kniazev
93b753ef7e X3: Removed unused Fusion includes 2019-01-23 15:04:20 +03:00
Nikita Kniazev
d80d32f892 X3: Removed sequence into plain parsing
The possibility to parse `int_ >> int_` into `int` is dangerous and hides the
actual bugs in user parsers (and in Spirit too).
2019-01-21 03:06:53 +03:00
Nikita Kniazev
bd3e56c423 X3: pass_sequence_attribute: Removed unused specialization
The `partition_attribute` never splits a sequence into zero sized parts.

Removing the specialization simplifies an ongoing patch that will forbid
sequence into plain types parsing.
2019-01-21 03:02:16 +03:00
Xeverous
0a22620d25 Fix unused parameter warnings in position_tagged 2019-01-13 17:53:38 +03:00
Nikita Kniazev
65157bae07 extract_int: Custom integers support
It will allow to test `extract_int` properly.

Replacing `boost::integer_traits` with `std::numeric_limits` will not hurt
performance because even MSVC 9/GCC 4.1/Clang 3.0 folds `min`/`max` calls
to a constant at compile time and since C++11 they are even constexpr.
2019-01-13 01:12:09 +03:00
Nikita Kniazev
6faa709605 Unbounded types can't be checked for overflow
Changed default `check_overflow` trait implementation to be `is_bounded`
as it also covers float types and user data types.
2019-01-13 01:11:50 +03:00
Nikita Kniazev
085f90f4ed
Removed unused private header. Closes #433
The `boost/spirit/home/support/detail/lexer/serialise.hpp` header is a private header
and is not used anywhere in Spirit or Boost. No one should be affected by the change.
2018-12-30 17:00:43 +03:00
Nikita Kniazev
da91db5a9c The boost/detail/iterator.hpp header is obsolete
Both `iterator_traits` and `distance` in `boost::detail` namespace are just
aliases from `std` namespace.
2018-12-29 17:46:33 +03:00
Nikita Kniazev
54ca101440 Removed unneeded lexical_cast usages 2018-12-27 20:54:49 +03:00
Nikita Kniazev
e07ce69363 Removed unused lexical_cast includes 2018-12-27 19:36:51 +03:00
Nikita Kniazev
0efdabd424 Qi: rule: Added asserts for mismatching skipper types
It looks like mismatching skipper types and `parse`/`phrase_parse` calls are
quite popular mistakes, and the actual problem is not clear for users despite
that there is a comment near the call that will fail and the hint should be
found by following to the file and line that compiler reports the error on.
2018-12-18 03:07:13 +03:00
Nikita Kniazev
ca76771cbf
Merge pull request #423 from Kojoley/fix-utree-negative-shift-ub
utree: Fixed negative value shift
2018-11-25 15:36:44 +03:00
Nikita Kniazev
a9207c1132 X3: Use constexpr in numeric utils instead of static storage
It is a symmetrical change to Qi one that landed a while ago d8637825 (#146).
There should not be race condition on C++11+, but MSVC still does not do
compile-time initialization of static variables when constructor is constexpr
https://developercommunity.visualstudio.com/content/problem/336946/class-with-constexpr-constructor-not-using-static.html
2018-11-23 17:11:17 +03:00
Nikita Kniazev
eafd573b4d utree: Fixed negative value shift
Result of shifting a negative value is an implementation defined behavior.

The temporaries and memcpy calls will be completely optimized out.
2018-11-23 15:41:06 +03:00
Nikita Kniazev
d3e14ccf04 Classic: Fixed position_iterator forming reference to local
When underlying iterator returns by value the corresponding position_iterator
was providing iterator_adaptor with a reference type what lead to returning
a reference to a local variable in dereference operator.

Made a custom trait because it is a way more elegant than:
```cpp
    typedef typename boost::mpl::if_c<
        boost::is_reference<reference>::value,
        typename boost::add_reference<
            typename boost::add_const<
                typename boost::remove_reference<reference>::type
            >::type
        >::type,
        typename boost::add_const<reference>::type
    >::type const_reference_type;
```

Fixes https://svn.boost.org/trac10/ticket/9737.
2018-11-23 03:19:03 +03:00
Nikita Kniazev
6810f9ecbd Lex: Avoid casting min_token_id to id_type in lexer ctor
When `min_token_id` is not a valid value for `id_type` and `first_id` is not
provided lexer constructor is triggering UB. To fix this problem, constructor
with ommited `first_id` initializes `next_token_id` directly, so if unique ids
feature is not used there is no UB.
2018-11-20 23:59:45 +03:00
Nikita Kniazev
cfcfe6d0cd
Merge pull request #418 from Kojoley/simplify-symbols
Simplify symbols
2018-11-19 19:32:51 +03:00
Nikita Kniazev
2a80c25584 Simplify symbols 2018-11-16 19:35:49 +03:00
Romain Geissler
5e10e84031 Prepare for C++20 and remove "throw()" usage. 2018-11-11 23:14:05 +00:00
Nikita Kniazev
ff6a8e4e13 [1.69] Version bump and changelog update [skip ci] 2018-11-08 18:06:37 +03:00
Nikita Kniazev
3fbde9c195 to_utf8: Fixed wchar_t handling on Windows
Spirit were assuming that wchar_t is 32-bit and the content is UCS-4.
It is wrong, the actual representation is implementation defined [lex.ccon]/6.
However, on most Unix platforms this assumption is valid and gives the
expected outcome, but on Windows wchar_t is 16-bit and the content is UTF-16.
2018-10-28 17:43:05 +03:00
Nikita Kniazev
4be6e2d033
Merge pull request #410 from Kojoley/fix-buffer-char-type-on-windows
Karma: Fixed wrong buffer char type on Windows
2018-10-25 13:55:00 +03:00
Nikita Kniazev
4b1b2dfd2d Karma: Fixed wrong buffer char type on Windows
With `BOOST_SPIRIT_UNICODE` defined Clang, MinGW and Cygwin were using `wchar_t`.

I have switched to OS detection with `_WIN32`, it will give the right results for
most compilers except Cygwin.
2018-10-24 16:53:10 +03:00
Nikita Kniazev
ea9c54ab0e
Merge pull request #407 from Kojoley/qi-transform_attribute-adapt_adt-specialization-ambiguity
V2: Fixed transform_attribute ambiguity
2018-10-23 05:10:47 +03:00
Nikita Kniazev
5c62f8baf3 V2: Fixed transform_attribute ambiguity
Domain-agnostic class template partial specializations and
type agnostic domain partial specializations are ambious.
To resolve the ambiguity type agnostic domain partial
specializations are dispatched via intermediate type.
2018-10-22 01:19:27 +03:00
Nikita Kniazev
bfbd691c4f Missing visibility mark on exception types
https://gcc.gnu.org/wiki/Visibility#Problems_with_C.2B-.2B-_exceptions_.28please_read.21.29
2018-10-17 22:09:19 +03:00
Nikita Kniazev
72c8da1099 Classic: utility/loops.hpp: Added missing includes 2018-09-26 15:41:09 +03:00
Nikita Kniazev
b3ae790e2b Use endian macros from Predef
The `boost/detail/endian.hpp` header is deprecated.
2018-09-15 18:19:49 +03:00
Nikita Kniazev
925f40a2d0
Karma: Missing include for math::fpclassify 2018-08-17 00:59:08 +03:00
Nikita Kniazev
43f8b5035e Drop own fp routines in favor of boost::math
Remove own fp routines as Boost 1.40 released ~9 years ago.
The `boost::math::changesign` usage fixes trac 13531.
2018-07-27 20:26:11 +03:00
Nikita Kniazev
e2c3a539ad Misstyped version digit [skip ci] 2018-07-01 19:45:03 +03:00
Nikita Kniazev
2d1b8eb95d Bump version and update changelog [skip ci] 2018-07-01 19:32:50 +03:00
Nikita Kniazev
bbfa94974d
Merge pull request #379 from RandomInEqualities/develop
X3: variant: More fixes for compilation with VS2015 Update 3
2018-07-01 01:31:12 +03:00
Christian Andersen
27c2fb5a53 X3: variant: More fixes for compilation with VS2015 Update 3
This applies the fix in 6d6f40c3e5 to all BOOST_NOEXCEPT_IF statements in
variant.cpp. I have trouple compiling a toy project with VS2015, as these
noexcept if statements fails to compile.
2018-06-30 16:37:52 +03:00
Nikita Kniazev
cfe94349e2 Classic: The right fix for PR 336 2018-04-17 19:04:51 +03:00
sehe
4196998377 Specialize iterator_source for random access
Optimizing this case allows the compiler to achieve a large speedup
especially in the case where the underlying range is contiguous in
memory.

The effective result is for the performance to be equivalent to directly
using `boost::iostreams::array_source<char_type>` if the source range so
allows.

This patch arose from benchmarking several varying approaches to parsing
posix timestamps here:

 - https://stackoverflow.com/questions/49693376/why-does-using-a-stream-in-boost-spirit-penalize-performance-so-much
 - https://stackoverflow.com/questions/49671674/use-a-trait-for-parsing-a-date-in-boostspirit

I'll refer to that location for some benchmark results.
2018-04-08 13:35:44 +02:00
Nikita Kniazev
ae78e1ec24 X3: sequence: Fixed reference to temporary bug 2018-03-16 20:10:37 +03:00
Nikita Kniazev
e7f31017ec Qi: Fixed ADT support by permutation and sequence_or operator
This is follow-up to 0f2b3c49ce
2018-03-16 01:23:31 +03:00
Nikita Kniazev
1d9aa696bf Karma: Fixed use after scope bug if ADT getter returns by value
The `extract_from_attribute` returns a reference to a temporary
value produced by calling Fusion ADT adapted sequence getter that
returns by value.

Was reported 6 years ago https://svn.boost.org/trac10/ticket/6126
2018-03-15 18:50:17 +03:00
Nikita Kniazev
4213d53d9a X3: More fine grained sequence attribute check message 2018-03-14 15:41:01 +03:00
Nikita Kniazev
b22686b7d7
Qi: skip_over: Remove redundant check
End iterator check is redundant here because it is done in skipper.

Follow-up to PR #373.
2018-03-12 18:25:11 +03:00
Nikita Kniazev
bfec8c66f9 X3: skip_over: Remove redundant check
End iterator check is redundant here because it is done in skipper.
2018-03-11 17:38:51 +03:00
Nikita Kniazev
fac9dfae9e X3: Pass container attribute through sequence 2018-02-28 23:21:31 +03:00
Nikita Kniazev
f73b121a83
Merge pull request #246 from ecatmur/ubsan-abs-negation-in-unsigned
Karma: Perform negation in unsigned type to prevent UB
2018-02-24 17:57:26 +03:00
Nikita Kniazev
a1e9668c34
Merge pull request #368 from Kojoley/small-list-parser-optimization
Small list parser optimization
2018-02-24 05:01:07 +03:00
Nikita Kniazev
b0e8095a94 Suppress MSVC C4146 warning 2018-02-24 04:55:05 +03:00
Nikita Kniazev
42e1d4989b X3: Small list parser optimization 2018-02-23 23:09:34 +03:00
Nikita Kniazev
b9ac3e4a23 Added comment of implementation limitations 2018-02-23 22:42:54 +03:00
Nikita Kniazev
c7f2b86118 Removed redundant static_cast 2018-02-23 22:32:17 +03:00
Nikita Kniazev
0831d603e4 Classic: parser_names.ipp: Fixed unused parameter warnings 2018-02-22 20:49:20 +03:00
djowel
d98a785093 Merge branch 'Some-Tutorials' into develop 2018-02-21 10:50:07 +08:00
Nikita Kniazev
f324a80d83 Bump version and update changelog [skip ci] 2018-02-20 21:14:37 +03:00
Nikita Kniazev
8a29b4c574 Added missing copy assignment operator
Closes trac #8268
2018-02-18 03:10:45 +03:00
Nikita Kniazev
37bcfced65
Merge pull request #358 from Kojoley/add-some-asserts-to-real-parsers
Added some asserts to real parsers
2018-02-15 21:36:19 +03:00
Nikita Kniazev
7ba702ff8f Added some asserts to real parsers
Should prevent static analyzer false-positives.
2018-02-14 19:48:38 +03:00
Tim Angus
3d04ba605f Use traits to detect test container is empty 2018-01-24 17:27:51 +00:00
Marc Gallagher
ea57c257f6 Prevent parse_nan() from dereferencing out of range iterator 2018-01-04 15:29:32 -08:00
Nikita Kniazev
54d5ea1ea8
Merge pull request #345 from DanielaE/fix/no-iterator-inheritance
Inheriting std::iterator is deprecated in c++17
2018-01-01 19:49:28 +03:00
Nikita Kniazev
1433de2fe3 X3: Remove unused function_types includes 2017-12-30 20:52:38 +03:00
Daniela Engert
8edbebe8b3
Inheriting std::iterator is deprecated in c++17
Boost's iterator.hpp is deprecated, too. It does nothing but pulling std::iterator into namespace boost and including standard headers 'iterator' and 'cstddef'. Therefore get rid of all of that and replace inheritance by lifting std::iterator's members into the derived class.
2017-12-29 19:35:56 +01:00
Nikita Kniazev
681db787d8
X3: expect: Fix multiple specializations match
.\boost/spirit/home/x3/core/detail/parse_into_container.hpp(299): error C2752: 'boost::spirit::x3::detail::parse_into_container_impl<Parser,Context,RContext,void>': more than one partial specialization matches the template argument list
2017-12-23 03:43:53 +03:00
Nikita Kniazev
3ae9e29184
Merge pull request #152 from vogelsgesang/fix_expect_container_parsing
X3: Fix expect directive's handling of container attributes
2017-12-23 03:12:39 +03:00
Nikita Kniazev
5bd4d10619 X3: Dereference a single item view instead of unwrapping sequence
A single item sequences like `fusion::vector<T>` will be passed through,
while fusion iterators, fusion iterator range or view of size one will
be dereferenced before passing to underlying parsers of sequence parser.
2017-12-22 18:08:39 +03:00
Nikita Kniazev
6cd3d3a08f fix sequence partitioning problem (reverted from commit a8e391bd99) 2017-12-22 18:02:47 +03:00
Nikita Kniazev
12c79e2b2e Classic: Increment scanner through iterator policy
Closes https://svn.boost.org/trac10/ticket/7371

The trac ticket author was right and left unnoticed for 5 years.
2017-12-21 02:53:07 +03:00