Niko Demmel | 1 Mar 17:16
Picon
Picon

Re: Embedded objects

Now I see what you are trying to do.

I don't think you can acheive this with the recursive call to readTest 
in your functor. What this does is parse the allready parsed sub-map again.

You could use closures to handle the recursive occurances of 
mapEntryExpr. ( http://www.boost.org/libs/spirit/doc/closures.html )

The closure for your mapEntryExpr would have a member of type Map and 
the colsure for your assignExpr would have a member of type string 
(current the key). This way new assign expressions can be added to the 
correct map and the values to the current keys without those references 
in your functor.

If what I said is unclear I can elaborate. (I'm certainly no spirit 
expert though)

Also something compilable would help further explanation.

Regards,
Niko

On 28/02/2008 08:26, Steffen Roeber wrote:
>
> Unfortunately, createSubMap is a functor that needs the parsed submap.
>
> Maybe my original code could give a better understanding of what I'm 
> doing.
>
> Maybe it is to simple.
(Continue reading)

Steffen Roeber | 3 Mar 16:34
Picon
Favicon

Re: Embedded objects

I thing I don't get the things working together. See attachment. I don’t
understand how to insert new objects into the map.

Hella Aglaia Mobile Vision GmbH
Dipl. Ing. Steffen Roeber
Software Tools
Treskowstraße 14, 13089 Berlin, 
Handelsregister Amtsgericht Charlottenburg HRB 66976
Geschäftsführer: Thomas Schilling
Tel: +49 30 2000 429 – 412
Fax: +49 30 2000 429 – 109
Mail: steffen.roeber <at> aglaia-gmbh.de
URL: www.aglaia-gmbh.de
URL: www.mobilevision.de
-----Ursprüngliche Nachricht-----
Von: spirit-general-bounces <at> lists.sourceforge.net
[mailto:spirit-general-bounces <at> lists.sourceforge.net] Im Auftrag von Niko
Demmel
Gesendet: Samstag, 1. März 2008 17:17
An: Spirit General Mailing List
Betreff: Re: [Spirit-general] Embedded objects

Now I see what you are trying to do.

I don't think you can acheive this with the recursive call to readTest 
in your functor. What this does is parse the allready parsed sub-map again.

You could use closures to handle the recursive occurances of 
mapEntryExpr. ( http://www.boost.org/libs/spirit/doc/closures.html )

(Continue reading)

Nikolaus Demmel | 5 Mar 12:06
Picon
Picon

Accessing second closure member in semantic actions

Hello list,

in semantic actions for a rule that hast 1 closure member I can access 
that with "arg1". How do I do the same for a second closure member. I 
expected "arg2" to just work but this is always type "nil_t". I didnt 
find anything in the docs about it.

Regards,
Niko Demmel

-------------------------------------------------------------------------
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 | 6 Mar 03:38

Re: Accessing second closure member in semantic actions


On Mar 5, 2008, at 6:06 AM, Nikolaus Demmel wrote:

> Hello list,
>
> in semantic actions for a rule that hast 1 closure member I can access
> that with "arg1". How do I do the same for a second closure member. I
> expected "arg2" to just work but this is always type "nil_t". I didnt
> find anything in the docs about it.
>
> Regards,
> Niko Demmel
>
> ----------------------------------------------------------------------- 
> --
> 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
>
>
    Since you mention arg1 I assume you want more than one return
value from a closure.  Only the first variable of a closure is returned.
So create a pair, or tuple of the desired return values and return that.
Or if the rule using the results is the only rule calling the given  
rule and it
its not very recursunve, perhaps you can store directly in the closure  
(Continue reading)

Matt Flanzer | 7 Mar 03:22
Picon

basic boolean logic parser with closures

If someone could help me figure this out, I would be most grateful:

I'm trying to implement a basic boolean grammar parser, using closures 
and binary ftors. It seems like it should be simple, but I can't get it 
to work. Here's the essence of the code:

// the closures
  struct cond_closure : boost::spirit::closure<cond_closure, bool>
  {
    member1 cond;
  } conditional;

  struct boolop_closure : boost::spirit::closure<boolop_closure, 
binary_function<bool,bool,bool> >
  {
    member1 op;
  } bool_op;

...

// the grammar (excerpt):

      conditional
        = str_p("true")[conditional.cond = true]
        | str_p("false")[conditional.cond = false]
        |
          (
             conditional[conditional.cond = arg1]
          >> bool_op
          >> conditional[conditional.cond = 
(Continue reading)

Andreas Bruckmeier | 7 Mar 04:13

Segmentation fault when parsing grammar with threads

Hi out there,

after searching for the cause of segmentation faults in my program i figured
out that it happens while parsing my grammar with spirit.
But this happens only if i run multiple threads, with only one thread all
works as expected.

I used the current boost trunk, gcc 4.1.2 and option D_REENTRANT

Does anybody have a clue what happens inside parse(...) that could cause
this segfault?

Best regards
Andi

calling code: ('buf' is a zero-terminated string)
--------------------------------------------------------
HttpRequestGrammar parser;
parse_info<const char*> parserInfo = parse(buf, parser);

my grammar: (cutted some rules to limit length ;-))
--------------------------------------------------------
#ifndef BASIC_HTTP_GRAMMAR_H_
#define BASIC_HTTP_GRAMMAR_H_

#include <boost/spirit/core.hpp>
#include <boost/spirit/actor/assign_actor.hpp>
#include <boost/spirit/actor/insert_at_actor.hpp>

using namespace boost::spirit;
(Continue reading)

Wori Lone | 7 Mar 17:20
Picon
Favicon

Grammar

Having the following input string, how could I write a grammar and both expressions be valid (synonyms)? 
The second expression should be a short cut for the first expression.

//Expression 1
A from KEYOBJ and B from KEYOBJ or C from KEYOBJ

//Expression 2
A and B or C from KEYOBJ



Thanks for any suggestion

W

Never miss a thing. Make Yahoo your homepage.
-------------------------------------------------------------------------
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
jens weller | 7 Mar 18:08
Picon
Picon

Re: Grammar

Make KEYOBJ optional, but then you've got the problem, that you don't 
know where to bind it too, if it stands in such a hirarchy.

(A and B or C) from KEYOBJ

^but with braces you could solve that problem also then.

so in spirit-rules:

identifier >> -("from" >> keyobj_rule);

rules for and, or to follow.
then bracing, to map those structures to a parse tree f.e.

regards

Jens Weller

Wori Lone wrote:
> Having the following input string, how could I write a grammar and both 
> expressions be valid (synonyms)? 
> The second expression should be a short cut for the first expression.
> 
> //Expression 1
> A from KEYOBJ and B from KEYOBJ or C from KEYOBJ
> 
> //Expression 2
> A and B or C from KEYOBJ
> 
> 
> 
> Thanks for any suggestion
> 
> W
> 
> ------------------------------------------------------------------------
> Never miss a thing. Make Yahoo your homepage. 
> <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> 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

-------------------------------------------------------------------------
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/
Picon
Gravatar

Struggling with understanding of local variables in grammar

I am frustrated with my lack of understanding the spririt documentation.
This is a cry for help.

I am parsing very simple strings: Number Color, Number Color... Example
is 1 White, 3 Black etc.
I need to put the result in a vector for later processing, so I have a
placeholder for the results
Class myclass
{
Public:
	int ColorIndex;
	int ColorNumber;

	myclass (int iIndex, int iNumber) {..}
	myclass (const myclass& another){...}
	
}

Following grammar and actions work. In this working example I construct
myclass instance on the stack and 
In each parsing step assign parsing result to a member of a class. Very
unattractive, but it works.

definition (mygrammar const& self)  
{ 
	myclass test;
	r = as_lower_d 
		[
		*
		(
			limit_d(1u, 4u)[uint1_p]
[assign_p(test.ColorIndex)] 
			>> +(ch_p(' ')) 
			>> colors_p [assign_p(iColorNumber)]
			>> eps_p[push_back_a(self.m_v, test))]
		)
		];
}

Of course, much nicer is to stuff results in some intermediate variables
and then, upon
Successful completion of the parsing process, to create an instance of a
placeholder and put it into the container
Following is the grammar that does not work. 
definition (mygrammar const& self)  
{ 
	int iColorIndex  = -1;
	int iColorNumber = -1;
	r = as_lower_d 
		[
		*
		(
			limit_d(1u, 4u)[uint1_p] [assign_p(iColorIndex)]

			>> +(ch_p(' ')) 
			>> colors_p [assign_p(iColorNumber)]
			>> eps_p[push_back_a(self.m_v,
myclass(iColorIndex, iColorNumber))]
		)
		];
}
That above example does not work. iColorIndex and iColorNumber are
always "-1".

Why first example works and second does not?

-------------------------------------------------------------------------
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/
Olaf Peter | 8 Mar 20:18
Picon
Picon

dubious compile error (bug?)

Hi,

the following code doesn't compile as expected. The compiler error 
message points to an irrelevant source line. Rewritten the rule works - 
in my opinion both variants should work. Is this a bug? or my fault.

Thanks,
Olaf
Attachment (keyword_sep.cpp): text/x-c++src, 3243 bytes
-------------------------------------------------------------------------
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