aboutsummaryrefslogtreecommitdiff
path: root/Lua/README.md
blob: f58e952dcb72755adf48c4e7c4138bc454e28d06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Lua Bindings

This directory contains Lua bindings for bp. The bindings are intended to be
roughly equivalent in usefulness to LPEG, but with a smaller codebase (roughly
3/4 the size, as of this writing).

## API

```lua
local bp = require("bp")
local m, i, len = bp.match("like finding a needle in a haystack", '"n" @Es=+`e "dle"')
--> {[0]="needle", Es={[0]="ee"}}
--> tostring(m) == "needle", tostring(m.Es) == "ee"
local replaced = bp.match("like finding a needle in a haystack", '"n" +`e "dle"', "cat")
--> "like finding a cat in a haystack"
```