...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
auto_
component in
Spirit.Qi and Spirit.Karma, added
API functions qi::
create_parser
and karma::
create_generator
.
auto_
based overloads
for all API functions taking no attributes (see Qi
API and Karma
API).
karma::columns
directive.
karma::
symbols
generator.
push_back_container
now returns
a bool
to report whether the
item has been added to the container.
karma::maxwidth
directive allowing to specify
an additional parameter (any compatible output iterator) receiving the 'overspilled'
output (output not fitting into the maxwidth limit).
basic_istream_iterator<Char, Traits>
usable as an equivalent for std::istream_iterator
except its a ForwardIterator
allowing to parse
directly from any std::basic_istream
.
qi::
matches
directive.
*stream
| "empty"
(which fixes the Karma example basic_facilities.cpp).
qi::repeat[]
for unused attributes.
karma::repeat[]
.
lex::token_def::what
.
qi::symbols::prefix_find
to allow matching of (prefix-)
substrings.
phoenix::val
), for integral values this was not
necessary. Now all string types can be passed without being wrapped as well
(i.e. std::string
, char
const*
,
etc.).
std::forward_iterator_tag
.
qi::match
and qi::phrase_match
set of API functions not to internally utilize a std::stream_iterator
anymore as this iterator is of the type std::input_iterator_tag
only, which is not sufficient for Spirit.Qi.
qi::phrase_parse
, qi::phrase_format
now post-skip by default.
karma::generate_delimited
and karma::format_delimited
now don't do pre- delimiting by default.
qi::phrase_parse
,
qi::phrase_match
, karma::generate_delimited
,
and match_delimited
. The
attribute is now always the last parameter.
grammar_def<>
make_parser()
and make_generator()
qi::none
and karma::none
int_
,
double_
, verbatim
,
etc.) were previously defined in the namespace boost::spirit
only. Now these are additionally imported into the namespaces spirit::qi
, spirit::karma
,
and spirit::lex
(if they are supported by the corresponding
sub-library).
char_
and string
are not defined
in the namespace boost::spirit
anymore as they have been moved
to the character set namespaces, allowing to do proper character set handling
based on the used namespace (as spirit::ascii
,
etc.)
uint
, ushort
,
ulong
, and byte
terminal placeholders have been renamed
to uint_
, ushort_
,
ulong_
, and byte_
.
qi::skip[]
now re-enables outer skipper if used inside lexeme[]
karma::maxwidth[]
directive (see maxwidth
)
karma::omit[]
allowing to consume the attribute of subject generator without emitting any
output (see omit
).
karma::buffer[]
allowing to avoid unwanted output to be generated in case of a generator
failing in the middle of a sequence (see buffer
).
karma::delimit[]
now re-enables outer delimiter if used inside verbatim[]
operator&()
) and not-predicate (operator!()
)
Both now always consume an attribute.
char_()
, string()
, int_()
et.al., and double_()
et.al.: all of these generators now always
expose an attribute. If they do not have an associated attribute, they generate
their immediate literal. If they have an associated attribute, the generators
first test if the attribute value is equal to the immediate literal. They
fail and do not generate anything if those are not equal. Otherwise they
generate their immediate literal. For more information see for instance
int_
.
karma::lit()
can
now be used to generate integer and floating point numbers
qi::rule
and karma::rule
now can be directly initialized using their copy constructor. I.e. this works
now: qi::rule<...>
r = ...some parser...;
.
qi::attr()
exposing its immediate parameter as its attribute.
bool_
,
true_
, false_
).
attr_cast<>
enabling in place attribute type conversion in Qi and Karma grammars.
optional<>
attributes and will fail generating
if this is not initialized.
operator%=()
anymore, even if it's still existing).
Auto-rule semantics are applied if the right hand side has no semantic actions
attached to any of the elements. This works for rule initialization and assignment.
transform_attribute
.
char_(...)
didn't expose an attribute while char_
did. If you need a literal parser
not exposing any attribute use lit(...)
instead.
Here is a list of changes in Spirit.Lex since version 2.0. Spirit.Lex 2.1 is a complete rewrite of the Spirit.Lex distributed with Boost V1.37. As with all code portions of the Spirit library, Spirit.Lex is usable as standalone piece. Spirit.Lex now uses the infrastructure provided by Spirit version 2.1.
def(Self&
self)
anymore, token definitions can be added to the lexer at any time, usually
in the constructor of the user defined lexer class:
template <typename Lexer> struct example_tokens : lex::lexer<Lexer> { example_tokens() { // your token definitions here this->self = ... } };
make_lexer()
has been removed.
lex::tokenize_and_parse()
and lex::tokenize_and_phrase_parse()
functions have been changed to match the parameter sequence as implemented
by the qi::parse()
and qi::phrase_parse()
functions. Both take an arbitrary number of attribute arguments as the last
parameters. This argument list is limited by the macro SPIRIT_ARGUMENTS_LIMIT
.
lex::lexertl_lexer
, and lex::lexertl_token
classes have been moved to the lex::lexertl
namespace and the names have been changed to lex::lexertl::lexer
,
lex::lexertl::token
. This also applies to the lex::lexert_actor_lexer
,
and the static_lexertl_*
family of types.
lex::lexertl_token_set
has been removed. This
functionality is now available from the lexer class.
lex::lexer<Lexer>
template constructor now takes an optional parameter specifying the match_flags
to be used for table generation.
Currently, there are the following flags available:
match_flags::match_default, // no flags match_flags::match_not_dot_newline, // the regex '.' doesn't match newlines match_flags::match_icase // all matching operations are case insensitiveIf no parameter is passed to the constructor,
match_flags::match_default
is used, i.e. the .
matches
newlines and matching is case sensitive.
char_()
and string()
placeholders can now be used for token definitions and are synonymous with
token_def
.
lex::_start
,
lex::_end
, lex::_eoi
,
lex::_state
, lex::_val
,
and lex::_pass
(see Lexer
Semantic Actions for more details).
lex::more()
, lex::less()
, and lex::lookahead()
(see Lexer
Semantic Actions for more details).
lex::omitted
in favor of lex::omit
to unify the overall interface.
The Spirit V1.8.x code base has been integrated with Spirit V2. It is now called Spirit.Classic. Since the directory structure has changed (the Spirit Classic headers are now moved to the $BOOST_ROOT/boost/spirit/home/classic directory), we created forwarding headers allowing existing applications to compile without any change. However, these forwarding headers are deprecated, which will result in corresponding warnings generated for each of the headers starting with Boost V1.38. The forwarding headers are expected to be removed in the future.
The recommended way of using Spirit Classic now is to include header files from the directory $BOOST_ROOT/boost/spirit/include. All Spirit Classic headers in this directory have 'classic_' prefixed to their name. For example the include
#include <boost/spirit/core/core.hpp>
now should be written as:
#include <boost/spirit/include/classic_core.hpp>
To avoid namespace conflicts with the new Spirit V2 library we moved Spirit
Classic into the namespace boost::spirit::classic
.
All references to the former namespace boost::spirit
need to be adjusted as soon as the header names are corrected as described
above. As an alternative you can define the preprocessor constant BOOST_SPIRIT_USE_OLD_NAMESPACE
, which will
force the Spirit Classic code to be in the namespace boost::spirit
as before. This is not recommended, though, as it may result in naming clashes.
The change of the namespace will be automatically deactivated whenever the deprecated include files are being used. This ensures full backwards compatibility for existing applications.