This content originally appeared on DEV Community and was authored by Pʀᴀɴᴀá´
What is PegLang?
PegLang is an experimental language where Parsing Expression Grammars (PEGs) are not just used to parse input—they are the language. Instead of writing instructions in a traditional syntax, the program is expressed as grammar rules, and execution occurs as the parser processes text, symbols, or patterns.
PegLang blurs the line between interpreter, parser, and program, making code look more like formal grammar definitions than typical logic flow.
Specs
Language Type: Grammar-driven / PEG-based esolang
Era: ~2015–2022 language research phase
Execution Model: Matching and transforming input streams
Paradigm: Declarative, pattern-driven programming
Typing: Implicit — structure determined by grammar rules
Example Code (Hello World)
A minimal example may look like:
Start <- "Hello, PegLang!"
Execution prints or outputs the matched literal when the program is run with no input stream.
A more dynamic sample:
Digit <- [0-9]
Number <- Digit+
Print <- Number { print }
Depending on interpreter support, this prints any numeric input fed into the engine.
How It Works
PegLang programs consist of production rules similar to:
This content originally appeared on DEV Community and was authored by Pʀᴀɴᴀá´
Pʀᴀɴᴀᴠ| Sciencx (2025-11-28T19:02:57+00:00) 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic. Retrieved from https://www.scien.cx/2025/11/28/%f0%9f%a7%ac-peglang-a-language-built-on-parsing-expression-grammars-as-executable-logic/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.