Janet 1.16.1-87f8fe1 Documentation
(Other Versions: 1.15.0 1.13.1 1.12.2 1.11.1 1.10.1 1.9.1 1.8.1 1.7.0 1.6.0 1.5.1 1.5.0 1.4.0 1.3.1 )

PEG Module

See The peg documentation for more information.

Index

peg/compile peg/find peg/find-all peg/match peg/replace peg/replace-all


peg/compile cfunction
(peg/compile peg)

Compiles a peg source data structure into a <core/peg>. This will speed up matching if the same peg will be used multiple times. Will also use `(dyn :peg-grammar)` to suppliment the grammar of the peg for otherwise undefined peg keywords.
Community Examples

peg/find cfunction
(peg/find peg text &opt start & args)

Find first index where the peg matches in text. Returns an integer, or nil if not found.
Community Examples

peg/find-all cfunction
(peg/find-all peg text &opt start & args)

Find all indexes where the peg matches in text. Returns an array of integers.
Community Examples

peg/match cfunction
(peg/match peg text &opt start & args)

Match a Parsing Expression Grammar to a byte string and return an array of captured values. Returns nil if text does not match the language defined by peg. The syntax of PEGs is documented on the Janet website.
Community Examples

peg/replace cfunction
(peg/replace peg repl text &opt start & args)

Replace first match of peg in text with repl, returning a new buffer. The peg does not need to make captures to do replacement. If no matches are found, returns the input string in a new buffer.
Community Examples

peg/replace-all cfunction
(peg/replace-all peg repl text &opt start & args)

Replace all matches of peg in text with repl, returning a new buffer. The peg does not need to make captures to do replacement.
Community Examples