🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic

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 gramma…


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ʀᴀɴᴀᴠ


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic." Pʀᴀɴᴀᴠ | Sciencx - Friday November 28, 2025, https://www.scien.cx/2025/11/28/%f0%9f%a7%ac-peglang-a-language-built-on-parsing-expression-grammars-as-executable-logic/
HARVARD
Pʀᴀɴᴀᴠ | Sciencx Friday November 28, 2025 » 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic., viewed ,<https://www.scien.cx/2025/11/28/%f0%9f%a7%ac-peglang-a-language-built-on-parsing-expression-grammars-as-executable-logic/>
VANCOUVER
Pʀᴀɴᴀᴠ | Sciencx - » 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/28/%f0%9f%a7%ac-peglang-a-language-built-on-parsing-expression-grammars-as-executable-logic/
CHICAGO
" » 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic." Pʀᴀɴᴀᴠ | Sciencx - Accessed . https://www.scien.cx/2025/11/28/%f0%9f%a7%ac-peglang-a-language-built-on-parsing-expression-grammars-as-executable-logic/
IEEE
" » 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic." Pʀᴀɴᴀᴠ | Sciencx [Online]. Available: https://www.scien.cx/2025/11/28/%f0%9f%a7%ac-peglang-a-language-built-on-parsing-expression-grammars-as-executable-logic/. [Accessed: ]
rf:citation
» 🧬 PegLang — A Language Built on Parsing Expression Grammars as Executable Logic | Pʀᴀɴᴀᴠ | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.