rply
A pure Python Lex/Yacc that works with RPython
What it is and what it does
RPLY is a parser generator library that lets you define lexical and syntactic rules for parsing custom languages or domain-specific syntax. You write token rules (lexer) and grammar productions (parser) as Python decorators, then build a lexer and parser that can tokenize and parse input strings. It's a direct port of PLY (Python Lex-Yacc) with a cleaner API and support for RPython, a statically-typed Python subset used by PyPy.
The library is designed for building interpreters, domain-specific languages, or any tool that needs to parse structured text. It handles operator precedence, error reporting with source positions, and optional caching of compiled grammars. The box pattern (wrapping values in classes) is built in for RPython compatibility but can be ignored in pure-Python projects.
Use it for:
- Build a simple calculator or expression evaluator that parses and computes mathematical expressions.
- Create a domain-specific language (DSL) parser for configuration files or query languages.
- Implement an interpreter for a toy programming language or scripting syntax.
- Parse structured text formats where regex alone is insufficient.
- Develop a PyPy-compatible parser when RPython support is required.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
RPLY is a pure Python parser generator that creates lexers and parsers from grammar rules, compatible with both standard Python and RPython.
Yes, if you need a parser generator and are comfortable with abandoned software. RPLY is stable, has no known vulnerabilities, and works well for building parsers in pure Python. However, it has received no updates since January 2021 and is no longer maintained—use it only for projects where you can tolerate no future fixes or Python version support updates. For active alternatives, consider PLY or more modern parser libraries.
Install
rply on PyPI
pip
pip install rplyuv
uv add rplypoetry
poetry add rplyInstalling rply
Before you install
Installation is straightforward with a single lightweight dependency (appdirs) and a pure-Python wheel. However, the package is abandoned—last released in January 2021 with no activity since, so expect no bug fixes or maintenance.
License in practice
BSD 3-Clause License is permissive, allowing commercial and private use with minimal restrictions; attribution and license inclusion are required.
Quickstart
pip install rply
from rply import LexerGenerator, ParserGenerator
from rply.token import BaseBox
lg = LexerGenerator()
lg.add("NUMBER", r"\d+")
lg.add("PLUS", r"\+")
lg.ignore(r"\s+")
pg = ParserGenerator(["NUMBER", "PLUS"])
@pg.production("expr : NUMBER PLUS NUMBER")
def expr(p):
return int(p[0].getstr()) + int(p[2].getstr())
lexer = lg.build()
parser = pg.build()
result = parser.parse(lexer.lex("1 + 2"))
Requires understanding of lexer/parser concepts; RPython support is optional but the box pattern (wrapping values) is necessary for RPython compatibility.
Verify before relying
- Whether the package still works reliably with Python 3.8+ given the 2021 release date and no recent maintenance.
- Whether cached parsers (cache_id feature) remain compatible across Python versions without manual invalidation.
Package facts
| License | BSD 3-Clause License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — appdirs |
| Maintenance | abandoned — 2,025 days since the last release |
| First released | |
| Downloads | 542,262/month — #6,089 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: rply-0.7.8-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
plyPLY is a lexer and parser generator for Python…
permissive · top 1,000 on PyPI
slySLY is a pure-Python implementation of lex and…
permissive · top 5,000 on PyPI
phplyphply is a lexer and parser for PHP source code…
permissive · top 15,000 on PyPI
pygmarsPygmars builds lightweight lexers and parsers…
permissive · top 15,000 on PyPI
ParsleyParsley is a PEG-based parsing library that…
permissive · top 5,000 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
funcparserlibFuncparserlib is a recursive descent parsing…
permissive · top 15,000 on PyPI
flexparserflexparser lets you build parsers by writing…
permissive · top 5,000 on PyPI
lark-parserLark is a parsing library that builds abstract…
permissive · top 5,000 on PyPI
PyMeta3PyMeta3 compiles pattern-matching grammars…
permissive · top 15,000 on PyPI