1[/============================================================================== 2 Copyright (C) 2001-2011 Joel de Guzman 3 Copyright (C) 2001-2011 Hartmut Kaiser 4 5 Distributed under the Boost Software License, Version 1.0. (See accompanying 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7===============================================================================/] 8 9[section Number List Attribute - one more, with style] 10 11You've seen that the `double_` parser has a `double` attribute. All parsers have 12an attribute, even complex parsers. Those that are composed from primitives 13using operators, like the list parser, also have an attribute. It so happens that 14the attribute of a list parser: 15 16 p % d 17 18is a `std::vector` of the attribute of `p`. So, for our parser: 19 20 21 double_ % ',' 22 23we'll have an attribute of: 24 25 std::vector<double> 26 27 28So, what does this give us? Well, we can simply pass in a `std::vector<double>` 29to our number list parser and it will happily churn out our result in our 30vector. For that to happen, we'll use a variation of the `phrase_parse` with 31an additional argument: the parser's attribute. With the following arguments 32passed to `phrase_parse` 33 34# An iterator pointing to the start of the input 35# An iterator pointing to one past the end of the input 36# The parser object 37# Another parser called the skip parser 38# The parser's attribute 39 40our parser now is further simplified to: 41 42[import ../../example/qi/num_list4.cpp] 43 44[tutorial_numlist4] 45 46The full cpp file for this example can be found here: [@../../example/qi/num_list4.cpp] 47 48[*Hey, no more actions!!!] Now we're entering the realm of attribute grammars. 49Cool eh? 50 51[endsect] 52