| Home | Libraries | People | FAQ | More

### Spirit V2.4.2

##### What's changed in Spirit.Qi and Spirit.Karma from V2.4.1 (Boost V1.45.0) to V2.4.2 (Boost V1.46.0)

##### New Features in Qi or Karma

- Added keyword indexes for Spirit.Qi and Spirit.Karma to the docs.
- Introduced a new customization point `traits::assign_to_container_from_value` which is invoked for container attributes whenever an attribute value needs to be added to that container.
- Replaced `proto::lit` (which was used to implement `spirit::lit`) with a separate version allowing to distinguish 'lit(foo)' from 'foo'. This should not change any semantics nor should it break exiting code.
- Added the Spirit.Qi directive `as<T>[]` (and its string specializations `as_string[]` and `as_wstring[]`) enabling assignment of container attribute types as a whole.
- Added the Spirit.Karma directive `as<T>[]` (and its string specializations `as_string[]` and `as_wstring[]`) enabling handling of container attribute types during output generation as a whole.
- In Spirit.Qi, `lit()` can now be used for numeric literals as well.
- The `symbols<>` parser component now has an explicit name used for error handling and debugging, which can be set using the new member functions `sym.name(...)`. Thanks to teajay for contributing a patch.
- The `symbols<Attrib, T>` generator component now has an explicit name used for error handling and debugging, which can be set using the new member functions `sym.name(...)`.

##### Bug Fixes in Qi or Karma

- Fixed a problem in handling container attributes for Spirit.Qi sequences, which caused the properly parsed attributes of the first elements being overwritten by later elements of the sequence.
- Fixed the Spirit.Karma generator `string(s)`. It succeeded even if `s` matched only a prefix of its attribute.

##### What's changed in Spirit.Lex from V2.4.1 (Boost V1.45.0) to V2.4.2 (Boost V1.46.0)

##### New Features in Lex

- Added `qi::tokenid()` primitive parser allowing to match arbitrary lexer tokens based on a given token id. The difference to `qi::token()` is, that it exposes as its attribute the token id of the matched token (instead of the iterator_range of the matched input, as `qi::token()` does).
- Added an additional template parameter to the default `lexertl::token<>` definition: the type of the token id. This type defaults to `std::size_t`. Any type used as the id type needs to be (explicitly) convertible from `std::size_t`.
- It's now possible to attach lexer semantic actions to token definitions based on `lex::char()` and `lex::string()`.
- It's now possible to specify a lexer state the lexer should automatically be switched to after matching certain tokens. For this reason the token definition syntax has been extended:

      template <typename Lexer>
      struct lexer : lex::lexer<Lexer>
      {
          lexer()
          {
              int_ = "[1-9][0-9]*";
              this->self("INITIAL", "TARGETSTATE") = int_;
          }
          lex::token_def<int> int_;
      };

  This example lexer will match a `int_` token and will switch the lexer to the state `"TARGETSTATE"` afterwards. If the second argument is not specified the lexer remains in the previous state (as before).
- The parser primitives `qi::token` and `qi::tokenid` can now be used without any argument. In this case they will match any token.
- `lex::lit()` has been removed.

##### Bug Fixes in Lex

- Fixed an issue in the Lexer giving problems while assigning tokens to all lexer states at once. This is now possible by simply using "*" as the state name. For instance this will add the token int_ to all lexer states:

      template <typename Lexer>
      struct lexer : lex::lexer<Lexer>
      {
          lexer()
          {
              int_ = "[1-9][0-9]*";
              this->self("*") = int_;
          }
          lex::token_def<int> int_;
      };

  Note: the `self("*") = ...` must be executed after all lexer states have been introduced to the lexer object.
- Fixed lexer lookahead. The lookahead operation is now evaluated using the lexer state the `token_def` instance used as its argument is associated with.
- Fixed a problem in the `multi_pass` iterator causing wrong tokens to be returned to the user. This could happen in conjunction with a lexer which performed lexer state changes and was using `pass_fail` in semantic actions to make a token match fail.

##### Known Problems

- Spirit.Qi integer literals (like `int_(10)`) consume input on failure, which can lead to problems with the alternative operator.