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 Prune/collapse AST Nodes
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   Translate to Translated (View Original)
 More options Feb 3 2011, 4:23 am
From: andrew cooke <and...@acooke.org>
Date: Thu, 03 Feb 2011 06:23:32 -0300
Local: Thurs, Feb 3 2011 4:23 am
Subject: Re: [LEPL] Re: Prune/collapse AST Nodes

 OK, cool.

 Sorry for the slow reply, but I am only able to read email a few times
 a day - I have just returned to Chile and don't have an internet
 connection (I requested it Monday, but they quoted two weeks for
 installation).  Sometimes I can access an open Wifi, but it is very
 unreliable (yesterday was not visible at all).

 Andrew

 On Wed, 2 Feb 2011 20:09:30 +0100, Florian Leitner

 <florian.leit...@gmail.com> wrote:
> Just to follow up - forget my question, I realized the problem is
> trivial by using the postorder walk function of support.graph...

> --Florian

> On Feb 2, 2011, at 17:17 , Florian Leitner wrote:

>> Hi again,

>> I have a problem I'm not quite able to solve on myself, pruning
>> Nodes that only contain other, single Nodes in the AST, so that the
>> innermost single Node gets "promoted" to the top. Let's take the Nodes
>> example on the webpage (bottom):

>> http://www.acooke.org/lepl/nodes.html

>> There we see the following AST from the expression "1 + 2 * (3 + 4 -
>> 5)", modified with dropped spaces and parenthesis:

>> Expression
>> +- Factor
>> |   +- Term
>> |   |   `- number '1'
>> +- operator '+'
>> `- Factor
>>     +- Term
>>     |   `- number '2'
>>     +- operator '*'
>>     `- Term
>>         +- Expression
>>             +- Factor
>>             |   +- Term
>>             |   |   `- number '3'
>>             +- operator '+'
>>             +- Factor
>>             |   +- Term
>>             |   |   `- number '4'
>>             +- operator '-'
>>             `- Factor
>>                 +- Term
>>                 |   `- number '5'

>> Now, this is rather verbose... I'd like to get rid of all Nodes that
>> contain only single child nodes, to arrive at the following tree:

>> Expression
>> +- Term
>> |   `- number '1'
>> +- operator '+'
>> `- Factor
>>     +- Term
>>     |   `- number '2'
>>     +- operator '*'
>>     `- Term
>>         +- Expression
>>             +- Term
>>             |   `- number '3'
>>             +- operator '+'
>>             +- Term
>>             |   `- number '4'
>>             +- operator '-'
>>             `- Term
>>                 |   `- number '5'

>> This doesn't seem like something very sophisticated, but I don't see
>> a way this is simply done with LEPL, or at least am not able to deduce
>> it from the API and manual. Any hints? Maybe I need to walk the tree
>> and prune it manually?I'm a bit lost ATM, so any help would be much
>> appreciated! Thanks!

>> --Florian


 
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.