2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00

26 Commits

Author SHA1 Message Date
Xeverous
a6c0b0bb6a X3: rollback iterator when rule fails to parse
This commit adjusts work of commit 2db3fde.
It corrected error_handler which should not skip whitespaces but
introduced a regression where handlers returning fail were still
moving the iterator forward. This commit adds iterator rollback
and synchronizes rule's and guard's iterators behavior.
2025-10-06 11:55:52 +02:00
Nana Sakisaka
63fabece48 Revert "Use concepts for attribute category overload resolution (#812)"
This reverts commit c64a9146fc.
2025-09-13 08:57:06 +09:00
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
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
Nana Sakisaka
c64a9146fc Use concepts for attribute category overload resolution (#812)
* Use concepts for attribute category overload resolution

`x3::traits::move_to`: Dump tag dispatching and use concepts for
overload resolution. This drastically improves compilation speed and
prints significantly concise errors on ill-formed programs, thanks to
the reduced nesting level on the entire control flow of X3. Also
partially (but not yet completely) improves #346 due to reduced MPL usage.

`x3::detail::parse_into_container`: Ditto.

`support/traits/optional_traits.hpp`:
  `BOOST_SPIRIT_X3_USE_BOOST_OPTIONAL`: new macro.
  Default to `boost::optional` unless above macro is defined as `0`. Implements
  `std::optional` handling regardless of the value; fixes #270.
  Note that most test suites are intentionally not defining above macro as `1` 
  (yet) to make sure the change does not break existing codes.

`x3::optional`: Ideally this should've split into a separate PR, but the
new attribute category handling requires the overhaul on this.

`core/proxy.hpp`: Removed. `x3::optional` was the only derived parser
which used this feature for years. We shouldn't support any overly
generic 'core' features whose extandable use case is unknown even to the
core components.

`extract_int`, etc.: Adjusted to properly "move" the local attribute
variable before passing it to `x3::traits::move_to`.

`char_parser`: Ditto, but this constructs temporary value instead of
applying `std::as_const`. Const references are costly for primitive type
like `Char` thus prvalue should be constructed here.

tests: No semantic changes intended. All changes exists solely for
adapting to the new attribute category handling (implementation details.)

* Fix incorrect `noexcept` specification

* Compensate for potential GCC bug on constraint satisfaction

It turns out that GCC 14 does not like the form below, resulting
in silently defining the flipped value (!) without raising any sort of
hard/soft errors in well-formed code.

```
struct S : std::bool_constant<requires(...) { ... }> {};
```

* Use the correct path to retrieve action cache

<638ed79f9d/restore (ensuring-proper-restores-and-save-happen-across-the-actions)>
> It is very important to use the same key and path that were used by either actions/cache or actions/cache/save while saving the cache.
2025-09-07 04:55:57 +09:00
Nikita Kniazev
7b7a09db8c X3: Return back iterator pre-skipping for on_success handler
Reverts the wrong part of #686.
2022-01-21 02:28:58 +03:00
Nikita Kniazev
2f5c2cb718 X3: Fix on_success dispatcher inverted iterator const/mutability
Instead of usual `[current, end)` pair it receives `[before, current)` pair.
2022-01-15 20:28:48 +03: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
db8bdf3d71 Fix GCC -Wshadow-local and MSVC C4457
GCC bug reported https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100608

Fixes #676
2021-05-17 03:02:19 +03:00
Nikita Kniazev
358246673b X3.Tests: Fix some C4244 warnings 2021-02-25 21:50:24 +03:00
Nikita Kniazev
0ab06abfc6 Annotate, clean up, and group extended ASCII tests 2019-03-01 22:50:15 +03:00
Nikita Kniazev
666fed425e X3.Tests: Fix unused argument warnings 2019-03-01 01:11:59 +03:00
Joel de Guzman
3627a46902 more test updates and cleanup 2015-05-14 07:40:18 +08:00
Joel de Guzman
c5fe8848ce added explicit force_attribute bool template parameter to rule 2015-04-08 14:34:29 +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
913a092ee6 reverting previous mistakes 2014-05-25 08:29:56 +08:00
Joel de Guzman
1a960e4bba All tests are now passing. 2014-05-17 09:25:06 +08:00
Joel de Guzman
f9e3f874cc porting calc7 to x3 2014-05-02 08:58:53 +08:00
Joel de Guzman
26b0e9e1f0 action should be in core, not auxilary 2014-04-09 12:57:52 +08:00
Joel de Guzman
f88d50853c use enum class for error_handler_result 2014-04-09 11:54:09 +08:00
Joel de Guzman
e24686ea6f added on_sucess handler (complements on_error) 2014-04-09 11:40:02 +08:00
Joel de Guzman
c0c07026dc Ported calc5 to X3 (Same as Calc4, this time, we'll incorporate debugging support, plus error handling and reporting). 2014-04-09 08:34:57 +08:00
Joel de Guzman
e1dffe91c3 impemented rule %= operator 2014-04-08 11:30:13 +08:00
Joel de Guzman
92dfab37fa added offline error handling for rules 2014-04-07 15:26:12 +08:00
Joel de Guzman
5767624292 preparing for migration to boost devel 2014-03-18 10:53:30 +08:00