mirror of
https://github.com/boostorg/spirit.git
synced 2026-01-19 04:42:11 +00:00
`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.
50 lines
1.8 KiB
C++
50 lines
1.8 KiB
C++
/*=============================================================================
|
|
Copyright (c) 2019 Nikita Kniazev
|
|
Copyright (c) 2025 Nana Sakisaka
|
|
|
|
Use, modification and distribution is subject to the Boost Software
|
|
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
|
http://www.boost.org/LICENSE_1_0.txt)
|
|
=============================================================================*/
|
|
|
|
#include "rule_separate_tu_grammar.hpp"
|
|
|
|
#include <boost/spirit/home/x3.hpp>
|
|
|
|
namespace unused_attr {
|
|
|
|
auto const skipper_def = x3::standard::lit('*');
|
|
BOOST_SPIRIT_X3_DEFINE(skipper)
|
|
BOOST_SPIRIT_X3_INSTANTIATE(skipper_type, char const*, x3::unused_type)
|
|
|
|
auto const skipper2_def = x3::standard::lit('#');
|
|
BOOST_SPIRIT_X3_DEFINE(skipper2)
|
|
BOOST_SPIRIT_X3_INSTANTIATE(skipper2_type, char const*, x3::unused_type)
|
|
|
|
auto const grammar_def = *x3::standard::lit('=');
|
|
BOOST_SPIRIT_X3_DEFINE(grammar)
|
|
BOOST_SPIRIT_X3_INSTANTIATE(grammar_type, char const*, x3::unused_type)
|
|
|
|
using skipper_context_type = typename x3::phrase_parse_context<skipper_type, char const*>::type;
|
|
BOOST_SPIRIT_X3_INSTANTIATE(grammar_type, char const*, skipper_context_type)
|
|
|
|
using skipper2_context_type = typename x3::phrase_parse_context<skipper2_type, char const*>::type;
|
|
BOOST_SPIRIT_X3_INSTANTIATE(grammar_type, char const*, skipper2_context_type)
|
|
|
|
}
|
|
|
|
namespace used_attr {
|
|
|
|
auto const skipper_def = x3::standard::space;
|
|
BOOST_SPIRIT_X3_DEFINE(skipper)
|
|
BOOST_SPIRIT_X3_INSTANTIATE(skipper_type, char const*, x3::unused_type)
|
|
|
|
auto const grammar_def = x3::int_;
|
|
BOOST_SPIRIT_X3_DEFINE(grammar)
|
|
BOOST_SPIRIT_X3_INSTANTIATE(grammar_type, char const*, x3::unused_type)
|
|
|
|
using skipper_context_type = typename x3::phrase_parse_context<skipper_type, char const*>::type;
|
|
BOOST_SPIRIT_X3_INSTANTIATE(grammar_type, char const*, skipper_context_type)
|
|
|
|
}
|