Re: [Spirit Development] Bug using operator >> and > in same sequence

Robert Nelson <[email protected]> Sun, 2 Jan 2011 13:49:19 -0700
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <[email protected]>
If the bug were only because of operator precedence you should be able
to fix it with parentheses.  Consider the following related example:

((int_ >> int_) > (int_ >> int_))[_val = construct<point>(_1,_2,_3,_4)]
This rule fails to compile because the type of the parser is
[[int,int],[int,int]]
Basically, the > operator _cannot_ flatten two sequences constructed
with the >> operator.
the next rule, works, however,
((int_ >> int_) >> (int_ >> int_))[_val = construct<point>(_1,_2,_3,_4)]
This rule works because the >> _can_ flatten two sequences constructed
with the >> operator.

The expressions here are fully parenthesized, so operator precedence
does not play a part in this.  The only difference is the operators
used.

Example program:

#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/home/phoenix/object/construct.hpp>
#include <string>

int main()
{
  using namespace boost::spirit::qi;
  using namespace boost::phoenix;
  typedef boost::fusion::vector4<int,int,int,int> point;
  rule<std::string::const_iterator,point()> rule = ((int_ >> int_) >
(int_ >> int_))[_val = construct<point>(_1,_2,_3,_4)];
}



Thanks
--Robert Nelson

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl

_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel
main.cpp (text/x-c++src, 439 B)
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/home/phoenix/object/construct.hpp>
#include <string>

int main()
{
  using namespace boost::spirit::qi;
  using namespace boost::phoenix;
  typedef boost::fusion::vector4<int,int,int,int> point;
  rule<std::string::const_iterator,point()> rule = ((int_ >> int_) > (int_ >> int_))[_val = construct<point>(_1,_2,_3,_4)];
}