Janet 1.27.0-01aab66 Documentation
(Other Versions: 1.26.0 1.25.1 1.24.0 1.23.0 1.22.0 1.21.0 1.20.0 1.19.0 1.18.1 1.17.1 1.16.1 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

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 / source
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 / source
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 / source
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 / source
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 / source
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 / source