2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-30 20:22:10 +00:00

17 Commits

Author SHA1 Message Date
Nana Sakisaka
e4d3fce09f Revert "Merge pull request #813 from saki7/modernize-rule-parser"
This reverts commit bae393d159, reversing
changes made to c64a9146fc.
2025-09-13 08:57:05 +09:00
Nana Sakisaka
49753e2515 Revert "Modernize x3::with (#829)"
This reverts commit e1973fcb31.
2025-09-13 08:56:51 +09:00
Nana Sakisaka
e1973fcb31 Modernize x3::with (#829)
Use concepts in `x3::with`.

`x3::with` is now a CPO that inhibits ADL.

`x3::with_directive` now holds lvalue reference by reference, and rvalue by value.
This is necessary for preventing dangling reference. However, passing dangling
lvalue reference or destroying the value bound to the reference passed to
`x3::with` technically can't be detected and it is the user's responsibility to not
do such things.

Add `x3::with` test for all 4 value categories: `T`, `T const`, `T&`, `T const&`
2025-09-11 20:54:37 +09:00
Nana Sakisaka
47945d1e81 Modernize rule, guard, on_error and on_success
`rule` now resolves the parse function using concepts, providing
significantly faster compile time & better errors.

`core/error_handler_types.hpp`: New header to separate enum
definition.

`annotate_on_success`: Modernized.

`on_error` and `on_success` now only accepts const iterators.
This is a breaking change, but we should apply this immediately
due to the reasons described below.

Historically, Spirit has passed mutable lvalue references of the
*internal* iterators to the `on_success`/`on_error` handlers. This
behavior was semantically a mistake, because:
  (1) `on_success`/`on_error` mechanism was designed to be
      grammar-agnostic, and
  (2) it does not make sense to modify the grammar-specific
      iterator on the grammar-agnostic callback.

Furthermore, any modification to X3's internal iterator variables
may invoke undefined behavior, since we had never provided any
kind of guarantee on how those variables are processed in X3's
implementation details.

In other words, I consider the old behavior as a serious BUG
that involves undefined behavior which may even lead to
security issues.

`BOOST_SPIRIT_DECLARE`: Deprecated regarding compile-time slowness
of `BOOST_PP_SEQ_FOR_EACH`.

`BOOST_SPIRIT_DEFINE`: Ditto.

`BOOST_SPIRIT_INSTANTIATE`: Deprecated because the name was not
correctly prefixed with `X3_`.

`BOOST_SPIRIT_X3_DECLARE`: New macro with correctly prefixed name.

`BOOST_SPIRIT_X3_DEFINE`: Ditto.

`BOOST_SPIRIT_X3_INSTANTIATE`: Ditto.
2025-09-07 07:29:17 +09:00
Nikita Kniazev
6a7c758376 Switch to the new location of lightweight test
Old location had been deprecated for a long time already.
2021-08-23 21:45:17 +03:00
Nikita Kniazev
40f20f0e99 X3.Tests: Disable constexpr with from rvalue test for Clang 6 and below 2020-03-31 21:58:54 +03:00
Nikita Kniazev
addeb47086 X3.Tests: Add constexpr with from lvalue test 2020-03-31 21:56:50 +03:00
Nikita Kniazev
8e94d8d783 X3: Extensive constexpr testing and fixes (#572)
I have replaced the shallow constexpr test and fixed revealed missing parts.
2020-03-06 04:17:29 +03:00
Nikita Kniazev
666fed425e X3.Tests: Fix unused argument warnings 2019-03-01 01:11:59 +03:00
Han Wang
30dfb6230a simplify with directive (3): make rvalue injection mutable 2017-08-22 15:43:34 +02:00
Han Wang
6412f88813 simplify with directive (2): add test cases 2017-08-22 12:15:42 +02:00
Joel de Guzman
0adee06b27 cleaning up the tests 2015-05-14 02:13:24 +08:00
Joel de Guzman
528c1de366 made on_success mechanism as a member of the rule ID 2014-05-26 13:06:58 +08:00
Joel de Guzman
168e202365 making the rule ID more useful by making it a class where you define on_error (and later on_success) hooks. 2014-05-26 12:38:30 +08:00
Joel de Guzman
571fcb07ba fixed for new on_error interface 2014-05-25 08:34:38 +08:00
Joel de Guzman
f9e3f874cc porting calc7 to x3 2014-05-02 08:58:53 +08:00
Joel de Guzman
7f111eb070 added with directive 2014-05-02 08:30:37 +08:00