Braden McDaniel | 3 Jun 08:21
Gravatar

error_status<>::accept

In the example program error_handling.cpp, if the handler::operator() is
changed to return "error_status<>(error_status<>::accept)", the
assertion at the end of main still doesn't fail. That's not what I
expected.

Is this the intended behavior? I'd like to get a successful match after
triggering an error handler in order to display warnings.

--

-- 
Braden McDaniel                           e-mail: <braden <at> endoframe.com>
<http://endoframe.com>                    Jabber: <braden <at> jabber.org>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Joel de Guzman | 3 Jun 16:23
Picon
Favicon

Re: Spirit 1.6.4 & 1.8.5 tagged in CVS

Nicola Musatti wrote:
> Hallo,
> I have tagged the 1.6.4 and 1.8.5 release candidates as follows:
> SPIRIT_1_6_4		Spirit 1.6.4 standalone
> SPIRIT_1_6_4_MINIBOOST	Spirit 1.6.4 miniboost
> SPIRIT_1_8_5		Spirit 1.8.5 standalone
> SPIRIT_1_8_5_MINIBOOST	Spirit 1.8.5 miniboost
> SPIRIT_MINIBOOST_1_34_0	The new 1.34.0 based miniboost
> 
> I tested 1.6.4 with g++ 2.95.3, MSVC 6.0 SP5, BCB6 and BCB2006, and 
> 1.8.5 with g++ 3.4.5, g++ 4.1.0 and MSVC 8.0, all on windows and with 
> Boost 1.34.0 . I didn't test with any other Boost release.
> 
> I'd be very grateful if anybody could check these out, both from CVS and 
> to see that they work ;-) Apart from reviewing the readme files I don't 
> intend to do any modifications.
> 
> My current plan is to wait for Boost 1.34.1 to be released and then to 
> rebase the miniboost and proceed with the release.
> 
> Comments and suggestions are obviously welcome.

Thank you very much!

(cross-posting to the spirit general list)

Hey, guys, can't emphasize this more. Please check it out. The
more people out there actually testing the pre-release, the better
our release will be. I can't emphasize enough the importance of
that. Your feedback is highly appreciated. We'd like to know
(Continue reading)

Catalin Ionescu | 4 Jun 13:03
Picon
Favicon

help with closures

Hello all,

I need some help with closures. I've written code using the closures to
create a custom made AST and I'm running into problems. I don't
understand what I should do to be able to push the references up the
parse tree. Here is a small code snippet of what I have to deal with:

///// code 
struct pctl_grammar_closure :
boost::spirit::closure<pctl_grammar_closure, SPCTLProbabilisticFormula>
{
  member1 formula;
};

struct pctl_expr_closure : boost::spirit::closure <pctl_expr_closure,
SPCTLFormula, CToken, SPCTLFormula> {
  member1 left;
  member2 op;
  member3 right;
};
/// snip 

struct SPctlParser : public grammar<SPctlParser,
pctl_grammar_closure::context_t> {
  template <typename ScannerT>
  struct definition {

      definition(SPctlParser const& self) {

        prop
(Continue reading)

Favicon

Rules for parsing A B and C in any order

Dear all,
 
I'm writing a grammar and I am wondering if there is a way to parse a number of symbols/rules in any order. For example I want to accept any strings with 0-1 A symbols, 1 B symbol, and 1 or more C symbols, but I don't mind the order. e.g. ACCCBCCCCC or CCCCBA.
 
I've looked at the standard operators, but I can't see a way of doing this using them.
 
The following rule would get the right number of symbols, but does not ignore the order
 
rule = !A & B & +C
 
Does anyone have a solution to this?
 
Peter
 
 
Dr Peter Myerscough-Jackopson
Engineer, MAC Ltd

phone: +44 (0) 23 8076 7808  fax: +44 (0) 23 8076 0602
email: peter.myerscough-jackopson <at> macltd.com  web: www.macltd.com

Multiple Access Communications Limited is a company registered in
England at Delta House, Southampton Science Park, Southampton,
SO16 7NS, United Kingdom with Company Number 1979185
 
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Picon

Re: Rules for parsing A B and C in any order

Hi Peter,

I don't think you need Spirit to do this... A simple character counting/sorting+counting solution would
suffice using STL strings and algorithms.

In which case, it might help if you sort the string first before passing it to a spirit parse which expected a
sorted string.

HTH!

"Sent via BlackBerry from Smart"
+63 928  5030979

-----Original Message-----
From: "Peter Myerscough-Jackopson" <peter.myerscough-jackopson <at> macltd.com>

Date: Mon, 4 Jun 2007 14:06:16 
To:<spirit-general <at> lists.sourceforge.net>
Subject: [Spirit-general] Rules for parsing A B and C in any order

Dear all, 
  
I'm writing a grammar and I am wondering if there is a way to parse a number of symbols/rules in any order. For
example I want to accept any strings with 0-1 A symbols, 1 B symbol, and 1 or more C symbols, but I don't mind
the order. e.g. ACCCBCCCCC or CCCCBA. 
  
I've looked at the standard operators, but I can't see a way of doing this using them. 
  
The following rule would get the right number of symbols, but does not ignore the order 
  
rule = !A & B & +C 
  
Does anyone have a solution to this? 
  
Peter 
  
 Dr Peter Myerscough-Jackopson 
Engineer, MAC Ltd 

phone: +44 (0) 23 8076 7808  fax: +44 (0) 23 8076 0602 
email: peter.myerscough-jackopson <at> macltd.com  web: www.macltd.com 

Multiple Access Communications Limited is a company registered in
England at Delta House, Southampton Science Park, Southampton,
SO16 7NS, United Kingdom with Company Number 1979185

 -------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Favicon

Re: Rules for parsing A B and C in any order (where A/B/C are rules)

Thanks for the help, I should have been more explicit,

In the example A, B and C are further rules in my spirit grammar, and not simple characters. 

So I'm still interested if anyone has a solution ?

Peter

Dr Peter Myerscough-Jackopson
Engineer, MAC Ltd

phone:+44 (0) 23 8076 7808 fax:+44 (0) 23 8076 0602
email:peter.myerscough-jackopson <at> macltd.com  web:www.macltd.com

Multiple Access Communications Limited is a company registered in
England at Delta House, Southampton Science Park, Southampton,
SO16 7NS, United Kingdom with Company Number 1979185

-----Original Message-----
From: spirit-general-bounces <at> lists.sourceforge.net
[mailto:spirit-general-bounces <at> lists.sourceforge.net] On Behalf Of Dean Michael Berris
Sent: 04 June 2007 15:16
To: Spirit General Mailing List
Subject: Re: [Spirit-general] Rules for parsing A B and C in any order

Hi Peter,

I don't think you need Spirit to do this... A simple character counting/sorting+counting solution would
suffice using STL strings and algorithms.

In which case, it might help if you sort the string first before passing it to a spirit parse which expected a
sorted string.

HTH!

"Sent via BlackBerry from Smart"
+63 928  5030979

-----Original Message-----
From: "Peter Myerscough-Jackopson" <peter.myerscough-jackopson <at> macltd.com>

Date: Mon, 4 Jun 2007 14:06:16
To:<spirit-general <at> lists.sourceforge.net>
Subject: [Spirit-general] Rules for parsing A B and C in any order

Dear all, 
  
I'm writing a grammar and I am wondering if there is a way to parse a number of symbols/rules in any order. For
example I want to accept any strings with 0-1 A symbols, 1 B symbol, and 1 or more C symbols, but I don't mind
the order. e.g. ACCCBCCCCC or CCCCBA. 
  
I've looked at the standard operators, but I can't see a way of doing this using them. 
  
The following rule would get the right number of symbols, but does not ignore the order 
  
rule = !A & B & +C 
  
Does anyone have a solution to this? 
  
Peter 
  
 Dr Peter Myerscough-Jackopson 
Engineer, MAC Ltd 

phone: +44 (0) 23 8076 7808  fax: +44 (0) 23 8076 0602 
email: peter.myerscough-jackopson <at> macltd.com  web: www.macltd.com 

Multiple Access Communications Limited is a company registered in
England at Delta House, Southampton Science Park, Southampton,
SO16 7NS, United Kingdom with Company Number 1979185

 -------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Daniel Lidström | 4 Jun 16:38
Picon
Favicon

Hhow to read fixed width data?

Hello!

I'm sorry if this is a FAQ. If it is I could not find it in the User's
Guide. Anyway, I want to parse
the following data:

66      1   24000001  -20000 289070  -15000 289210  -10000 289310   -5000
289300
66      1   24000002   -4822 289299       0 289260    1707 289246    5000
289220
66      1   24000003   10000 289190   15000 289190   20000 289130
66      4   24000001   -4822 289299   -3750 290013   -3000 290058   -3000
290058
66      4   24000002       0 289968      10 289968      10 289968     760
289878
66      4   24000003    1707 289246

This is fixed width and sometimes the data is not whitespace separated. The
problem lies in parsing
the third and fourth values. In this case they are together (24000001 is
actually the values 240000 01).
How can I be explicit about which columns contains a specific item? Here is
my grammar, which works
fine as long as the values are separated by white space:

namespace
{
   //!
   //! Grammar for REB format 66
   //!
   class REB66_grammar : public grammar<REB66_grammar>
   {
      vector<double>& out;
      int& layer, &section, &number;
      string& type;

   public:

      REB66_grammar(string& t, int& l, int& s, int& n, std::vector<double>&
v)
         : type(t), layer(l), section(s), number(n), out(v)
      { }

      template<class Scan>
      struct definition
      {
         definition(const REB66_grammar& self)
         {
            type
                = str_p("66")[assign_a(self.type)]
                ;
            layer
                = int_p[assign_a(self.layer)]
                ;
            section
                = int_p[assign_a(self.section)]
                ;
            number
                = int_p[assign_a(self.number)]
                ;
            pair_item
                = int_p[push_back_a(self.out)]
                ;
            pair
                = pair_item && pair_item
                ;
            required
                = type && layer && section && number
                ;
            optional
                = repeat_p(1, 4)[pair]
                ;
            line
                = required && optional
                ;
         }

         rule<Scan> type, layer, section, number, pair_item, pair, required,
optional, line;

         const rule<Scan>& start() const
         {
            return line;
         }
      };
   };
}

The parsing is done like this:

   while( getline(infile, line) )
   {
      int lyr, section, number;
      string type;
      std::vector<double> items;
      REB66_grammar grammar(type, lyr, section, number, items);
      if( parse(line.begin(), line.end(), grammar, blank_p).full )
      { ... }
   }

I would be very grateful for any help! Thanks in advance!

Hälsningar,
Daniel
SBG AB

Phone: +4687112090
Fax  : +4687112098
Location:
       59 14'10" N
       18 00'09" E

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Joel de Guzman | 4 Jun 20:52
Picon
Favicon

Re: Hhow to read fixed width data?

Daniel Lidström wrote:

> This is fixed width and sometimes the data is not whitespace separated. The
> problem lies in parsing
> the third and fourth values. In this case they are together (24000001 is
> actually the values 240000 01).
> How can I be explicit about which columns contains a specific item? Here is
> my grammar, which works
> fine as long as the values are separated by white space:

Check out the docs for the numeric parsers. You can specify
the exact width of an integer.

HTH.

Regards,
--

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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Joel de Guzman | 4 Jun 20:54
Picon
Favicon

Re: Rules for parsing A B and C in any order (where A/B/C are rules)

Peter Myerscough-Jackopson wrote:
> Thanks for the help, I should have been more explicit,
> 
> In the example A, B and C are further rules in my spirit grammar, and not simple characters. 
> 
> So I'm still interested if anyone has a solution ?

You want a permutation parser. Spirit2 has it. Unfortunately,
Spirit1 does not :(

Regards,
--

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

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
Carl Barron | 4 Jun 20:56
Picon

Re: Rules for parsing A B and C in any order


On Jun 4, 2007, at 9:06 AM, Peter Myerscough-Jackopson wrote:

> Dear all,
>  
> I'm writing a grammar and I am wondering if there is a way to parse a 
> number of symbols/rules in any order. For example I want to accept any 
> strings with 0-1 A symbols, 1 B symbol, and 1 or more C symbols, but I 
> don't mind the order. e.g. ACCCBCCCCC or CCCCBA.
>  
> I've looked at the standard operators, but I can't see a way of doing 
> this using them.
>  
> The following rule would get the right number of symbols, but does not 
> ignore the order
>  
> rule = !A & B & +C
>  
> Does anyone have a solution to this?
>

how about counting the # of times the rules match in the parser
and if the parse 'succeeds' compare the counts to what you want
and if they don't match your pars actually fails.

struct foo:grammar<foo>
{
	mutable int n_A,n_B,n_C;
	foo() :n_A(0),n_B(0),n_C(0){}
	template <class Scan>
	struct defintion
	{
		definition(const foo &s)
		{
			t =  A [++var(s.n_A)]
			   | B [++vars(s.n_B)]
			   | C[++vars(s.n_C)]
			  ;
			A = ...
			B= ...
			C= ...
		}
		rule<Scan> t,A,B,C;
		rule<Scan> const &start()const
		{ return t;}
	};
};

int main()
{
	foo g;
	//...
       if(parse(begin,end,g,skipper).hit && g.n_A == value_A && ....)
	{
		// parse found wanted data
	}
	else
	{
		// parse failed
	}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general

Gmane