...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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.
traits::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 stand alone 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.