# 使用 Homebrew, apk, apt, MacPorts, Nix, pacman, zypper 安装 peg

查看 peg 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

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

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install peg
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install peg
```

  证据: 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
```

  证据: 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
```

  证据: 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
```

  证据: 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
```

  证据: 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
```

  证据: openSUSE Tumbleweed package metadata: peg from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-primary.xml.zst

## 软件包事实

- **软件包键:** brew:peg
- **软件包管理器:** Homebrew
- **版本:** 0.1.19
- **来源摘要:** Program to perform pattern matching on text
- **主页:** <https://www.piumarta.com/software/peg/>
- **最后更新:** 2026-06-14T14:47:59+02:00
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- leg (别名)
- peg (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 0.1.19
## 项目历史与用法

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.

### 项目历史

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.

### 采用历史

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.

### 使用方式

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.

### 为什么软件包爱好者会关心

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.

### 时间线

- 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.

### 来源

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


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 其他软件包管理器记录

- 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.9: normalized package name match | openSUSE Tumbleweed package metadata: peg from https://download.opensuse.org/tumbleweed/repo/oss/repodata/50b07339cb64c8ed4091bdbabddadc1ff5737b090e478818a195b40d8a3292861a879139b4a3987c31109699fde9fbf4a716367ddf4eef77da75f96e3193d6ed-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


## Combined YAML source

View the package source record on GitHub. [combined/peg.yml](https://github.com/mxcl/pkgdb/blob/main/combined/peg.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
