Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #85297

Re: help with pypeg2?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'args': 0.07; 'subject:help': 0.08; '__future__': 0.16; 'alphanum': 0.16; 'args.': 0.16; 'expecting': 0.16; 'optional': 0.16; 'syntaxerror:': 0.16; 'followed': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'feb': 0.22; 'import': 0.22; 'tests': 0.22; 'looks': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'fine,': 0.31; 'produces': 0.31; 'class': 0.32; 'fri,': 0.33; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'list': 0.37; 'lists.': 0.38; 'to:addr:python- list': 0.38; 'list,': 0.38; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'more': 0.64; '2015': 0.84; 'recursive.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=gGcQ5xq0edSLRLRT9rqI++VkeVdkv2Z6TTJxgQ0/U+Y=; b=y2/Aqyj1JeOb6H2derCQVYtpfKKIPm6XqtKtDqF4g82HdioL3bHuSPIYZZgjzCZi16 Zb6dQulUv+h728NpFN510amZ6lVB826PU/x1JbB6eWNESgTNesN5zzj2PDRR6Nz5zMvY tNER3VaaDsP0xzh8Cq5ZLtlSZOKyydJvDMxGdQlIJJCaa36cXBGz9RCEasld4rxwix3V 65fGg9A2vaIwELbXfP41zvhKCWGv+eOq1XQEsBvCN1VfyDoXiQzcDUS2ZSuNZbKVLt0r 2Un6Je6h9/3F/G9sEIeCrSewWOtdOUeaOcidiY0kb5ZgSeyUqdVhBXDRLcWU6dEPCwsj lD3A==
X-Received by 10.70.135.165 with SMTP id pt5mr7104350pdb.101.1423240850546; Fri, 06 Feb 2015 08:40:50 -0800 (PST)
MIME-Version 1.0
In-Reply-To <mb2klq$3r5$1@ger.gmane.org>
References <mb2klq$3r5$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Fri, 6 Feb 2015 09:40:10 -0700
Subject Re: help with pypeg2?
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.18510.1423240859.18130.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1423240859 news.xs4all.nl 2844 [2001:888:2000:d::a6]:54877
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:85297

Show key headers only | View raw


On Fri, Feb 6, 2015 at 7:55 AM, Neal Becker <ndbecker2@gmail.com> wrote:
> 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]))

I'm not familiar with pypeg2, but should this use optional instead of
maybe_some? The csl function already produces a list, so the result of
maybe_some on that would be one or more consecutive lists.

Also, it looks from the docs like it should just be "csi(alphanum,
Gen)" (no list in the arguments).

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: help with pypeg2? Ian Kelly <ian.g.kelly@gmail.com> - 2015-02-06 09:40 -0700

csiph-web