Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #85294
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'args': 0.07; 'subject:help': 0.08; 'args)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; '__future__': 0.16; 'alphanum': 0.16; 'args.': 0.16; 'attr': 0.16; 'expecting': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'syntaxerror:': 0.16; 'followed': 0.16; 'trying': 0.19; 'import': 0.22; 'tests': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'header:X-Complaints-To:1': 0.27; 'skip:( 20': 0.30; 'fine,': 0.31; 'class': 0.32; 'subject:with': 0.35; 'but': 0.35; 'subject:?': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'repeat': 0.74; 'received:139': 0.84; 'recursive.': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Neal Becker <ndbecker2@gmail.com> |
| Subject | help with pypeg2? |
| Date | Fri, 06 Feb 2015 09:55:53 -0500 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | exa2-in-fw-01-epn.hns.com |
| User-Agent | KNode/4.14.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18508.1423234568.18130.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1423234568 news.xs4all.nl 2905 [2001:888:2000:d::a6]:37646 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:85294 |
Show key headers only | View raw
Trying out pypeg2. The below grammar is recursive. A 'Gen' is an ident
followed by parenthesized args. args is a csl of alphanum or Gen.
The tests 'p' and 'p2' are fine, but 'p3' fails
SyntaxError: expecting u')'
from __future__ import unicode_literals, print_function
from pypeg2 import *
ident = re.compile (r'[a-z]+')
alphanum = re.compile (r'[a-z0-9]+')
num = re.compile (r'[0-9]+')
class args (List):
grammar = maybe_some ( csl ([alphanum, Gen]))
class Gen (List):
grammar = attr ('type', ident), '(', attr ('args', args), ')'
p = parse ('abc,123', args)
p2 = parse ('abc(123,456)', Gen)
p3 = parse ('abc(123,def(456))', Gen)
--
-- Those who don't understand recursion are doomed to repeat it
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
help with pypeg2? Neal Becker <ndbecker2@gmail.com> - 2015-02-06 09:55 -0500
csiph-web