Janet 1.38.0-73334f3 Documentation
(Other Versions: 1.37.1 1.36.0 1.35.0 1.34.0 1.31.0 1.29.1 1.28.0 1.27.0 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


peg/compile cfunction source

(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 supplement the grammar of the peg for otherwise undefined peg keywords.

Community Examples

peg/find cfunction source

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

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

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

(peg/replace peg subst text &opt start & args)

Replace first match of peg in text with subst, returning a new buffer. The peg does not need to make captures to do replacement. If subst is a function, it will be called with the matching text followed by any captures. If no matches are found, returns the input string in a new buffer.

Community Examples

peg/replace-all cfunction source

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

Replace all matches of peg in text with subst, returning a new buffer. The peg does not need to make captures to do replacement. If subst is a function, it will be called with the matching text followed by any captures.

Community Examples