Xavier Pegenaute | 1 Oct 18:30

Re: Fill classes


> I really don't have lots of time to look into code right now. As
> always, if you can simplify the code to the exact problem; no more,
> there'll be a bigger chance for me to look into the code ASAP.
Ok, it was so simple, but anyway forget it, I am going to simplify my
case.
> Anything more than a few lines tend to get pushed down the "do later"
> list. So, essentially, I need to know what it is you are trying to
> achieve. The best strategy so far is to look at the examples
> available and see if any of those are good starter candidates for
> what you want to achieve. Then, we can work on that. How does that
> sound?

Fine. Ok, at the moment I am going to "clone" a sample from the spirit
examples. In this way I am not stopped but this is what I would like:

Having a file with data I want a grammar to parse this file. I want all
the data to be filled in only one class (ClassToFill). I want a grammar
that parse the contents of the file. This grammar will probably be
updated soon, so I want that the people that update the grammar don't
worry at all about the participants classes so I want the grammar the
maximum isolate as possible.

To solve this situation I thought about using 2 classes one that will be
the component of the application with the information of the data file
that doesn't care at all about how to fill its information and another
class (GrammarClass) that will contain the grammar.

The sequence that I thought is that once ClassToFill is created, it
creates an instance of GrammarClass and calls the phrase "parse".
(Continue reading)

Xavier Pegenaute | 1 Oct 18:35

Character vs Phrase parser

Hi,

What does exactly to change the behaviour between Character and Phrase
parsers? Is it only the skip rules?

Thanks & Regards.
Xavi.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Braden McDaniel | 1 Oct 19:57
Gravatar

Re: stored_rule copying and semantic actions

On Fri, 2007-09-28 at 16:25 +0800, Joel de Guzman wrote:
> Braden McDaniel wrote:
> > On Fri, 2007-09-28 at 14:17 +0800, Joel de Guzman wrote:
> >> Braden McDaniel wrote:
> >>
> >>>>  Do you have code I can try?
> >>> That can be arranged. The code is open source; though the changes that
> >>> exhibit this behavior so far exist only in my local working copy. I can
> >>> put a tarball together and send it to you off-list (since,
> >>> unfortunately, it will not be small).
> >> Can't you provide something minimal?
> > 
> > I will try to put together an example isolating this behavior this
> > weekend.
> 
> Tks!

I haven't managed to reproduce this in a reduced test case yet; but I
think the source of my trouble has dawned on me: my stored_rule--a
member of the grammar::definition--is entered recursively; and actions
taken associated with that recursion can change the stored_rule's value.
I'm guessing I can't do that.

Would putting the stored_rule in a closure let me do what I want here?

--

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

-------------------------------------------------------------------------
(Continue reading)

jono | 1 Oct 23:49

spirit w/ scheme update


i have a lisp parser working.  the most time i've ever spent on 4 lines 
of code, lol!
it hasn't got any special forms yet, just sexp and a few first class 
object types.
also i'm not consing pairs, just using std::list.

anyway i asked my boss about sharing the code, but he's anxious about 
the ip issues, so i'll leave that for now. 

cheers,
jono

Day One Digital Media Ltd.
Auckland, NZ

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Joel de Guzman | 2 Oct 01:26
Picon
Favicon

Re: Fill classes

Xavier Pegenaute wrote:

> The problems with this solution:
> - I have a cyclic include. GrammarClass needs ClassToFill with the bind
> call, and ClassToFill needs GrammarClass with parse.

Ah, so that's your problem. I suggest using templates for the actions.
Here's how I do it in quickbook (with one example only showing the
phrase rule):

     template <typename Actions>
     struct phrase_grammar : grammar<phrase_grammar<Actions> >
     {

         /*...*/

Then a sample of a rule:

     phrase =
        *(   common
         |   comment
         |   (anychar_p - phrase_end)        [actions.plain_char]
         )
         ;

Notice that I didn't have to include anything about `Actions`.
Any kind of `Actions` class will work as long as it can do:

      actions.plain_char

(Continue reading)

Joel de Guzman | 2 Oct 01:26
Picon
Favicon

Re: Character vs Phrase parser

Xavier Pegenaute wrote:
> Hi,
> 
> 
> What does exactly to change the behaviour between Character and Phrase
> parsers? Is it only the skip rules?

Yep.

Regards,
--

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

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Joel de Guzman | 2 Oct 01:32
Picon
Favicon

Re: stored_rule copying and semantic actions

Braden McDaniel wrote:
> On Fri, 2007-09-28 at 16:25 +0800, Joel de Guzman wrote:
>> Braden McDaniel wrote:
>>> On Fri, 2007-09-28 at 14:17 +0800, Joel de Guzman wrote:
>>>> Braden McDaniel wrote:
>>>>
>>>>>>  Do you have code I can try?
>>>>> That can be arranged. The code is open source; though the changes that
>>>>> exhibit this behavior so far exist only in my local working copy. I can
>>>>> put a tarball together and send it to you off-list (since,
>>>>> unfortunately, it will not be small).
>>>> Can't you provide something minimal?
>>> I will try to put together an example isolating this behavior this
>>> weekend.
>> Tks!
> 
> I haven't managed to reproduce this in a reduced test case yet; but I
> think the source of my trouble has dawned on me: my stored_rule--a
> member of the grammar::definition--is entered recursively; and actions
> taken associated with that recursion can change the stored_rule's value.
> I'm guessing I can't do that.
> 
> Would putting the stored_rule in a closure let me do what I want here?

Not sure. It's hard to visualize what you want without some
code. Snippet please :-)

Regards,
--

-- 
Joel de Guzman
(Continue reading)

Xavier Pegenaute | 2 Oct 13:14

Re: Fill classes

Hi,

On dt, 2007-10-02 at 07:26 +0800, Joel de Guzman wrote:
> Xavier Pegenaute wrote:

>      phrase =
>         *(   common
>          |   comment
>          |   (anychar_p - phrase_end)        [actions.plain_char]
>          )
>          ;
> 
> Notice that I didn't have to include anything about `Actions`.
> Any kind of `Actions` class will work as long as it can do:
> 
>       actions.plain_char

First, thanks for your solution. I saw it before but I tried and did not
reach anything so, I was a bit lost.

I saw your code of quickbook, Seems that every actions.XXX must be an
attribute of the main class, and the type of this attribute must be some
struct that should contain a method like this to take the parsed value.

void operator()(...)

Now I was wondering if it is possible to do some thing like this...

phrase =
   *(    common
(Continue reading)

Xavier Pegenaute | 2 Oct 15:00
Picon

Re: Fill classes

Hi,

I am sorry about my last question, it is well explained in doc.

Thanks & Regards.
Xavi.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Petri Lehtinen | 2 Oct 18:52
Gravatar

Re: Documentation of root_node_d

Petri Lehtinen wrote:
> So, it seems to me that the documentation is incorrect.

I found an old thread (from January 2003) discussing
postfix_root_node_d.  Its function is to generate left associative trees
instead of right associative, so it seems that root_node_d has really
produced right associative trees, at least in the past.

Can someone reproduce the right associativity?  For input "1+2+3" the
grammar

  expression = integer >> *(root_node_d[ ch_p('+') ] >> integer);
  integer = leaf_node_d[ lexeme_d[ +(range_p('0', '9')) ]];

produces a left associative tree where "1" and "2" are the children of
"+" which is a sibling of "3".  I've checked it many times by printing
the tree with tree_to_xml().

I'm also curious about what happened to postfix_root_node_d.  In the old
thread the "Spirit Folks" affirmative about adding the new directive to
Spirit.

-Petri Lehtinen

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

Gmane