jens weller | 1 Sep 16:05
Picon
Picon

Re: comment_p & confix_p in spirit2

Hartmut Kaiser wrote:
> Jens, 
> 
> 
>>Ok. Thought that this is implemented...
>>Then, those are basicly grammars or how could I create such rules?
>>I can't wait for someone implementing this later, I have a 
>>project to work on...
>>
>>Pseudocode:
>>template<Iterator>
>>struct comment_p_def : grammar_def<Iterator,<what is the 
>>correct (string)type?>(?,?="\n"(is there something for 
>>Lineending?)),space_type> {
>>  comment_p_def()
>>  {
>>    start = (lit(_r1) >> *(char_ - lit(_r1) - lit(_r2)) >> 
>>lit(_r2))[_val = _1 /* is this needed for storing? (afaik yes) */];
>>  }
>>  rule<same as in grammar_def<>> start;
>>}
>>
>>Well, really don't have a clue, how I would implement this in 
>>the correct way...
> 
>  
> The best is probably to look at the corresponding parsers in Spirit1. These
> should be self-explanatory.

I did look at the spirit1.x code for those parsers, and in general, I 
(Continue reading)

Hartmut Kaiser | 1 Sep 16:18
Picon
Gravatar

Re: comment_p & confix_p in spirit2

Jens, 

> >>Well, really don't have a clue, how I would implement this in the 
> >>correct way...
> > 
> >  
> > The best is probably to look at the corresponding parsers 
> in Spirit1. 
> > These should be self-explanatory.
> 
> I did look at the spirit1.x code for those parsers, and in 
> general, I would be able to create a parser or another 
> solution that will work for me, since I can't wait until it 
> is implemented. But also I'd like to know, how this could be 
> implemented in a generic way for spirit2.
> 
> The 1.x code for the confix_parser:
> 
[snip]
> 
> If I try to implement this as a grammar, it would be 
> different I guess.
> Also I don't know if ScannerT & Co still exist in Spiri2.x.

I don't think you looked at the right place. The code in question is in
spirit/utility/impl/confix.ipp:

    nested_confix =
            open
        >>  (nested_confix | (expr - close))
(Continue reading)

jens weller | 1 Sep 16:52
Picon
Picon

Re: comment_p & confix_p in spirit2

[snip snap]
> 
> I don't think you looked at the right place. The code in question is in
> spirit/utility/impl/confix.ipp:
> 
>     nested_confix =
>             open
>         >>  (nested_confix | (expr - close))
>         >>  close
> 
> For the nested (comment) case and:
> 
>     non_nested_confix = 
>             open
>         >>  (expr - close)
>         >>  close
> 
> for the non-nested case. As you can see it's straightforward Spirit code.
> There are two more parsers for the confix_p primitive, these are doing some
> refactoring of the expr parser. However, our experience showed that these
> tend to add more confusion than they solve problems. I'ld stick with the two
> simple cases provided.

Hartmut, I know how the basic rules for such a thing look like.
My concern is more, how can I implement a confix_p/comment_p in a global 
way in spirit. So how should this be implemented in spirit2.x?
As a grammar? I would like to use it just as in spirit1.x:
quote = confix_p("\"",*(char_-"\""|'\\' >> char_),"\"");
And therefore, I think I looked at the right place, since in this file 
is also confix_p and comment_p defined.
(Continue reading)

Hartmut Kaiser | 1 Sep 17:56
Picon
Gravatar

Re: comment_p & confix_p in spirit2

Jens, 

> > I don't think you looked at the right place. The code in 
> question is 
> > in
> > spirit/utility/impl/confix.ipp:
> > 
> >     nested_confix =
> >             open
> >         >>  (nested_confix | (expr - close))
> >         >>  close
> > 
> > For the nested (comment) case and:
> > 
> >     non_nested_confix = 
> >             open
> >         >>  (expr - close)
> >         >>  close
> > 
> > for the non-nested case. As you can see it's 
> straightforward Spirit code.
> > There are two more parsers for the confix_p primitive, 
> these are doing 
> > some refactoring of the expr parser. However, our experience showed 
> > that these tend to add more confusion than they solve 
> problems. I'ld 
> > stick with the two simple cases provided.
> 
> Hartmut, I know how the basic rules for such a thing look like.
> My concern is more, how can I implement a confix_p/comment_p 
(Continue reading)

jens weller | 1 Sep 20:01
Picon
Picon

Re: comment_p & confix_p in spirit2

Hartmut Kaiser wrote:
>>Hartmut, I know how the basic rules for such a thing look like.
>>My concern is more, how can I implement a confix_p/comment_p 
>>in a global way in spirit. So how should this be implemented 
>>in spirit2.x?
>>As a grammar? I would like to use it just as in spirit1.x:
>>quote = confix_p("\"",*(char_-"\""|'\\' >> char_),"\""); And 
>>therefore, I think I looked at the right place, since in this 
>>file is also confix_p and comment_p defined.
>>
>>Also some of the basic spirit1.x typerules are now differnt, f.e. 
>>implementing the comment //:
>>cpp_comment = "//" >> *(char - eol_p);// is this now eol 
>>simply? As by alnum_p is now alnum?
> 
> 
> Sorry, I didn't intend to offend you. From looking at your examples I think
> you don't need the refactoring, which simplifies things. 

It takes more to offend me ;)

> I never tried to pass parser objects as parameters to another parser (which
> is what you want to do if you implement it as a generic confix grammar).
> You'll have to try. 
> 
> OTOH it might be a good idea to implement the confix as a primitive in
> Spirit2, which is a bit more involved. For this you need to get accustomed
> with the Spirit2 internals, though.

Well, tell me the details and secrets of Spirit2 ;)
(Continue reading)

Hartmut Kaiser | 1 Sep 20:23
Picon
Gravatar

Re: comment_p & confix_p in spirit2

Jens, 

> > Sorry, I didn't intend to offend you. From looking at your 
> examples I 
> > think you don't need the refactoring, which simplifies things.
> 
> It takes more to offend me ;)

:-P

> > OTOH it might be a good idea to implement the confix as a 
> primitive in 
> > Spirit2, which is a bit more involved. For this you need to get 
> > accustomed with the Spirit2 internals, though.
> 
> Well, tell me the details and secrets of Spirit2 ;) BTW. how 
> far are the Docs? *g*

Ha!

But, if your interested there is always the possibility to look at the code
:-P 
We don't hide anything, it's all there, just plain C++.

> > which you can use in your grammar as
> > 
> >     ... >> confix("\"", *(char_-"\""|'\\' >> char_), "\"")[...] 
> >         >> ...
> > 
> Looks promising. Will try this out by tomorrow.
(Continue reading)

Joel de Guzman | 2 Sep 01:55
Picon
Favicon

Re: Spirit 1.8.5 and 1.6.4 released

Nicola Musatti wrote:
> It is my pleasure to announce the release of Spirit 1.8.5 and 1.6.4 .
> 
[...]

Woohoo! Great :-) Thank you Nicola. You're DA MAN. I'll update the
website now.

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/
Jens Weller | 3 Sep 11:19
Picon
Picon

Re: comment_p & confix_p in spirit2

> > > Sorry, I didn't intend to offend you. From looking at your 
> > examples I 
> > > think you don't need the refactoring, which simplifies things.
> > 
> > It takes more to offend me ;)
> 
> :-P
Wer zu letzt lacht ;)

> > > OTOH it might be a good idea to implement the confix as a 
> > primitive in 
> > > Spirit2, which is a bit more involved. For this you need to get 
> > > accustomed with the Spirit2 internals, though.

But whats better now, primitive or functor_parser?
Would be a primitive better in performing at runtime?

> But, if your interested there is always the possibility to look at the
> code
> :-P 
> We don't hide anything, it's all there, just plain C++.

I always was a fan of reading tons of unknown code in several unknown files ;P

> > > which you can use in your grammar as
> > > 
> > >     ... >> confix("\"", *(char_-"\""|'\\' >> char_), "\"")[...] 
> > >         >> ...
> > > 
> > Looks promising. Will try this out by tomorrow.
(Continue reading)

Jens Weller | 3 Sep 12:01
Picon
Picon

Re: comment_p & confix_p in spirit2

Forgot to save the file before sending, so here is the "new" version...

> > > Sorry, I didn't intend to offend you. From looking at your 
> > examples I 
> > > think you don't need the refactoring, which simplifies things.
> > 
> > It takes more to offend me ;)
> 
> :-P
Wer zu letzt lacht ;)

> > > OTOH it might be a good idea to implement the confix as a 
> > primitive in 
> > > Spirit2, which is a bit more involved. For this you need to get 
> > > accustomed with the Spirit2 internals, though.

But whats better now, primitive or functor_parser?
Would be a primitive better in performing at runtime?

> But, if your interested there is always the possibility to look at the
> code
> :-P 
> We don't hide anything, it's all there, just plain C++.

I always was a fan of reading tons of unknown code in several unknown files ;P

> > > which you can use in your grammar as
> > > 
> > >     ... >> confix("\"", *(char_-"\""|'\\' >> char_), "\"")[...] 
> > >         >> ...
(Continue reading)

Jens Weller | 3 Sep 11:08
Picon
Picon

Re: comment_p & confix_p in spirit2

> > > Sorry, I didn't intend to offend you. From looking at your 
> > examples I 
> > > think you don't need the refactoring, which simplifies things.
> > 
> > It takes more to offend me ;)
> 
> :-P
Wer zu letzt lacht ;)

> > > OTOH it might be a good idea to implement the confix as a 
> > primitive in 
> > > Spirit2, which is a bit more involved. For this you need to get 
> > > accustomed with the Spirit2 internals, though.

But whats better now, primitive or functor_parser?
Would be a primitive better in performing at runtime?

> But, if your interested there is always the possibility to look at the
> code
> :-P 
> We don't hide anything, it's all there, just plain C++.

I always was a fan of reading tons of unknown code in several unknown files ;P

> > > which you can use in your grammar as
> > > 
> > >     ... >> confix("\"", *(char_-"\""|'\\' >> char_), "\"")[...] 
> > >         >> ...
> > > 
> > Looks promising. Will try this out by tomorrow.
(Continue reading)


Gmane