Benjamin Menküc | 7 Feb 00:22
Picon

multi actor

Hi,

is it possible to have a multi actor somehow.

I want to do stuff like

var1=10, var2=20

(someRule[assign_a(var1,10)])[assign_a(var2,20)]

doesnt work unfortunately.

regards,
Ben

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Benjamin Menküc | 7 Feb 00:26
Picon

multi actor

Hi,

I want to do the following at the same time: var1=10 and var2=20

(someRule[assign_a(var1,10)])[assign_a(var2,20)] doesn't work 
unfortunately. Is there a trick to do it?

regards,
Ben

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
CARL BARRON | 7 Feb 02:56

Re: multi actor


On Feb 6, 2008, at 6:26 PM, Benjamin Menküc wrote:

> Hi,
>
> I want to do the following at the same time: var1=10 and var2=20
>
> (someRule[assign_a(var1,10)])[assign_a(var2,20)] doesn't work
> unfortunately. Is there a trick to do it?
>
  Need more info since this works:
#include <boost/spirit/core.hpp>
#include <boost/spirit/actor.hpp>
#include <iostream>

using namespace boost::spirit;

int main()
{
	int i,j;
	
	rule<> r = (ch_p('a')[assign_a(i,10)])[assign_a(j,20)];
	const char test[] ="a";
	if(parse(test,r).full)
	{
		std::cout << i << ',' << j << '\n';
	}
	else
	{
		std::cout << "parse failed\n";
(Continue reading)

Benjamin Menküc | 7 Feb 18:24
Picon

Re: multi actor

Thanks, it was my fault somewhere else, it works now here to.

CARL BARRON schrieb:
> On Feb 6, 2008, at 6:26 PM, Benjamin Menküc wrote:
>
>   
>> Hi,
>>
>> I want to do the following at the same time: var1=10 and var2=20
>>
>> (someRule[assign_a(var1,10)])[assign_a(var2,20)] doesn't work
>> unfortunately. Is there a trick to do it?
>>
>>     
>   Need more info since this works:
> #include <boost/spirit/core.hpp>
> #include <boost/spirit/actor.hpp>
> #include <iostream>
>
> using namespace boost::spirit;
>
> int main()
> {
> 	int i,j;
> 	
> 	rule<> r = (ch_p('a')[assign_a(i,10)])[assign_a(j,20)];
> 	const char test[] ="a";
> 	if(parse(test,r).full)
> 	{
> 		std::cout << i << ',' << j << '\n';
(Continue reading)

Benjamin Menküc | 7 Feb 18:27
Picon

int_parser<int,16,1,-1> doesn't convert to int

Hi,

when I try

    int value
    ...
    int_parser<int,16,1,-1>[value]
    ...

I get the following error:
error C2440: 'initializing' : cannot convert from 
'boost::spirit::ref_value_actor<T,ActionT>' to 'unsigned int'

I also tried uint_parser<signed,16,1,-1>, can anybody help?

regards,
Ben

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Benjamin Menküc | 7 Feb 18:29
Picon

Re: int_parser<int, 16, 1, -1> doesn't convert to int

sorry, I mean int_parser<int,16,1,-1>[assign_a(value)]
> Hi,
>
> when I try
>
>     int value
>     ...
>     int_parser<int,16,1,-1>[value]
>     ...
>
> I get the following error:
> error C2440: 'initializing' : cannot convert from 
> 'boost::spirit::ref_value_actor<T,ActionT>' to 'unsigned int'
>
> I also tried uint_parser<signed,16,1,-1>, can anybody help?
>
> regards,
> Ben
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Spirit-general mailing list
> Spirit-general <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/spirit-general
>
>   

(Continue reading)

CARL BARRON | 8 Feb 03:20

Re: int_parser<int, 16, 1, -1> doesn't convert to int


On Feb 7, 2008, at 12:29 PM, Benjamin Menküc wrote:

> sorry, I mean int_parser<int,16,1,-1>[assign_a(value)]
>> Hi,
>>
>> when I try
>>
>>     int value
>>     ...
>>     int_parser<int,16,1,-1>[value]
>>     ...
>>

int_parser is a templated class not an instance of a parser.
template <...> struct int_parser:parser<...> {/**/};

you need an instance of this to attach an action

int_parser<int,16,1,-1>	my_int;
int var ;

parse(input,my_int[assign_a(var)]);

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Wori Lone | 8 Feb 12:31
Picon
Favicon

Using closure

Hi everybody!

I’m using closure for the following rule

expression=
       (as_lower_d["field"]
>> limit_d(0u, 31u)[uint2_p][ expression.field = arg1]
    >> as_lower_d["from"]
    >> lexeme_d    [( +upper_p ) [expression.key_name = arg1] ]
    )[ expression.val = do_evaluation(expression.field, expression. key_name)]
    ;

uint_parser<unsigned, 10, 1, 2> uint2_p;
typedef rule<ScannerT, my_closure::context_t> rule_t;
rule_t expression;


struct my_closure : boost::spirit::closure<my_closure, bool, int, string>
{
      member1 val;
    member2 field;
    member3 key_name;
};



struct do_evaluation_
{
    template <typename X, typename Y>
    struct result { typedef bool type; };

     template <typename A, typename B>
    bool operator()(A field_, B key_) const
    {    
        //test
        cout << "field = " << field_<< endl;
        cout << "key = " << key_ << endl;    
        
return true;
}    
};
function<do_evaluation_> do_evaluation;



If I typed an expression like

                             field 20 from AAA and field 10 from CCC

I expected to get the keys „AAA“ and CCC into the key_name member, but the printed out results are

field =20
key_name = AAA and field 10 from CCC
field =10
key_name = CCC

How could I get the keys (“AAA” and “CCC”) using closure?
Thanks for any suggestions.

Sincerely,
Wo

Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
Larry W | 9 Feb 00:51

position_iterator problem

Hi,

it seems there is a problem with the position_iterator. I'm compiling on unix and when I parse a windows file (having a CRLF line break)  the reported line numbers are incorrect. Would it make sense to change the implementation to handle all different line breaks (unix, windows, mac)?

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general
CARL BARRON | 9 Feb 03:18

Re: position_iterator problem


On Feb 8, 2008, at 6:51 PM, Larry W wrote:

> Hi,
>
> it seems there is a problem with the position_iterator. I'm compiling 
> on unix and when I parse a windows file (having a CRLF line break)  
> the reported line numbers are incorrect. Would it make sense to change 
> the implementation to handle all different line breaks (unix, windows, 
> mac)?
>

  Not really:)   How do you expect to determine the source os of the 
file? In general its
is not easily solvable without a statistically guessing after reading 
entire file!!

The place to translate endlines of foreign files is in a filtering 
streambuffer class.
It is not difficult to write this class once and use it whenever you 
read a windows text file
assuming it is a windows text file in a unix program.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Spirit-general mailing list
Spirit-general <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spirit-general

Gmane