Gmane
From: Yusaku Sugai <sugai <at> nfc.co.jp>
Subject: intersection with skip parser
Newsgroups: gmane.comp.parsers.spirit.general
Date: 2005-01-31 12:05:03 GMT (4 years, 21 weeks, 6 days, 16 hours and 55 minutes ago)
Hello,
I used Spirit to write CSS parser
(it reduced lots of my labor, thanks Spirit developers!)
and got a little problem.
This (simplified) sample code causes compile error on VC7.1.

> using namespace boost::spirit;
> parse( "foo", (anychar_p & anychar_p), ch_p(' ') );

I guess it's caused in the following way.
Let me quote from spirit/core/composite/intersection.hpp

> template <typename ScannerT>
> typename parser_result<self_t, ScannerT>::type
> parse(ScannerT const& scan) const
> {
>   typedef typename parser_result<self_t, ScannerT>::type result_t;
>   typedef typename ScannerT::iterator_t iterator_t;
>   iterator_t save = scan.first;
>   if (result_t hl = this->left().parse(scan))
>   {
>     ScannerT bscan(scan.first, scan.first);
>     scan.first = save;
>     result_t hr = this->right().parse(bscan);
>     if (hl.length() == hr.length())
>       return hl;
>   }
>   return scan.no_match();
> }

Here, bscan is constructed with only two arguments
while ScannerT(class scanner, in this case)'s constructor
can take scanner policy as third argument.
So in case scan uses non-default scanner policy,
constructing bscan with default scanner policy
makes some incompatibility which, I guess, leads to compile error.

My solution is to give bscan scanner policy part of scan
as third argument.

> ScannerT bscan(scan.first, scan.first, scan);

It seems working well, so far.
Is this a right approach?

Thanks.

--
Yusaku Sugai

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl