skillfed

sly

"SLY - Sly Lex Yacc"

sly v0.5 5.1M downloads/30d#2,172 on PyPI862
Permissive license MIT Abandoned released

What it is and what it does

SLY is a pure-Python lexer and parser generator based on the LALR(1) algorithm, designed for building compilers and domain-specific language parsers without requiring a separate code generation step. You define lexer and parser rules as Python classes with decorators, and SLY handles tokenization and syntax analysis directly at runtime.

The library was originally developed for instructional purposes and emphasizes extensive error reporting to help users identify common mistakes. It supports empty productions, error recovery, precedence rules, and moderately ambiguous grammars. While not optimized for speed due to its Python implementation, it can handle grammars with several hundred rules. However, the project was retired on December 21, 2025, and no further maintenance is planned.

Use it for:

  • Building a domain-specific language (DSL) interpreter or compiler without external code generation tools.
  • Parsing configuration files or domain-specific syntax with custom error messages for invalid input.
  • Educational projects where understanding parser construction and LALR theory is part of the goal.
  • Prototyping language features or grammar designs before committing to a production parser generator.
  • Embedding a simple expression evaluator into a Python application.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

SLY is a pure-Python implementation of lex and yacc for building lexers and parsers using LALR(1) parsing, with no code generation step required.

No—do not install for new projects. The project is formally retired as of December 21, 2025 with no planned maintenance. While the code is stable and license-permissive, the maintainer explicitly recommends considering alternatives. Install only if you are maintaining existing code that already depends on SLY, or if you are willing to fork and maintain it yourself.

Install

sly on PyPI

pip

pip install sly

uv

uv add sly

poetry

poetry add sly

Installing sly

Before you install

Installation is frictionless with no runtime dependencies. However, the project was formally retired on December 21, 2025, with the maintainer stating no further maintenance is expected. The repository is archived. Users should be aware they are adopting a library that will not receive updates or bug fixes.

License in practice

SLY is licensed under the MIT License (permissive), meaning you can use, modify, and distribute it freely with minimal restrictions, though you must include the license notice.

Quickstart

from sly import Lexer, Parser

class MyLexer(Lexer):
    tokens = { NAME, NUMBER }
    NAME = r'[a-zA-Z_][a-zA-Z0-9_]*'
    NUMBER = r'\d+'

class MyParser(Parser):
    tokens = MyLexer.tokens
    @_('NUMBER')
    def expr(self, p):
        return int(p.NUMBER)

lexer = MyLexer()
parser = MyParser()
result = parser.parse(lexer.tokenize('text'))

Requires Python 3.6 or greater.

Verify before relying

  • Whether the archived repository will accept security patches or critical bug fixes despite the retirement notice.
  • Performance characteristics when parsing large or complex grammars in production settings.
  • Compatibility with recent Python versions given the last release was October 2022.

Package facts

License MIT (permissive)
Python support not specified
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 1,389 days since the last release
Last repo commit (repository archived)
First released
Downloads 5,083,867/month — #2,172 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: sly-0.5-py3-none-any.whl

License :: OSI Approved :: MIT License

Tags

python parser generatorlex yacc implementationlalr parser librarylexer tokenizer pythoncompiler construction toolsgrammar parsing frameworkrecursive descent alternative
parser-generatorarchivededucational

More Build Tools packages