Skip to main content

PyLGEN

PyPI - 0.6.1 PyPI - 3.12 PyPI - LICENSE CI Supported OS

From prototype to production: a Python-native compiler framework that brings the "Dragon Book" to life in Python, with clarity throughout.

PyLGEN gives you complete control over every stage of language processing. Build interpreters and compilers from scratch without leaving the Python ecosystem. Prototype rapidly in pure Python, then compile to native speed with Cython for production workloads.

[!note] Cython compilation requires a C compiler installed on system to compile the code

Why PyLGEN?

  • Full pipeline control: You own every step: lexer, parser, AST, semantic analysis, and evaluation.

  • Dual‑nature design: Pure Python for development and debugging; Cython for near‑C performance.

  • Built for scale: Handles 2‑million‑line inputs with ~1.92x faster parsing than Lark + lark_cython.

  • Python ecosystem integration: Leverage NumPy, SciPy, or any library from within your language.

📊 Benchmark at a Glance

Lark + lark_cython PyLGEN
Parsing (2M lines, 40 MB) 116.73 s 60.80 s
AST Construction Separate pass Integrated
Full Interpreter — ~66.03 s (incl. semantic checks + eval)
Peak Memory ~4 GB ~928 MB

more details in the benchmark section of documentation →

PyLGEN is not just a parser, it's a complete, production‑ready interpreter framework that outperforms industry‑standard tools.

🚀 Minimal Example

from pylgen.lexer import Lexer
from pylgen.grammar import AttributedGrammar
from pylgen.parser import ParserBuilder, ParserType

# 1. Define tokens & lexer
lexer = Lexer(mapping_function, r'\s+')
lexer[0, 'NUMBER'] = r'\d+'
lexer[1, 'PLUS']   = r'\+'

# 2. Define grammar with AST builders
G = AttributedGrammar(start=Symbol('E'))
G[E] += (E, plus, T), binary_reductor
G[E] += (T,),        single_reductor

# 3. Build the parser
parser = ParserBuilder.build_parser_from_attributed(G, ParserType.LALR1)

# 4. Parse, analyse, execute
ast = parser.parse(lexer.tokens)
# ... your semantic visitors & evaluator ...

🧩 Architecture

flowchart LR
    Source["Source Code"] --> Lexer["Lexer"]
    Lexer --> Parser["Parser LALR(1)"]
    Parser --> AST["AST"]
    AST --> Visitors["Visitors"]
    Visitors --> Result["Result / Errors"] 
Module Purpose
common Core types: Symbol, AST, Token, ASTListView
automaton Finite automata(DFA/NFA), determinization, Hopcroft minimisation
regex Full regex engine -> automata conversion
lexer Regex‑based tokenisation with priority and validation
grammar CFG and attributed grammar with reducers
parser LALR(1) parser generation and runtime
analysis Visitor pattern, traversal strategies, context management
visual Interactive HTML visualisation of ASTs, parse trees, automata and parsing tables

All modules are fully usable from Python and Cython, prototype in Python, ship in C.

⚡ Quick Start

pip install pylgen-core

Then build your interpreter step by step, following the complete tutorial in the documentation.

📖 Learn More

  • Step‑by‑step tutorial: Build a full arithmetic REPL from scratch.

  • VecLang case study: Production‑grade language with vectors, functions, and slicing.

  • Deep‑dive API tour: Understand every module inside out.

Read the full documentation →

PyLGEN: Where compiler theory meets Python pragmatism.

Metadata

Release files for pylgen-core 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pylgen-core 0.6.1
File Size Uploaded
pylgen_core-0.6.1.tar.gz 2.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pylgen-core 0.6.1
File
pylgen_core-0.6.1-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pylgen_core-0.6.1-cp314-cp314-musllinux_1_2_x86_64.whl CPython 3.14 CPython 3.14 Linux musl 1.2+ x86-64 Details
pylgen_core-0.6.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
pylgen_core-0.6.1-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
pylgen_core-0.6.1-cp314-cp314-macosx_10_15_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.15+ x86-64 Details
pylgen_core-0.6.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pylgen_core-0.6.1-cp313-cp313-musllinux_1_2_x86_64.whl CPython 3.13 CPython 3.13 Linux musl 1.2+ x86-64 Details
pylgen_core-0.6.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
pylgen_core-0.6.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
pylgen_core-0.6.1-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
pylgen_core-0.6.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pylgen_core-0.6.1-cp312-cp312-musllinux_1_2_x86_64.whl CPython 3.12 CPython 3.12 Linux musl 1.2+ x86-64 Details
pylgen_core-0.6.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
pylgen_core-0.6.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
pylgen_core-0.6.1-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details

Total release size: 97.3 MB

Release files / pylgen_core-0.6.1.tar.gz

Download URL pylgen_core-0.6.1.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
805058c26d32bf3892c74802ca1f099f09d5bdebcc939a63baa41b46502debcd
BLAKE2b-256 checksum
How to use checksums
63943fb661b5be995754520c51cbcf0edd122f10f2ab66efd5a4350539de67ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp314-cp314-win_amd64.whl

Download URL pylgen_core-0.6.1-cp314-cp314-win_amd64.whl
Size 3.4 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
1b522071f876b3fc70b473cde830da0fc9b38262e0f46ff5d79ae3d4a20cc4de
BLAKE2b-256 checksum
How to use checksums
371432876a2633953dba3d35c8fac7b903a6e4bc02ed905000c0320ff6b66dee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL pylgen_core-0.6.1-cp314-cp314-musllinux_1_2_x86_64.whl
Size 10.4 MB
Tags CPython 3.14 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
255a9db0c80f999ebd9b17f038490273671a656bb0f669a098f3c92292415631
BLAKE2b-256 checksum
How to use checksums
009721b0411a1b51883e6db42687dd8dff2cbb13652b1ea7c3028a39b5a193ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pylgen_core-0.6.1-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 10.4 MB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a5e309b15d7bfba1f434bccfbafe17f7290d9a2b3eff52f95f1e57a16b5f2fba
BLAKE2b-256 checksum
How to use checksums
4a8335e96327548b73756af449fe41cfc7c2409520608fd5901fcb0b288f3002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp314-cp314-macosx_11_0_arm64.whl

Download URL pylgen_core-0.6.1-cp314-cp314-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ec8a29776b2a5de6749011095c3d67a771d54bca2d14aed20a5e3bb3ad417836
BLAKE2b-256 checksum
How to use checksums
8a6a4c048bb172f0d17ba6a6b40c11642ecc41211251e3eae148fd99c03fcbef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp314-cp314-macosx_10_15_x86_64.whl

Download URL pylgen_core-0.6.1-cp314-cp314-macosx_10_15_x86_64.whl
Size 3.7 MB
Tags CPython 3.14 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
ee1c7dde1cff8e1fe75151a591491653abbf2d92f246fe70d6b0048fe436f431
BLAKE2b-256 checksum
How to use checksums
d68ade7d32f8e287866531d05ec5f619e2adec435ab703ae9a12237b7647cad1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp313-cp313-win_amd64.whl

Download URL pylgen_core-0.6.1-cp313-cp313-win_amd64.whl
Size 3.4 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
fda4de4a02b2d11c339785ce82a19eec965f4f1825bb70a6860887dd9766e24d
BLAKE2b-256 checksum
How to use checksums
288f3b07b842284ae1bda16e387977e11f72af90740d9a3883cf0cf7265e8fde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL pylgen_core-0.6.1-cp313-cp313-musllinux_1_2_x86_64.whl
Size 10.5 MB
Tags CPython 3.13 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
70f9c93fbbca5c49eee309e71fe741e2992701f20baf96cb0125e74496b8bf53
BLAKE2b-256 checksum
How to use checksums
ed4165ecccdf807cb9cb7632af1bea6db115639f34d190a75a00aa98d3393560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pylgen_core-0.6.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 10.5 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e13019072010f9e0bb9755643b26c250336ac99e8859394c2a07fa6652ed258c
BLAKE2b-256 checksum
How to use checksums
81fe467c2f10355e7d24407a8757fc01f9d3e17c07e24c2eeb8e0b2ae91940c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL pylgen_core-0.6.1-cp313-cp313-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
10327a899fe0c3bf972aac1ffe667b6d504bc24bcc553b02b964412e12ad0125
BLAKE2b-256 checksum
How to use checksums
883d8eb4736809a701280bea920868fc53358ae60013018a78956f2f98df1596
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp313-cp313-macosx_10_13_x86_64.whl

Download URL pylgen_core-0.6.1-cp313-cp313-macosx_10_13_x86_64.whl
Size 3.7 MB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
705cfb0fd58ad86f4f984d9e4facbbb14d6efb60d2bd55ac028126906ea7606e
BLAKE2b-256 checksum
How to use checksums
8ce24e504132a5cf6decbd1ac8e2c831e5a1692b3f7d8d8d1cdf4a429d155a9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp312-cp312-win_amd64.whl

Download URL pylgen_core-0.6.1-cp312-cp312-win_amd64.whl
Size 3.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
0a1b26f3d56faef26a8055812e6192f75af96274f3230c06e781ce1f18adeedb
BLAKE2b-256 checksum
How to use checksums
0dd818252a5a91801b75585b9a0b734be84ff375363b7db9dc055dca6dc9179d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL pylgen_core-0.6.1-cp312-cp312-musllinux_1_2_x86_64.whl
Size 10.6 MB
Tags CPython 3.12 Linux musl 1.2+ x86-64
SHA-256 checksum
How to use checksums
1deb4a6d67c0691a5bc3c9b3aef182ad97b592c93408fd66a398d0e6b3eb9c3a
BLAKE2b-256 checksum
How to use checksums
e1f4d33b44cbe587c21f71ec76bb839bcf20700e52149aff354ea6cbfd25d4bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pylgen_core-0.6.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 10.6 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
aba99d498868758324f98a951d383cb6053734ff44b30fe5da5d893b98c66f27
BLAKE2b-256 checksum
How to use checksums
d9aaf77b3881cdcc564514e704c4d3b386c21b3deeeb60893ae180a16147d0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL pylgen_core-0.6.1-cp312-cp312-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b47d5a60f1e6f2c8f74241e891a3810918326f6115a8b34c873efdea24f7027c
BLAKE2b-256 checksum
How to use checksums
c7e066e4fc08ebd9523bd9022516276826f503e3e24e5cfc3344d76149ae3f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / pylgen_core-0.6.1-cp312-cp312-macosx_10_13_x86_64.whl

Download URL pylgen_core-0.6.1-cp312-cp312-macosx_10_13_x86_64.whl
Size 3.7 MB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
6a1bca8784509a81b5a4562f6f9e4bd8a228beb52e1aca71a19134a2ffa72198
BLAKE2b-256 checksum
How to use checksums
5e9ae6f5361a30ebb0644cb299eaa74ba02510f8f51f46a2a8bc3cf6797e488d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release history Release notifications | RSS feed

0.7.2

16 release files

0.7.1

16 release files

0.7.0

16 release files

0.6.3

16 release files

This release

0.6.1 This release

16 release files

0.6.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page