Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Spirit V2.1
PrevUpHomeNext
What's changed in Spirit.Qi and Spirit.Karma from V2.0 (Boost V1.37.0) to V2.1 (Boost V1.41.0)
  • Spirit is now based on the newest version of Boost.Proto
  • 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.
  • Changed parameter sequence of qi::phrase_parse, qi::phrase_match, karma::generate_delimited, and match_delimited. The attribute is now always the last parameter.
  • Added new overloads of those functions allowing to explicitly specify the post-skipping and pre-delimiting behavior.
  • Added multi attribute API functions
  • Removed grammar_def<>
  • Removed functions make_parser() and make_generator()
  • Removed qi::none and karma::none
  • Sequences and lists now accept a standard container as their attribute
  • The string placeholder terminal now can take other strings as its parameter (i.e. std::string)
  • All terminals taking literals now accept a (lazy) function object as well
  • All placeholders for terminals and directives (such as 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).
  • The terminal placeholders 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.)
  • The 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[]
  • Added karma::maxwidth[] directive (see maxwidth)
  • Added karma::omit[] allowing to consume the attribute of subject generator without emitting any output (see omit).
  • Added 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[]
  • Karma: added and-predicate (operator&()) and not-predicate (operator!()) Both now always consume an attribute.
  • Karma: changed semantics of 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...;.
  • Added qi::attr() exposing its immediate parameter as its attribute.
  • Added boolean parsers and generators (bool_, true_, false_).
  • Added attr_cast<> enabling in place attribute type conversion in Qi and Karma grammars.
  • Almost all Karma generators now accept optional<> attributes and will fail generating if this is not initialized.
  • Qi and Karma rules now automatically detect whether to apply auto-rule semantics or not (no need for using 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.
  • Qi and Karma rules now do intrinsic attribute transformation based on the attribute customization point traits::transform_attribute.
  • All char_ parsers now always expose an attribute. Earlier char_(...) didn't expose an attribute while char_ did. If you need a literal parser not exposing any attribute use lit(...) instead.
  • The qi::int_spec, qi::real_spec, karma::int_spec, and karma real_spec types do not exist anymore. These have been replaced with qi::int_parser, qi::real_parser, karma::int_generator, and karma::real_generator.
What's changed in Spirit.Lex from V2.0 (Boost V1.37.0) to V2.1 (Boost V1.41.0)

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.

  • The lex::lexer_def class has been renamed to lex::lexer, while the original class lex::lexer does not exist anymore. This simplifies the creation of lexers.
  • The lex::lexer class does not have the function 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 = ...
          }
    };
    
  • The new lexer class can now be used directly. The function make_lexer() has been removed.
  • The 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.
  • The 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.
  • The class lex::lexertl_token_set has been removed. This functionality is now available from the lexer class.
  • The Spirit.Lex library has been updated to use the newest version of Ben Hansons Lexertl lexer construction library (Boost review pending).
  • The 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 insensitive
    
    If no parameter is passed to the constructor, match_flags::match_default is used, i.e. the . matches newlines and matching is case sensitive.
  • The char_() and string() placeholders can now be used for token definitions and are synonymous with token_def.
  • Lexer semantic actions now have to conform to a changed interface (see Lexer Semantic Actions for details).
  • Added placeholder symbols usable from the inside of lexer semantic actions while using Phoenix: lex::_start, lex::_end, lex::_eoi, lex::_state, lex::_val, and lex::_pass (see Lexer Semantic Actions for more details).
  • Added (lazy) support functions usable from the inside of lexer semantic actions while using Phoenix: lex::more(), lex::less(), and lex::lookahead() (see Lexer Semantic Actions for more details).
  • Removed lex::omitted in favor of lex::omit to unify the overall interface.

PrevUpHomeNext