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 lepl and blocks
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
 
wrobell  
View profile  
 More options Dec 13 2011, 7:35 pm
From: wrobell <wrob...@pld-linux.org>
Date: Tue, 13 Dec 2011 16:35:54 -0800 (PST)
Local: Tues, Dec 13 2011 7:35 pm
Subject: Re: lepl and blocks
On Dec 13, 12:43 am, andrew cooke <and...@acooke.org> wrote:

> as i said earlier, i can't do much from here, but i would suggest using "with
> TraceVariable()"http://acooke.org/lepl/debugging.html#index-3which should
> help clarify what is matching what.  if it works with tokens and lines (i
> guess it should, but cannot be sure).  andrew

Thanks for the tip.

The order matters!

Should be

    statement += (block | line | empty) > list

instead of

    statement += (empty | line | block) > list

The whole example below.

------- cut --------------
from lepl import *

word = Token(Word(Lower()))

statement = Delayed()

line = Line(word[:])
empty = Line(Empty(), indent=False)
block = line & Block(statement[1:])

statement += (block | line | empty) > list
program = statement[:]

program.config.lines(block_policy=constant_indent(4))
parse = program.parse

print(parse('''
abc def
ghijk
    mno pqr
        stu
    vwx yz
'''))

------- cut --------------

Best regards,

w


 
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.