# Install peg with Homebrew, apk, apt, MacPorts, Nix, pacman, zypper

Program to perform pattern matching on text. Version 0.1.19 via Homebrew; verified 2026-06-14.

## Install

```sh
sudo av install brew:peg
```

Additional install commands:

### macOS

- Homebrew (100%):

```sh
brew install peg
```

  Evidence: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install peg
```

  Evidence: MacPorts ports tree: devel/peg/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- apk (92%):

```sh
sudo apk add peg
```

  Evidence: Alpine Linux edge package indexes: peg from https://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz

- Debian apt (92%):

```sh
sudo apt install peg
```

  Evidence: Debian stable package indexes: peg from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz

- Nix (92%):

```sh
nix profile install nixpkgs#peg
```

  Evidence: nixpkgs package indexes: pkgs/by-name/pe/peg/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

- pacman (92%):

```sh
sudo pacman -S peg
```

  Evidence: Arch Linux sync databases: peg from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz

- zypper (92%):

```sh
sudo zypper install peg
```

  Evidence: openSUSE Tumbleweed package metadata: peg from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst

## Package facts

- **Package key:** brew:peg
- **Package manager:** Homebrew
- **Package manager page:** <https://formulae.brew.sh/formula/peg>
- **Version:** 0.1.19
- **Source summary:** Program to perform pattern matching on text
- **Homepage:** <https://www.piumarta.com/software/peg/>
- **Upstream docs:** <https://www.piumarta.com/software/peg>
- **License:** MIT
- **Source archive:** <https://www.piumarta.com/software/peg/peg-0.1.19.tar.gz>
- **Last updated:** 2026-06-14T14:47:59+02:00
- **Generated:** 2026-07-08T07:18:31+00:00

## Executables

- leg (cli)
- peg (cli)
- leg (alias)
- peg (alias)

## Install behavior

- Post-install hook: not defined
- Bottle: available on arm64_linux, arm64_monterey, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, monterey, sonoma, ventura, x86_64_linux

## Freshness

- Page generated: 2026-07-08
- Package-manager version: 0.1.19
- Package-manager updated: 2026-06-14
- Local data: ok
- Upstream repository: https://www.piumarta.com/software/peg/
- info: Release/tag comparison is only available for GitHub repositories.
## Project history and usage

peg and leg are recursive-descent parser generators for C. They process Parsing Expression Grammars and generate C parsers, with `peg` following Bryan Ford's original PEG syntax and `leg` using conventions intended as an alternative to lex and yacc.

### Project history

Ian Piumarta's official page lists peg/leg as tools for generating recursive-descent parsers from Parsing Expression Grammars. The first public release in the official version history is 0.1.1 on 2007-05-15.

The manual page explains that peg reads grammar files or standard input and generates C source defining `yyparse()`, while leg uses a syntax intended to make it attractive to users familiar with lex and yacc workflows.

The official version history shows steady maintenance through 0.1.19 stable in 2023, including reentrant parsing support, error actions, UTF-8 fixes, C++ support improvements, and Windows/Mac build files.

### Adoption history

peg/leg spread through Unix-like package managers as a small C parser-generation tool: the input metadata lists Homebrew, Debian, Ubuntu, Arch, MacPorts, Nix, Alpine, and openSUSE package names.

Its niche is smaller than yacc-family tools, but it remains useful where a project wants PEG-style ordered choice, unlimited backtracking, and combined scanning and parsing in generated C.

### How it is used

Typical use is to run `peg` or `leg` over a grammar file and compile or include the generated C source in a client program.

The official manual documents options such as `-o` for output file selection, `-P` for suppressing `#line` directives, `-v` for verbose mode, and `-V` for version output.

### Why package nerds care

peg/leg is package-manager-friendly because it is a compact C command-line tool with a stable manual page, source tarballs, and a long version history.

For package nerds it is also a useful contrast with lex/yacc: a small PEG-based generator that produces embeddable C parsers without requiring a larger parser framework.

### Timeline

- 2007-05-15: First public release, 0.1.1.
- 2013-06-03: 0.1.11 added error actions, C++ support improvements, and Win32/Mac build files.
- 2016-07-22: 0.1.18 added the `-P` option to disable `#line` directives.
- 2023-03-06: 0.1.19 stable added experimental re-entrant parsing through `yyparsefrom_r()`.
- 2023-11-19: 0.1.20 development version listed with experimental inline-action variables and semantic values.

### Related projects

- Bryan Ford's 2004 Parsing Expression Grammars paper is the formal grammar reference cited by the official page.
- lex and yacc are the comparison point used by the official page and manual.

### Sources

- <https://www.piumarta.com/software/peg>
- <https://www.piumarta.com/software/peg/peg.1.html>
- source_facts.package-manager


## Security Notes

narrow executable package without higher-risk signals.

- **Geiger risk:** green / low
- narrow executable package without higher-risk signals

## Source Database Details

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** peg
- **Aliases:** leg
- **Version Scheme:** 0
- **Revision:** 0
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** no
- **URL Keys:** stable

## Other Package-Manager Records

- Debian apt - peg - 0.1.20+really0.1.18-1: normalized package name match | Debian stable package indexes: peg from https://deb.debian.org/debian/dists/stable/main/binary-amd64/Packages.xz | recursive-descent parser generators for C | https://piumarta.com/software/peg/
- Nix - peg: normalized package name match | nixpkgs package indexes: pkgs/by-name/pe/peg/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- Ubuntu apt - peg - 0.1.18-1build1: normalized package name match | Ubuntu 24.04 LTS package indexes: peg from https://archive.ubuntu.com/ubuntu/dists/noble/universe/binary-amd64/Packages.gz | recursive-descent parser generators for C | http://piumarta.com/software/peg/
- apk - peg - 0.1.18-r1: normalized package name match | Alpine Linux edge package indexes: peg from https://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz | Recursive-descent parser generators for C | https://www.piumarta.com/software/peg/
- apk - peg-doc - 0.1.18-r1: normalized package name match | Alpine Linux edge package indexes: peg-doc from https://dl-cdn.alpinelinux.org/alpine/edge/testing/x86_64/APKINDEX.tar.gz | Recursive-descent parser generators for C (documentation) | https://www.piumarta.com/software/peg/
- pacman - peg - 0.1.19-1: normalized package name match | Arch Linux sync databases: peg from https://geo.mirror.pkgbuild.com/extra/os/x86_64/extra.db.tar.gz | recursive-descent parser generators for C | http://piumarta.com/software/peg/
- zypper - peg - 0.1.20-1.7: normalized package name match | openSUSE Tumbleweed package metadata: peg from https://download.opensuse.org/tumbleweed/repo/oss/repodata/be8d3611d25469107f32075a1697e69ec57a2b850b42348a658cc671ad5ec2b50760d02c3e59524d50da9a11d5be799bdaffba2e166e8ca8858512e3c0bd665d-primary.xml.zst | Recursive-Descent parser generators for C | https://piumarta.com/software/peg/
- MacPorts - peg: normalized package name match | MacPorts ports tree: devel/peg/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1


## Related links

- [Terminal utility packages](https://www.automicvault.com/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://www.automicvault.com/pkg/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://www.automicvault.com/pkg/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [Language runtime packages](https://www.automicvault.com/pkg/language-runtime-packages/) - Matched language runtime, compiler, or interpreter metadata.
- [ngs](https://www.automicvault.com/pkg/brew/ngs/) - Popular package that depends on this formula.
- [byacc](https://www.automicvault.com/pkg/brew/byacc/) - Shares av.db curated category or tags: c, cli, compiler-tools, developer-tools, parser-generator.
- [menhir](https://www.automicvault.com/pkg/brew/menhir/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools, parser-generator.
- [javacc](https://www.automicvault.com/pkg/brew/javacc/) - Shares av.db curated category or tags: cli, developer-tools, parser-generator.
- [packcc](https://www.automicvault.com/pkg/brew/packcc/) - Shares av.db curated category or tags: c, cli, developer-tools, parser-generator, peg.
- [tree-sitter-cli](https://www.automicvault.com/pkg/brew/tree-sitter-cli/) - Shares av.db curated category or tags: cli, developer-tools, parser-generator.
- [bison](https://www.automicvault.com/pkg/brew/bison/) - Shares av.db curated category or tags: cli, compiler-tools, developer-tools, parser-generator.
- [mcpp](https://www.automicvault.com/pkg/brew/mcpp/) - Shares av.db curated category or tags: c, cli, compiler-tools, developer-tools.
- [peg-markdown](https://www.automicvault.com/pkg/brew/peg-markdown/) - Shares av.db curated category or tags: c, cli, developer-tools, peg.

## Combined YAML source

View the package source record on GitHub. [combined/peg.yml](https://github.com/automic-vault/db/blob/main/combined/peg.yml)


## Sources

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
