Carlo Wood | 1 Oct 05:13
Gravatar

Compile error

I tried to write something that links a grammar with a file...
However, I failed; I get a huge compile error.

Can someone please tell me what I'm doing wrong here?
It has to be wrong because it seems that my grammar
doesn't even know about the used scanner type, or doesn't
it have to know?

I'm highly confused.

PS I posted another mail before this one with 'Hello world'
   as subject, but I never saw it back on the list??

-------------------------------------------------------------------------------
#include <iostream>
#include <fstream>
#include <boost/spirit/core.hpp>    
#include <boost/spirit/iterator/multi_pass.hpp>
//#include "PgnGrammar.h"
// being:
#include <boost/spirit.hpp>

namespace cwchess {
namespace pgn {
namespace grammar {

// Define whether the rules should generate debug output.
#define TRACE_PGN_GRAMMAR 1

class PgnGrammar : public boost::spirit::grammar<PgnGrammar> {
(Continue reading)

Joel de Guzman | 1 Oct 06:06
Picon
Favicon

Re: Compile error

Carlo Wood wrote:
> I tried to write something that links a grammar with a file...
> However, I failed; I get a huge compile error.
> 
> Can someone please tell me what I'm doing wrong here?
> It has to be wrong because it seems that my grammar
> doesn't even know about the used scanner type, or doesn't
> it have to know?
> 
> I'm highly confused.
> 
> PS I posted another mail before this one with 'Hello world'
>    as subject, but I never saw it back on the list??
> 

Hi Carlo,

You might want to minimize the code to only the problem parts.

Regards,
--

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
(Continue reading)

Carlo Wood | 1 Oct 14:14
Gravatar

Re: Compile error

On Wed, Oct 01, 2008 at 12:06:36PM +0800, Joel de Guzman wrote:
> You might want to minimize the code to only the problem parts.

It is already pretty minimal... you can ignore the grammar
easily yourself :/

Here it is again, without the grammar (see the previous post
if that is needed for the class definition or something):

#include <iostream>
#include <fstream>
#include <boost/spirit/core.hpp>    
#include <boost/spirit/iterator/multi_pass.hpp>
#include "PgnGrammar.h"

namespace {

std::ifstream in("test.pgn");

typedef char char_t;
typedef boost::spirit::multi_pass<std::istreambuf_iterator<char_t> > iterator_t;

typedef boost::spirit::skip_parser_iteration_policy<boost::spirit::space_parser> iter_policy_t;
typedef boost::spirit::scanner_policies<iter_policy_t> scanner_policies_t;
typedef boost::spirit::scanner<iterator_t, scanner_policies_t> scanner_t;

iter_policy_t iter_policy(boost::spirit::space_p);
scanner_policies_t policies(iter_policy);
iterator_t first(boost::spirit::make_multi_pass(std::istreambuf_iterator<char_t>(in)));
iterator_t last(boost::spirit::make_multi_pass(std::istreambuf_iterator<char_t>()));
(Continue reading)

Carlo Wood | 1 Oct 14:19
Gravatar

Re: Compile error

On Wed, Oct 01, 2008 at 05:13:09AM +0200, Carlo Wood wrote:
>   boost::spirit::parse_info<iterator_t> info = parse(first, last, g, boost::spirit::space_p);	//
COMPILE ERROR

Somewhere it said that a grammar IS-A parser... and so I put
my 'g' in code I found for a parser. But that didn't work thus.

I found it, the above line should read:

    boost::spirit::parse_info<iterator_t> info = parse(first, last, g);

then it compiles.

--

-- 
Carlo Wood <carlo <at> alinoe.com>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Carlo Wood | 1 Oct 15:41
Gravatar

How does parsing white-space work?

Hi again,..

I'm using the following rule:

        tag_pair = ch_p('[') >> tag_name >> tag_value >> ch_p(']');

In the input there is a space between 'tag_name' and 'tag_value',
and I was expecting that to be gobbled up automatically.
However, this rules fails because 'tag_value' is called at
the moment the input is at this space and fails.

Can someone give me a hint on what I'm doing wrong here?

I was under the impression that white spaces are eaten at
the place of a '>>' unless you wrap the rule in a lexeme_d[].

--

-- 
Carlo Wood <carlo <at> alinoe.com>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Satya Das | 1 Oct 15:45
Picon
Favicon

Re: How does parsing white-space work?

I guess this is because you have removed space_p as last parameter from boost::spirit::parse().

-----Original Message-----
From: Carlo Wood [mailto:carlo <at> alinoe.com]
Sent: Wednesday, October 01, 2008 7:12 PM
To: Spirit General Mailing List
Subject: [Spirit-general] How does parsing white-space work?

Hi again,..

I'm using the following rule:

        tag_pair = ch_p('[') >> tag_name >> tag_value >> ch_p(']');

In the input there is a space between 'tag_name' and 'tag_value',
and I was expecting that to be gobbled up automatically.
However, this rules fails because 'tag_value' is called at
the moment the input is at this space and fails.

Can someone give me a hint on what I'm doing wrong here?

I was under the impression that white spaces are eaten at
the place of a '>>' unless you wrap the rule in a lexeme_d[].

--
Carlo Wood <carlo <at> alinoe.com>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
(Continue reading)

Carlo Wood | 2 Oct 00:46
Gravatar

Re: How does parsing white-space work?

On Wed, Oct 01, 2008 at 07:15:15PM +0530, Satya Das wrote:
> I guess this is because you have removed space_p as last parameter from boost::spirit::parse().

I guess that too, but it doesn't compile WITH it.
So, what is the solution?

--

-- 
Carlo Wood <carlo <at> alinoe.com>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Shannon Weyrick | 1 Oct 14:11

Spirit v2 Lexer

Hi, is there are way to flip the "dot_not_newline" functionality for the 
rules in a lexer_def? In other words, I'd like the . to match anything, 
including new lines, in one particular rule. Browsing the lexertl source 
a bit, it seems this is possible but I don't know how to get to it from 
the rule definitions.

Thanks,
Shannon

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Joel de Guzman | 2 Oct 05:59
Picon
Favicon

Re: How does parsing white-space work?

Carlo Wood wrote:
> On Wed, Oct 01, 2008 at 07:15:15PM +0530, Satya Das wrote:
>> I guess this is because you have removed space_p as last parameter from boost::spirit::parse().
> 
> I guess that too, but it doesn't compile WITH it.
> So, what is the solution?

Again, please try to post a minimal cpp file that we can try.
I think that is a reasonable policy for user support. Also,
it is your best bet for other people to look into your code.
The compiler is better at finding the errors but this requires
the human to decipher what the errors are. Quite simply, the
minimal the code is, the lesser time involved in isolatng the
problem.

Regards,
--

-- 
Joel de Guzman
http://www.boostpro.com
http://spirit.sf.net

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
Anubis | 2 Oct 14:07
Picon
Picon
Favicon

[Fusion2] BOOST_FUSION_ADAPT_STRUCT breaks with too many ", "

How do you trick the preprocessor into accepting code containing "," as a
single parameter?

I cannot get BOOST_FUSION_ADAPT_STRUCT to work with templated types with
more than 1 template parameter.

struct Sample
{
        anytype1 foo;
        anytype2<templateParameter1> bar;
        anytype3<templateParameter1,templateParameter2> oh_no_I_will_break;
};

BOOST_FUSTION_ADAPT_STRUCT (
        Sample,
        (anytype1,foo)
        (anytype2<templateParameter1>,bar)
*       (anytype3<templateParameter1,templateParameter2>,oh_no_I_will_break;
)

The line marked with "*" will break because there are two ",", so 3
Parameters instead of 2 are passed. Is there a way to trick the
preprocessor into doing what is intended?

Cheers,
Thomas

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
(Continue reading)


Gmane