Parglare
A pure Python LR/GLR parser - http://www.igordejanovic.net/parglare/
Install / Use
/learn @igordejanovic/ParglareREADME

A pure Python scannerless LR/GLR parser.
For more information see the docs.
Quick intro
This is just a small example to get the general idea. This example shows how to parse and evaluate expressions with 5 operations with different priority and associativity. Evaluation is done using semantic/reduction actions.
The whole expression evaluator is done in under 30 lines of code!
from parglare import Parser, Grammar
grammar = r"""
E: E '+' E {left, 1}
| E '-' E {left, 1}
| E '*' E {left, 2}
| E '/' E {left, 2}
| E '^' E {right, 3}
| '(' E ')'
| number;
terminals
number: /\d+(\.\d+)?/;
"""
actions = {
"E": [lambda _, n: n[0] + n[2],
lambda _, n: n[0] - n[2],
lambda _, n: n[0] * n[2],
lambda _, n: n[0] / n[2],
lambda _, n: n[0] ** n[2],
lambda _, n: n[1],
lambda _, n: n[0]],
"number": lambda _, value: float(value),
}
g = Grammar.from_string(grammar)
parser = Parser(g, debug=True, actions=actions)
result = parser.parse("34 + 4.6 / 2 * 4^2^2 + 78")
print("Result = ", result)
# Output
# -- Debugging/tracing output with detailed info about grammar, productions,
# -- terminals and nonterminals, DFA states, parsing progress,
# -- and at the end of the output:
# Result = 700.8
Installation
-
Stable version:
$ pip install parglare -
Development:
Install just.
$ git clone git@github.com:igordejanovic/parglare.git $ cd parglare $ just dev
Citing parglare
If you use parglare in your research please cite this paper:
Igor Dejanović, Parglare: A LR/GLR parser for Python,
Science of Computer Programming, issn:0167-6423, p.102734,
DOI:10.1016/j.scico.2021.102734, 2021.
@article{dejanovic2021b,
author = {Igor Dejanović},
title = {Parglare: A LR/GLR parser for Python},
doi = {10.1016/j.scico.2021.102734},
issn = {0167-6423},
journal = {Science of Computer Programming},
keywords = {parsing, LR, GLR, Python, visualization},
pages = {102734},
url = {https://www.sciencedirect.com/science/article/pii/S0167642321001271},
year = {2021}
}
License
MIT
Python versions
Tested with 3.8-3.14
Credits
Initial layout/content of this package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Related Skills
node-connect
338.7kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
claude-opus-4-5-migration
83.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
frontend-design
83.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
model-usage
338.7kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
