The first production is the default start rule. Literals, character classes, references, ordered choice, repetition, optionals, lookahead, and named symbols form the supported language. Whole-input parsing is the default; search mode finds successive non-overlapping matches. Imports compose rule modules with aliases, allowing a domain grammar to reuse shared lexical rules without name collisions.
This is a deliberately bounded grammar engine, not a promise to validate a full programming language. Undefined or duplicate rules, malformed expressions, empty repeated matches, and resource-intensive recursion are diagnosed. Named captures preserve locations and can continue through query composition or be emitted as ranges.
A grammar map can parse a tiny format too
The framework's CertUtil tool uses TextFamily to extract the digest from certutil -hashfile output. That output contains status text around a digest printed as separated byte pairs. CertUtil does not hand-parse lines with a custom loop or a one-off regex. It describes the line break, the byte pair, and the repeated byte sequence as a small grammar map, then asks TextFamily for the HashBytes rule's inner span. The same try-extract-text helper lowers the map to PEG and calls the textgrammar tool.
hash-output-grammar = {
Digest: 'newline HashBytes newline'
HashBytes: 'Byte ( @spc Byte )*'
Byte: '[0-9a-fA-F][0-9a-fA-F]'
newline: '@crlf / @lf / @cr'
}
{value: hash-output, error} = try-extract-text process.stdout, hash-output-grammar, 'grammar[name=HashBytes]:inner'
throw error if error isnt void
hash = (remove-hash-spacing (trim hash-output)).to-lower-case!
That is enough grammar to say “find a whole digest line, recognize its byte-pair sequence, and return only that span.” CertUtil then removes the displayed spaces, normalizes letter case, and uses the composable hexadecimal-character check plus a 32-character length check to validate MD5. TextFamily handles structure and provenance; the small value checks remain ordinary framework operations. A PEG is useful here precisely because the format is simple: the grammar stays visible and reusable instead of hiding the output shape inside parsing code.
textgrammar examples/assignments.txt /input:file /grammar:examples/assignments.peg /search /q:'grammar[name=Number]:inner' /plain /join:', '