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 Nesting and +
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 Feb 7 2012, 6:09 pm
From: andrew cooke <and...@acooke.org>
Date: Tue, 7 Feb 2012 20:09:31 -0300
Local: Tues, Feb 7 2012 6:09 pm
Subject: Re: [LEPL] Re: Nesting and +

thanks + glad it works, andrew

On Tue, Feb 07, 2012 at 10:05:53PM -0600, Jelle Herold wrote:
> On 02/07/2012 02:36 PM, andrew cooke wrote:
> >ok, i don't know for sure, but just looking at that raises the following huge
> >red flag:
> >[...]

> So just for the record, should anyone be wondering, here is a parser
> that deals with nested comments, including empty ones, and dropping
> the delimiters.

> Cheers!

> #! /usr/bin/env python

> from lepl import *

> class Comment(Node): pass

> start = Literal('(*')
> end = Literal('*)')

> # a word is any number of symbols not '(*' or '*)'
> word = (~Lookahead(start|end) & Any())[1:,...]

> nested_comment = Delayed()
> contents = (nested_comment | word)[1:]
> comment = ~start & (contents|Empty()) & ~end > Comment
> nested_comment += comment

> parser = nested_comment[1:].get_parse()

> print parser("(*bar(*foo(*toz*)meh*)*)")[0]

> --
> 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.