Re: X3 problem

Mikael Asplund <[email protected]>
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
Hi!

Thanks for your answer! I made a new example with using a rule as you suggested, but that doesn't work either...

http://coliru.stacked-crooked.com/a/990cbbaf3551d072

( Doesn't work even if I make it non-optional:  http://coliru.stacked-crooked.com/a/8ded10bcf9d4db41 )

#include <iostream>
#include <string>
#include <vector>
#include <boost/spirit/home/x3.hpp>
#include <boost/optional.hpp>
#include <boost/fusion/include/adapt_struct.hpp>

using std::string;
using std::vector;
using std::pair;

namespace x3 = boost::spirit::x3;

int parse_input(vector<string> v);

int main(int argc, const char* argv[]) {
    if (argc > 1) {
      return parse_input(vector<string>(&argv[1], &argv[argc + !argc]));
    }
    return 1;
}

struct XXX {
  int a;
  boost::optional<pair<int, int>> b;
};

BOOST_FUSION_ADAPT_STRUCT(XXX, a, b)

class apair_class;
using apair_type = x3::rule<apair_class, std::pair<int, int>>;
const apair_type apair = "pair";
const auto apair_def = x3::int_ >> x3::int_;

int parse_input(vector<string> v) {
  std::stringstream ss;
  std::copy(v.begin(), v.end(), std::ostream_iterator<string>(ss, " "));
  string s = ss.str();
  auto iter = s.begin();
  auto end = s.end();
  XXX x;
  bool success = x3::phrase_parse(iter, end, x3::int_ >> -apair, x3::space, x);
  return !success;
}

BOOST_SPIRIT_DEFINE(apair)


-----Original Message-----
From: Joel de Guzman [mailto:[email protected]] 
Sent: Wednesday, March 9, 2016 00:47
To: [email protected]
Subject: Re: [Spirit-general] X3 problem

On 08/03/2016 6:23 AM, Mikael Asplund wrote:
> Hi!
>
> I really can't figure out what's wrong with this... Can anyone figure out what's wrong?
> Using boost 1.60.
>
> It seem to be exactly as prescribed, and the error messages that X3 
> produce are less then
> helpful:
>
> http://coliru.stacked-crooked.com/a/5c128d4f02379eb8
>
[...]

Looks like a bug. I'll have to investigate deeper. For now, please use a separate rule for the optional part.

Regards,
--
Joel de Guzman
http://www.ciere.com
http://boost-spirit.com
http://www.cycfi.com/


------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://makebettercode.com/inteldaal-eval
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.