Skip to main content

PyLGEN

PyPI - 0.6.3 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 ...
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.

📝 Changelog

v0.6.2 (2026-08-29) – Latest

  • fixed bug of type mismatches of BottomUpParser with enum BottomUpParserAction

Metadata

Release files for pylgen-core 0.6.3

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.3
File Size Uploaded
pylgen_core-0.6.3.tar.gz 2.4 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pylgen-core 0.6.3
File
pylgen_core-0.6.3-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
pylgen_core-0.6.3-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.3-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.3-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details
pylgen_core-0.6.3-cp314-cp314-macosx_10_15_x86_64.whl CPython 3.14 CPython 3.14 macOS 10.15+ x86-64 Details
pylgen_core-0.6.3-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
pylgen_core-0.6.3-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.3-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.3-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
pylgen_core-0.6.3-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
pylgen_core-0.6.3-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
pylgen_core-0.6.3-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.3-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.3-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
pylgen_core-0.6.3-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.3.tar.gz

Download URL pylgen_core-0.6.3.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
c205777fdd26553f28457c6c52d4633d6a37c523fbb73890d8b833e5897f7401
BLAKE2b-256 checksum
How to use checksums
458c23525881288aa5ea14344f3935d19379827f5ab8d7eb1d8b4d3d291d37ad
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.3-cp314-cp314-win_amd64.whl

Download URL pylgen_core-0.6.3-cp314-cp314-win_amd64.whl
Size 3.4 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
5025a74a6b434d3f30c2a5c155c6a0629927bc5e42c79c4ac72c60e93081b7b1
BLAKE2b-256 checksum
How to use checksums
c31bfb96c055ef9d80f04634926edf74ed519f65ed8d5ded3c92bd8cbb88c325
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.3-cp314-cp314-musllinux_1_2_x86_64.whl

Download URL pylgen_core-0.6.3-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
35a77625ba40d15fb2751f91c77e0f1c9479bc7129d46f4b54075a1c25ae071d
BLAKE2b-256 checksum
How to use checksums
ccb0c70d72f504633c128e05962b9c402f000e51bdaac8590ba7c8bb13ff8634
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.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pylgen_core-0.6.3-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
f0bd15b8967ebf31934fb6c0f89188b4a61062954e5ed9eb5e93e3948d0b449f
BLAKE2b-256 checksum
How to use checksums
fc1173ef55e7abe752d396f5b5d977bf50d3273abdcc4dbff18a126325d9607a
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.3-cp314-cp314-macosx_11_0_arm64.whl

Download URL pylgen_core-0.6.3-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
33c3b288d809503287f0be646526d0c76453ae496041c846a401e65d5874298f
BLAKE2b-256 checksum
How to use checksums
e91150f4e150c8b198ab29819bb273f8ca28c6b34c831f583e15aae6b88b85b1
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.3-cp314-cp314-macosx_10_15_x86_64.whl

Download URL pylgen_core-0.6.3-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
b137ee86304c1e12318caca927f70e9d7abbceff113cb2ac3f0c522821687ead
BLAKE2b-256 checksum
How to use checksums
756f34ebcab5f528207acab5080c4ccd13e53b0676ce10b2e0701833fdb24061
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.3-cp313-cp313-win_amd64.whl

Download URL pylgen_core-0.6.3-cp313-cp313-win_amd64.whl
Size 3.4 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
b3dad708008d07fe84ec7b5460aeeb577506f5147e635b159c4e5c493192e03a
BLAKE2b-256 checksum
How to use checksums
8ac6d32ef79c48068961483c6fcdae059f50a8777f7ef4c2cf09178bb2564b72
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.3-cp313-cp313-musllinux_1_2_x86_64.whl

Download URL pylgen_core-0.6.3-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
30df4160cc4842ba8d9440e9d307f41a80bd16ce2f9726a6112ff1dd72fe8c68
BLAKE2b-256 checksum
How to use checksums
d20a212b95877a95a49d02495520c838848f0bcab0fa59d26543e78d2160daa3
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.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pylgen_core-0.6.3-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
92af85c5be3e5469f387ade0c629873fe46015394376eed8df0ececbe8269004
BLAKE2b-256 checksum
How to use checksums
0c0f4839a915225fabb415e4663500ea3484ece97a7536c98654c29ce0f9ad6c
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.3-cp313-cp313-macosx_11_0_arm64.whl

Download URL pylgen_core-0.6.3-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
71cdd4a44be82592267d3da1b9357cd2968cba0801204fefcc8ffa317ee9db33
BLAKE2b-256 checksum
How to use checksums
032e8a2f1f8d3fd2478dfb63afc7b90b8356cc6f548dfe85e218b0fad6806c1f
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.3-cp313-cp313-macosx_10_13_x86_64.whl

Download URL pylgen_core-0.6.3-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
218fe4cb1e375ce8d844f2cfbff8922530db19ea4c00bd3e5fe2a2d05a457af8
BLAKE2b-256 checksum
How to use checksums
ac12699450f2fea60f36baa4d0e834a0cc6cf42d6df8e838011e45165175f6f1
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.3-cp312-cp312-win_amd64.whl

Download URL pylgen_core-0.6.3-cp312-cp312-win_amd64.whl
Size 3.4 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
d621fb9c644724565c9637a08ff76087e999d03222c967852592e32f07bb71dc
BLAKE2b-256 checksum
How to use checksums
540c7f3434812d898dd3b147fea4a9df0d8b8e81ddcd0afc76acd37ddd51b374
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.3-cp312-cp312-musllinux_1_2_x86_64.whl

Download URL pylgen_core-0.6.3-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
38ad5d6cc916ad4f9086174e22f0b50947893d40dbecfafd2222873f13d616a7
BLAKE2b-256 checksum
How to use checksums
43041572ed0e4d0d5c768c77a9f49557c649cdb4d0d31ab644de5c3e26db7a8a
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.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pylgen_core-0.6.3-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
94b95768026a6a608ff1a3c3d49d844af9d9e3c94ae7f3a40604ba5b2b141eae
BLAKE2b-256 checksum
How to use checksums
3e428b5a683039aaf45bf0985ed52cd0da2abf9d9caeff8c0c58143349a785b9
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.3-cp312-cp312-macosx_11_0_arm64.whl

Download URL pylgen_core-0.6.3-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
7a3f94faa8e52c499a1031d94dbc76dd441d94a4535013a1341dcc84d60f416a
BLAKE2b-256 checksum
How to use checksums
d938f624f80a42692810d8eacc25515b141633b5a66ed63e4e2063909fce2829
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.3-cp312-cp312-macosx_10_13_x86_64.whl

Download URL pylgen_core-0.6.3-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
ddcada323250b409b451489e3432f35000ae16c29e1af150cf3b0bb382b80bc8
BLAKE2b-256 checksum
How to use checksums
4916e48ce21ec706b8a0733f67774569d65497a29a6b746c3b59b63a09c222d0
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

This release

0.6.3 This release

16 release files

0.6.1

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