This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Introduction

easyply is a helper library for PLY, parser generator for Python. It acts as a middleware between your grammar definition and PLY.

What’s so appealing about easyply? PLY supports rather crude parser definitions; easyply adds some EBNF-y flavor to it. easyply is purely a helper in everyday work - you definitely need to understand PLY first in order to use this library.

Goodies

No mandatory whitespace surrounding colon sign

def px_rule():
  "production: SYMBOL

Named parameters

Instead of mutating and reading the mysterious p parameter, easyply employs named parameters and return values. So:

def px_rule(id):
  "production: {ID}
  ...
  return retval

is equivalent to:

def p_rule(p):
  "production : ID"
  id = p[1]
  ...
  p[0] = retval

You can also use custom names for parameters, just like this:

def px_rule(foo):
  "production: {ID:foo}"

In case when the custom name is not provided, a lowercased name of the term is used.

Optional symbols

Instead of creating multiple similar rules differing only by a few symbols, you can consolidate them into one using ? symbol. Observe:

def px_rule():
  "production: symbol1 symbol2? symbol3"
  ...

Given this code, easyply will generate two functions with the same code and the following rules:

  • production: symbol1 symbol3
  • production: symbol1 symbol2 symbol3

This is especially powerful in conjunction with named parameters(note the parentheses):

def px_list(expression, list = ()):
  "list: ({list} COMMA)? {expression}"
  return list + expression

Neat, isn’t it?

OR operator

In addition, easyply offers OR operator for quick grouping of similar cases:

def px_expression():
  """
    expression: LPAREN expression RPAREN
              | NUMBER
              | REAL
  """
  ...

The OR operator can be also used inline:

def px_list(expresion, list = ()):
  "list: ({list} (COMMA|SEMICOLON))? {expresson}"
  ...

Note that OR has the lowest priority of all operators - hence the additional parentheses.

Installation

pip install easyply

Usage

Basic usage is simple: Prefix all your easyply rules, except p_error, with px_ prefix (instead of the usual p_) and call easyply.process_all(globals()) before creating your PLY parser. The parameter to easyply.process_all can be any mapping or class with parser functions - process_all will mutate the parameter and add appropriate PLY rules. If you want more fine-grained control, consult the API reference in the source itself.

License

This library is licensed under the MIT License.

Copyright © 2011 by Mike Hordecki

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release History

Release History

1.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
easyply-1.2.tar.gz (8.9 kB) Copy SHA256 Checksum SHA256 Source Feb 3, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting