bp/Lua
2021-09-24 23:58:23 -07:00
..
lbp.c Overhaul of lua API to use tables 2021-09-24 22:55:39 -07:00
Makefile Added builtins for lua library 2021-09-23 21:19:39 -07:00
README.md Updated readme 2021-09-24 23:58:23 -07:00
test.lua Overhaul of lua API to use tables 2021-09-24 22:55:39 -07:00

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.

API

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"