Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Left and right recursion with subtraction
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
andrew cooke  
View profile  
 More options Jun 21 2011, 10:36 pm
From: andrew cooke <and...@acooke.org>
Date: Tue, 21 Jun 2011 22:36:08 -0400
Local: Tues, Jun 21 2011 10:36 pm
Subject: Re: [LEPL] Re: Left and right recursion with subtraction

curiously, i remembered you just this morning because i stumbled across the
test case i wrote when you last asked.  i haven't done any more, but i'll have
a look at using repetition (like the example) in the next few days.

cheers,
andrew

On Tue, Jun 21, 2011 at 09:54:09PM -0400, Andrew Stromme wrote:
> Hi Andrew,

> I'm just checking in with regards to the repetition vs recursion and left
> recursion/right recursion question I had a while back. The parsing part of
> my project was on the back burner but I'm picking it up again and remembered
> that I had this issue to look at. I had a look at the expression.py example
> but couldn't get it to work myself with Tokens.

> Thanks,

> Andrew Stromme

> On Tue, May 31, 2011 at 7:13 PM, andrew cooke <and...@acooke.org> wrote:

> > Hi,

> > I am trying to look at this, but am having some "issues" with running any
> > Python code at all, so it may be some time before I can get back.

> > FWIW it seems like you are right and that exmple is wrong.  What I would
> > like
> > to do is extend the approach at
> > http://code.google.com/p/lepl/source/browse/src/lepl/_example/express...
> > which uses repeptition rather than recursion.  I thnk that could give a
> > clean
> > solution, with some work (eg using "sum(...)")

> > Sorry I can't be more help right now - will try and be more useful in the
> > new
> > day or two.

> > Andrew

> > On Tue, May 31, 2011 at 02:23:36PM -0700, astromme wrote:
> > > After consulting the dragon book and some online resources I've come
> > > up with

> > > group4end = Delayed()
> > > add = ~symbol('+') & group3 & group4end > List
> > > sub = ~symbol('-') & group3 & group4end > List
> > > group4end += Optional(add | sub)
> > > group4 += group3 & group4end > List

> > > which should associate things as expected, I think? However, this
> > > makes it a lot harder to generate nodes on the fly. I still would like
> > > to have nodes that look sort of like (subtract (subtract 4 3) 2).

> > > Andrew

> > > On May 31, 3:53 pm, Andrew Stromme <andrew.stro...@gmail.com> wrote:
> > > > Hi there,

> > > > A part of my parser deals with expressions matching. I'm handling
> > operator
> > > > precedence as shown onhttp://www.acooke.org/lepl/intro-4.html

> > > > add = group3 & ~symbol('+') & group4 > Add._make
> > > > sub = group3 & ~symbol('-') & group4 > Sub._make
> > > > group4 += add | sub | group3

> > > > Lets assume that I am trying to parse 4 - 3 - 2 to get -1. The above
> > grammar
> > > > matches expressions incorrectly because ((4 - 3) - 2) is different from
> > (4 -
> > > > (3 - 2)). The parser generates an AST that corresponds to the 2nd
> > option,
> > > > which is wrong. I could rewrite the grammar as a left-recursive
> > grammar, but
> > > > that isn't good because it's best not to memoize. Any ideas?

> > > > Thanks,

> > > > Andrew

> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "lepl" group.
> > > To post to this group, send email to lepl@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > lepl+unsubscribe@googlegroups.com.
> > > For more options, visit this group at
> > http://groups.google.com/group/lepl?hl=en.

> > --
> > You received this message because you are subscribed to the Google Groups
> > "lepl" group.
> > To post to this group, send email to lepl@googlegroups.com.
> > To unsubscribe from this group, send email to
> > lepl+unsubscribe@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/lepl?hl=en.

> --
> You received this message because you are subscribed to the Google Groups "lepl" group.
> To post to this group, send email to lepl@googlegroups.com.
> To unsubscribe from this group, send email to lepl+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/lepl?hl=en.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.