Rainer Huebner | 1 Aug 04:22
Picon
Favicon

on vacation.


I will be out of the office starting  01.08.2007 and will not return until
12.08.2007.

I will respond to your message when I return.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
CARL BARRON | 1 Aug 05:36

Re: lexeme_d converse?


On Jul 31, 2007, at 9:28 AM, Jeff Flinn wrote:

> Below is an exemplary snippet of what I'm trying to accomplish. I'd 
> like
> to skip "-" and "--" anywhere in the string. I'm stumped on how to
> accomplish this using spirit symbols. Would I need to write a filtering
> input iterator? Or would I need to add all combinations "AAA", "A-AA",
> "A--AA", "AA-", ... to the symbol table? This could become unruly.
>
> All ideas appreciated, Jeff
>
> ==============================
> #include <boost/spirit.hpp>
> #include <vector>
> #include <string>
>
> int main()
> {
>      symbols<std::string> sym;
> 	
>      sym.add("AAA","xxx") ("BBB","yyy") ("CCC","zzz") ("---","   ");
>
>      lTxt = "AAA-B-BB---CC--C";
>
>      std::vector<std::string> out; // "xxx", "yyy", "---", "zzz"
>
>      parse_info<> lOk1 = parse( lTxt.c_str()
>                               , *sym[push_back_a(out)] >> !end_p
>                               , (str_p("--")>>~eps_p('-'))
(Continue reading)

Atry | 1 Aug 08:19
Picon

Does rule<>::copy work?

In boost 1.34.1, there is the rule<>::copy method, but invoking it raised a compiler error. I saw the test/rule_tests.cpp, rule<>::copy is never called in test case, but doc/rule.html said: "If you need to copy a rule you have to explicitly call its member function copy()", I am confused whether there is that method. Anyhow, is there a API document generated from doxygen?

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Joel de Guzman | 1 Aug 09:52
Picon
Favicon

Re: Does rule<>::copy work?

Atry wrote:
> In boost 1.34.1, there is the rule<>::copy method, but invoking it 
> raised a compiler error. I saw the test/rule_tests.cpp, rule<>::copy is 
> never called in test case, but doc/rule.html said: "If you need to copy 
> a rule you have to explicitly call its member function copy()", I am 
> confused whether there is that method. 

Do you have a minimal test case we can try?

> Anyhow, is there a API document 
> generated from doxygen?

Sorry, no.

Regards,
--

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
Jeff Flinn | 1 Aug 14:36
Picon

Re: lexeme_d converse?

CARL BARRON wrote:
> On Jul 31, 2007, at 9:28 AM, Jeff Flinn wrote:
> 
>> Below is an exemplary snippet of what I'm trying to accomplish. I'd 
>> like
>> to skip "-" and "--" anywhere in the string. I'm stumped on how to
>> accomplish this using spirit symbols. Would I need to write a filtering
>> input iterator? Or would I need to add all combinations "AAA", "A-AA",
>> "A--AA", "AA-", ... to the symbol table? This could become unruly.
>>
>> All ideas appreciated, Jeff

...

>    you can use a skipper to skip one or two -'s.
> 	parse_info<> lOk1 = parse( lTxt.c_str
>                                , *sym[push_back_a(out)] >> !end_p
>                            ,ch_p('-') >> !ch_p('-')
> 			);

This results in:

    lOk1 = {stop=0x00357714 "B-BB---CC--C" hit=true full=false...}

"B-BB" is not matched by sym. This also would prevent "---" from 
matching sym as well. Hence the title "Lexeme_d converse". I need the 
single and double dashes to be skipped by the skipper, but triples to be 
passed through to the symbol parser as a completed entity.

Here is the fully compilable code that distills my issue, correcting a 
few ommisions/errors in the previous posting.

#include <boost/spirit.hpp>
#include <vector>
#include <string>

using namespace boost::spirit;

int main()
{
      symbols<std::string> sym;
	
      sym.add("AAA","xxx") ("BBB","yyy") ("CCC","zzz") ("---","   ");

      std::string lTxt = "AAA-B-BB---CC--C";

      std::vector<std::string> out; // "xxx", "yyy", "---", "zzz"

      parse_info<> lOk1 = parse( lTxt.c_str()
                               , *sym[push_back_a(out)] >> !end_p
                               ,ch_p('-') >> !ch_p('-')
                               //, (str_p("--")>>~eps_p('-'))
                               //| (str_p("-") >>~eps_p('-'))
                               );

      //lOk1= {stop=0x00357714 "B-BB---CC--C" hit=true full=false...}

      return 0;
}

Thanks, Jeff

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
Jeff Flinn | 1 Aug 14:42
Picon

Re: lexeme_d converse?

Another correction inline.

Jeff Flinn wrote:
> CARL BARRON wrote:
>> On Jul 31, 2007, at 9:28 AM, Jeff Flinn wrote:
>>
>>> Below is an exemplary snippet of what I'm trying to accomplish. I'd 
>>> like
>>> to skip "-" and "--" anywhere in the string. I'm stumped on how to
>>> accomplish this using spirit symbols. Would I need to write a filtering
>>> input iterator? Or would I need to add all combinations "AAA", "A-AA",
>>> "A--AA", "AA-", ... to the symbol table? This could become unruly.
>>>
>>> All ideas appreciated, Jeff
> 
> ...
> 
>>    you can use a skipper to skip one or two -'s.
>> 	parse_info<> lOk1 = parse( lTxt.c_str
>>                                , *sym[push_back_a(out)] >> !end_p
>>                            ,ch_p('-') >> !ch_p('-')
>> 			);
> 
> This results in:
> 
>     lOk1 = {stop=0x00357714 "B-BB---CC--C" hit=true full=false...}
> 
> "B-BB" is not matched by sym. This also would prevent "---" from 
> matching sym as well. Hence the title "Lexeme_d converse". I need the 
> single and double dashes to be skipped by the skipper, but triples to be 
> passed through to the symbol parser as a completed entity.
> 
> Here is the fully compilable code that distills my issue, correcting a 
> few ommisions/errors in the previous posting.
> 
> #include <boost/spirit.hpp>
> #include <vector>
> #include <string>
> 
> using namespace boost::spirit;
> 
> int main()
> {
>       symbols<std::string> sym;
> 	
>       sym.add("AAA","xxx") ("BBB","yyy") ("CCC","zzz") ("---","   ");
> 
>       std::string lTxt = "AAA-B-BB---CC--C";
> 
>       std::vector<std::string> out; // "xxx", "yyy", "---", "zzz"

and the desired output should be:

 >       std::vector<std::string> out; // "xxx", "yyy", "   ", "zzz"

> 
>       parse_info<> lOk1 = parse( lTxt.c_str()
>                                , *sym[push_back_a(out)] >> !end_p
>                                ,ch_p('-') >> !ch_p('-')
>                                //, (str_p("--")>>~eps_p('-'))
>                                //| (str_p("-") >>~eps_p('-'))
>                                );
> 
>       //lOk1= {stop=0x00357714 "B-BB---CC--C" hit=true full=false...}
> 
>       return 0;
> }
> 
> Thanks, Jeff
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
Atry | 1 Aug 21:11
Picon

Re: Does rule<>::copy work?

Joel de Guzman wrote:
> Atry wrote:
>   
>> In boost 1.34.1, there is the rule<>::copy method, but invoking it 
>> raised a compiler error. I saw the test/rule_tests.cpp, rule<>::copy is 
>> never called in test case, but doc/rule.html said: "If you need to copy 
>> a rule you have to explicitly call its member function copy()", I am 
>> confused whether there is that method. 
>>     
>
> Do you have a minimal test case we can try?
>
>   
rule<> r = anychar_p;
r.copy(); // error
>> Anyhow, is there a API document 
>> generated from doxygen?
>>     
>
> Sorry, no.
>
> Regards,
>   

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
Joel de Guzman | 2 Aug 02:28
Picon
Favicon

Re: Does rule<>::copy work?

Atry wrote:
> Joel de Guzman wrote:
>> Atry wrote:
>>   
>>> In boost 1.34.1, there is the rule<>::copy method, but invoking it 
>>> raised a compiler error. I saw the test/rule_tests.cpp, rule<>::copy is 
>>> never called in test case, but doc/rule.html said: "If you need to copy 
>>> a rule you have to explicitly call its member function copy()", I am 
>>> confused whether there is that method. 
>>>     
>> Do you have a minimal test case we can try?
>>
>>   
> rule<> r = anychar_p;
> r.copy(); // error

Ooops. Sorry. That was a dumb request from me :P
Ok, fixed in SVN. I'm attaching the fixed rule.hpp here.

Regards,
--

-- 
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net
Attachment (rule.hpp): text/x-c++hdr, 5767 bytes
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
CARL BARRON | 2 Aug 10:23

Re: lexeme_d converse?


On Aug 1, 2007, at 8:36 AM, Jeff Flinn wrote:

>
> This results in:
>
>     lOk1 = {stop=0x00357714 "B-BB---CC--C" hit=true full=false...}
>
> "B-BB" is not matched by sym. This also would prevent "---" from
> matching sym as well. Hence the title "Lexeme_d converse". I need the
> single and double dashes to be skipped by the skipper, but triples to 
> be
> passed through to the symbol parser as a completed entity.
>
>
    It is probably easier to preprocess the data to remove single or 
double
-'s but not triples. Such as

#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <iostream>

#include <boost/spirit/core.hpp>
#include <boost/spirit/symbols.hpp>
#include <boost/spirit/actor.hpp>

void remove_one_or_two_minus(std::string &str);

using namespace boost::spirit;

int main()
{
	symbols<std::string> sym;
	sym.add("AAA","xxx")("BBB","yyy")("CCC","zzz")("---","   ");
	std::string in = "AAA-B-BB---CC--C";
	remove_one_or_two_minus(in);
	
	std::vector<std::string> out;
	if(parse(in.begin(),in.end(),
		*sym[push_back_a(out)]
		
		).full)
	{
		std::cout << "Parse produces:\n";
		std::copy(out.begin(),out.end(),
			std::ostream_iterator<std::string>(std::cout,"\n"));
	}
	else
	{
		std::cout << "parse failed\n";
	}
}

void remove_one_or_two_minus(std::string &str)
{
	std::string::iterator begin(str.begin());
	std::string::iterator end(str.end());
	std::string::iterator out(str.begin());
	while(begin != end)
	{
		if(*begin != '-')
		{
			*out = *begin;
			++begin;
			++out;
			continue;
		}
		++begin;
		if(begin != end && *begin != '-')
		{
			// only one
			continue; // begin already incr'd.
		}
		++begin;
		if(begin != end && *begin != '-')
		{
			// only 2
			continue;
		}
		// there were three '-'s begin already incr'd.
		// insert three -'s.
		*out = '-';++out;
		*out = '-';++out;
		*out = '-';++out;
	}
	str.erase(out,end);
}

one should be able to write a functor parser to do this as a skipper, 
but my attempts
led to infinite loops, so if you always want this skip then you can 
always do the skipping
in 'normal' C++ before passing the input to spirit.  It should be 
doable with a skipper, but
this solution is likely to be faster than using a skipper.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
Anatoli Sakhnik | 2 Aug 13:25
Picon

How to track the input consumption?

Hi, spiriters!

Can anyone advise me how could I track the count of bytes consumed by
a parser by means of the Phoenix library? The following piece of code
doesn't compile:

//////////////////////////////////////////////////////
// Decrease len by the count of consumed input bytes.

#include <iostream>
#include <boost/spirit.hpp>

using namespace std;
using namespace boost::spirit;
using namespace phoenix;

int main()
{
    char p[] = "Hello, world!";
    int len(strlen(p));
    parse(
        p + 0, p + len,
        (
            str_p("Hello") [var(len) -= static_cast_≤int>(arg2 - arg1)]
            // Neither works another: [var(len) -= (arg2 - arg1)]
        >>  *anychar_p
        )
        );
    // I supposed the len to be 13 - 5 -> 8.
    cout << len << endl;
    return 0;
}

The spirit version is 0x1803, gcc-4.1.2, Fedora 7.

Thanks in advance.

-- Anatoli Sakhnik.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

Gmane