Coder Social home page Coder Social logo

rocky / python-spark Goto Github PK

View Code? Open in Web Editor NEW
44.0 5.0 8.0 412 KB

An Earley-Algorithm Context-free grammar Parser Toolkit

License: MIT License

Python 91.44% Makefile 1.04% PowerShell 3.82% Batchfile 1.79% Shell 1.91%
parser parsing-library

python-spark's Introduction

buildstatus Pypi Installs Latest Version Supported Python Versions

packagestatus

An Earley Algorithm Parser toolkit.

This package uses Jay Earley's algorithm for parsing context free grammars, and comes with some generic Abstract Syntax Tree routines. There is also a prototype scanner which does its job by combining Python regular expressions.

(SPARK stands for Scanning, Parsing, and Rewriting Kit. It is a poor name since it conflicts with a more popular package of the same name. In the future we will rename this.)

The original version of this was written by John Aycock for his Ph.d thesis and was described in his 1998 paper: "Compiling Little Languages in Python" at the 7th International Python Conference. The current incarnation of this code is maintained (or not) by Rocky Bernstein.

Note: Earley algorithm parsers are almost linear when given an LR grammar. These are grammars which are left-recursive.

Installation

This uses setup.py, so it follows the standard Python routine:

$ pip install -e .  # set up to run from source tree
                    # Or if you want to install instead
$ python setup.py develop

Example

The github example directory has a worked-out examples; Package uncompyle6 uses this and contains a much larger example.

See Also

python-spark's People

Contributors

rocky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-spark's Issues

Grammar checking

We should have a routine for warning about nonterminals that don't appear on the LHS (especially those that aren't all uppercase).

We should warn about right-recursive rules.

incorrect setup_requires in setup.py

s/setup_requires/tests_require/

Nose is a test only dependency. Using setup_requires forces it to be installed.
It should be a tests_require setting.

Add omega memoization

To handle right recursion. See the Perl parser or the one Evan Pheonix did for inspiration.

Deprecation warning due to invalid escape sequences

Deprecation warnings are raised due to invalid escape sequences. This can be fixed by using raw strings or escaping the literals. pyupgrade also helps in automatic conversion : https://github.com/asottile/pyupgrade/

find . -iname '*.py' | grep -v example | xargs -P4 -I{} python3.8 -Wall -m py_compile {}
./spark_parser/spark.py:127: DeprecationWarning: invalid escape sequence \e
  _NULLABLE = '\e_'
./spark_parser/spark.py:200: DeprecationWarning: invalid escape sequence \s
  doc = os.linesep.join([s for s in doc.splitlines() if s and not re.match("^\s*#", s)])
./spark_parser/spark.py:272: DeprecationWarning: invalid escape sequence \s
  doc = os.linesep.join([s for s in doc.splitlines() if s and not re.match("^\s*#", s)])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.