SRD

symaction

SRD
Jun 19th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1.     struct print_action
  2.     {  
  3.         template <typename Context>
  4.         void operator()(Context const& ctx) const
  5.         {  
  6.             cout << _attr(ctx) << endl;
  7.         }
  8.     };
  9.    
  10.     auto description = *(char_ - eol) >> eol;
  11.     auto numbers = int_ >> int_ >> int_;
  12.     auto point = double_ >> double_ >> double_;
  13.     auto element = int_ >> *(char_) >> int_ >> int_ >> int_;
  14.  
  15.     auto points = skip(blank) [
  16.         *(point >> eol)
  17.     ];
  18.    
  19.     auto elements = skip(blank) [
  20.         *(element >> eol)
  21.     ];
  22.    
  23.     auto pr = [&] (auto& ctx) {
  24.         cout << "desc = " << _attr(ctx) << endl;
  25.     };
  26.    
  27.     auto pr2 = [] (auto& ctx) {
  28.         cout << _attr(ctx) << endl;;
  29.     };
  30.    
  31.     auto input = description[pr]
  32.         >> numbers[pr]
  33.         >> points  
  34.         >> elements;
  35.  
  36. /*
  37. The above works unless I add a symantic action to numbers. '>> numbers' works, 'numbers[pr]' doesn't. Anyone know why?
  38. */
Advertisement
Add Comment
Please, Sign In to add comment