grammatica-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Grammatica-users] Grammar for "Nesting"


From: Per Cederberg
Subject: Re: [Grammatica-users] Grammar for "Nesting"
Date: Mon, 25 Jul 2005 22:48:29 +0200

Well, Grammatica uses LL grammars so they are recursive on
the right-hand side. Your production is identical to this
one:

Message = MethodCall
        | Object MethodCall
        | Message MethodCall ;

This describes a sequence of MethodCall productions with a
possible end of an Object and then a MethodCall. To write
this in a right-recursive way, you'd simply write this
instead:

Message = MethodCall
        | Object MethodCall
        | MethodCall Message ;

Which in turn can be simplified to:

Message = MethodCall [Message]
        | Object MethodCall ;

/Per

On mon, 2005-07-25 at 12:45 -0500, Patrick M Gremo wrote:
> This is close.
> 
> 
> 
> But I think what I need is something like:
> 
> Message = [Object | Message] MethodCall
> 
> But this gives me an infinite loop.
> 
> I think I can describe it as:
> 
> A Message can have an Object OR another Message coupled with a MethodCall.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> I think a production for Message could look like this:
> 
>   Message = MethodCall Message?
>           | Object Message? ;
> 
> This will allow an infinite list of method calls and
> objects mixed together. If the Object production can
> only be placed at the end, you'd write the production
> like this:
> 
>   Message = MessageCall Message?
>           | Object ;
> 
> Cheers,
> 
> /Per
> 
> On sun, 2005-07-24 at 19:40 -0500, Patrick M Gremo wrote:
> > 
> > I'm trying to create a kind of "reverse" call stack type of thing.  It
> > sounds easy but for some reason I just can't figure it out.
> > 
> > I have this:
> > 
> > (object | methodCall) methodCall methodCall methodCall ...
> > 
> > 
> > I want a tree like:
> > 
> > message
> >    |-methodCall
> >    |-message
> >         |-methodCall
> >         |-message
> >              |-methodCall
> >              |-message
> >                   |-object | methodCall
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Grammatica-users mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/grammatica-users
> > 
> _______________________________________________
> Grammatica-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/grammatica-users





reply via email to

[Prev in Thread] Current Thread [Next in Thread]