The Artima Developer Community
Sponsored Link

Python Buzz Forum
python4ply

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Andrew Dalke

Posts: 291
Nickname: dalke
Registered: Sep, 2003

Andrew Dalke is a consultant and software developer in computational chemistry and biology.
python4ply Posted: Mar 8, 2008 6:50 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Andrew Dalke.
Original Post: python4ply
Feed Title: Andrew Dalke's writings
Feed URL: http://www.dalkescientific.com/writings/diary/diary-rss.xml
Feed Description: Writings from the software side of bioinformatics and chemical informatics, with a heaping of Python thrown in for good measure.
Latest Python Buzz Posts
Latest Python Buzz Posts by Andrew Dalke
Latest Posts From Andrew Dalke's writings

Advertisement

python4ply 1.0

python4ply is a Python parser for the Python language. The grammar definition uses PLY, a parser system for Python modelled on yacc/lex. The parser rules use the "compiler" module from the standard library to build a Python AST and to generate byte code for .pyc file.

You might use python4ply to experiment with variations in the Python language. The PLY-based lexer and parser are much easier to change than the C implementation Python itself uses or even the ones written in Python which are part of the standard library. This tutorial walks through examples of how to make changes in different levels of the system

To give you an idea of what it can do, here are some examples from the tutorial:

     # integers with optional underscores separators 
amount = 20_000_000
print "You owe me", amount, "dollars"
      # sytax-level support for decimals
% cat div.py
# div.py
print "float", 1.0 % 0.1
print "decimal", 0d1.0 % 0d0.1
% python compile.py -e div.py
float 0.1
decimal 0.0
% 
      # Perl-like regex creation and match operator
for line in open("python_yacc.py"):
    if line =~ m/def (?P\w+) *(?P\(.*\)) *:/:
        print repr($1), repr($args)

The primary site for ply4python is http://dalkescientific.com/Python/python4ply.html. The package is released under the MIT license.

Download python4ply-1.0.tar.gz or view the tutorial.

  • Questions or comments?
  • Read: python4ply

    Topic: On The Use of Code in Weblog Titles Previous Topic   Next Topic Topic: Jython and Java part 2

    Sponsored Links



    Google
      Web Artima.com   

    Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use