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:
Top comments (0)