Skip to content

Commit

Permalink
Renaming "lpeglabelrec" to "lpeglabel", and "relabelrec" to "relabel"
Browse files Browse the repository at this point in the history
  • Loading branch information
sqmedeiros committed Dec 16, 2016
1 parent bbc6ec5 commit 1968c31
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 56 deletions.
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ Below there is a brief summary of the new functions provided by LpegLabel:

<table border="1">
<tbody><tr><td><b>Function</b></td><td><b>Description</b></td></tr>
<tr><td><a href="#f-t"><code>lpeglabelrec.T (l)</code></a></td>
<tr><td><a href="#f-t"><code>lpeglabel.T (l)</code></a></td>
<td>Throws a label <code>l</code> to signal an error</td></tr>
<tr><td><a href="#f-rec"><code>lpeglabelrec.Rec (p1, p2, l1 [, l2, ..., ln])</code></a></td>
<tr><td><a href="#f-rec"><code>lpeglabel.Rec (p1, p2, l1 [, l2, ..., ln])</code></a></td>
<td>Specifies a recovery pattern <code>p2</code> for <code>p1</code>,
when the matching of <code>p1</code> gives one of the labels l1, ..., ln.</td></tr>
<tr><td><a href="#re-t"><code>%{l}</code></a></td>
<td>Syntax of <em>relabelrec</em> module. Equivalent to <code>lpeglabelrec.T(l)</code>
<td>Syntax of <em>relabel</em> module. Equivalent to <code>lpeglabel.T(l)</code>
</td></tr>
<tr><td><a href="#re-rec"><code>p1 //{l1 [, l2, ..., ln} p2</code></a></td>
<td>Syntax of <em>relabelrec</em> module. Equivalent to <code>lpeglabelrec.Rec(p1, p2, l1, ..., ln)</code>
<td>Syntax of <em>relabel</em> module. Equivalent to <code>lpeglabel.Rec(p1, p2, l1, ..., ln)</code>
</td></tr>
<tr><td><a href="#re-line"><code>relabelrec.calcline(subject, i)</code></a></td>
<tr><td><a href="#re-line"><code>relabel.calcline(subject, i)</code></a></td>
<td>Calculates line and column information regarding position <i>i</i> of the subject</code>
</td></tr>
<tr><td><a href="#re-setl"><code>relabelrec.setlabels (tlabel)</code></a></td>
<tr><td><a href="#re-setl"><code>relabel.setlabels (tlabel)</code></a></td>
<td>Allows to specicify a table with mnemonic labels.
</td></tr>
</tbody></table>
Expand All @@ -58,14 +58,14 @@ Below there is a brief summary of the new functions provided by LpegLabel:
### Functions


#### <a name="f-t"></a><code>lpeglabelrec.T(l)</code>
#### <a name="f-t"></a><code>lpeglabel.T(l)</code>


Returns a pattern that throws the label `l`.
A label must be an integer between 1 and 255.


#### <a name="f-rec"></a><code>lpeglabelrec.Rec(p1, p2, l1, ..., ln)</code>
#### <a name="f-rec"></a><code>lpeglabel.Rec(p1, p2, l1, ..., ln)</code>

Returns a *recovery pattern*.
If the matching of `p1` gives one of the labels `l1, ..., ln`,
Expand All @@ -76,23 +76,23 @@ Otherwise, the result of the matching of `p1` is the pattern's result.

#### <a name="re-t"></a><code>%{l}</code>

Syntax of *relabelrec* module. Equivalent to `lpeg.T(l)`.
Syntax of *relabel* module. Equivalent to `lpeg.T(l)`.


#### <a name="re-lc"></a><code>p1 //{l1, ..., ln} p2</code>

Syntax of *relabelrec* module. Equivalent to `lpeglabelrec.Rec(p1, p2, l1, ..., ln)`.
Syntax of *relabel* module. Equivalent to `lpeglabel.Rec(p1, p2, l1, ..., ln)`.

The `//{}` operator is left-associative.



#### <a name="re-line"></a><code>relabelrec.calcline (subject, i)</code>
#### <a name="re-line"></a><code>relabel.calcline (subject, i)</code>

Returns line and column information regarding position <i>i</i> of the subject.


#### <a name="re-setl"></a><code>relabelrec.setlabels (tlabel)</code>
#### <a name="re-setl"></a><code>relabel.setlabels (tlabel)</code>

Allows to specicify a table with labels. They keys of
`tlabel` must be integers between 1 and 255,
Expand All @@ -118,8 +118,8 @@ table and to return the index associated with each error message.


```lua
local m = require'lpeglabelrec'
local re = require'relabelrec'
local m = require'lpeglabel'
local re = require'relabel'

local terror = {}

Expand Down Expand Up @@ -176,7 +176,7 @@ the <em>regular</em> matching. For example, in the example below
we expect to match rule `A`, but when a failure occur the label 42
is thrown and then we will try to match the recovery pattern `recp`:
```lua
local m = require'lpeglabelrec'
local m = require'lpeglabel'

local recp = m.P"oast"

Expand Down Expand Up @@ -223,8 +223,8 @@ When the matching of an identifier fails, a defaul value ('NONE')
is provided.

```lua
local m = require'lpeglabelrec'
local re = require'relabelrec'
local m = require'lpeglabel'
local re = require'relabel'

local terror = {}

Expand Down Expand Up @@ -311,14 +311,14 @@ print(mymatch(grec, "one\n two123, \nthree,"))
-- Error at line 3 (col 6): expecting an identifier
```

##### *relabelrec* syntax
##### *relabel* syntax

Below we describe again a grammar that matches a list of identifiers,
now using the syntax supported by *relabelrec*, where `//{}` is the
now using the syntax supported by *relabel*, where `//{}` is the
recovery operator, and `%{}` is the throw operator:

```lua
local re = require 'relabelrec'
local re = require 'relabel'

local errinfo = {
{"errUndef", "undefined"},
Expand Down Expand Up @@ -428,8 +428,8 @@ task to build manually the recovery grammar `grec`. In the next example
we will show how to build the recovery grammar in a more automatic way.

```lua
local m = require"lpeglabelrec"
local re = require"relabelrec"
local m = require"lpeglabel"
local re = require"relabel"

local labels = {
{"ExpTermFirst", "expected an expression"},
Expand Down Expand Up @@ -566,8 +566,8 @@ In the example below we also throw an error when the grammar
does not match the whole subject.

```lua
local m = require"lpeglabelrec"
local re = require"relabelrec"
local m = require"lpeglabel"
local re = require"relabel"

local num = m.R("09")^1 / tonumber
local op = m.S("+-")
Expand Down
4 changes: 2 additions & 2 deletions examples/expRec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = require"lpeglabelrec"
local re = require"relabelrec"
local m = require"lpeglabel"
local re = require"relabel"

local labels = {
{"ExpTermFirst", "expected an expression"},
Expand Down
4 changes: 2 additions & 2 deletions examples/expRecAut.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = require"lpeglabelrec"
local re = require"relabelrec"
local m = require"lpeglabel"
local re = require"relabel"

local num = m.R("09")^1 / tonumber
local op = m.S("+-")
Expand Down
4 changes: 2 additions & 2 deletions examples/listId1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = require'lpeglabelrec'
local re = require'relabelrec'
local m = require'lpeglabel'
local re = require'relabel'

local id = m.R'az'^1

Expand Down
4 changes: 2 additions & 2 deletions examples/listId2.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = require'lpeglabelrec'
local re = require'relabelrec'
local m = require'lpeglabel'
local re = require'relabel'

local terror = {}

Expand Down
4 changes: 2 additions & 2 deletions examples/listId2Rec2.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = require'lpeglabelrec'
local re = require'relabelrec'
local m = require'lpeglabel'
local re = require'relabel'

local terror = {}

Expand Down
4 changes: 2 additions & 2 deletions examples/listId2Rec2Cap.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local m = require'lpeglabelrec'
local re = require'relabelrec'
local m = require'lpeglabel'
local re = require'relabel'

local terror = {}

Expand Down
2 changes: 1 addition & 1 deletion examples/listIdRe1.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local re = require 'relabelrec'
local re = require 'relabel'

local g = re.compile[[
S <- Id List
Expand Down
2 changes: 1 addition & 1 deletion examples/listIdRe2.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local re = require 'relabelrec'
local re = require 'relabel'

local errinfo = {
{"errUndef", "undefined"},
Expand Down
2 changes: 1 addition & 1 deletion examples/tiny.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local re = require 'relabelrec'
local re = require 'relabel'

local terror = {}

Expand Down
2 changes: 1 addition & 1 deletion examples/typedlua/tllexer.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local tllexer = {}

local lpeg = require "lpeglabelrec"
local lpeg = require "lpeglabel"
lpeg.locale(lpeg)

local tlerror = require "tlerror"
Expand Down
2 changes: 1 addition & 1 deletion examples/typedlua/tlparser.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local tlparser = {}

local lpeg = require "lpeglabelrec"
local lpeg = require "lpeglabel"
lpeg.locale(lpeg)

local tllexer = require "tllexer"
Expand Down
4 changes: 2 additions & 2 deletions lptree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1348,8 +1348,8 @@ static struct luaL_Reg metareg[] = {
};


int luaopen_lpeglabelrec (lua_State *L); /* labeled failure */
int luaopen_lpeglabelrec (lua_State *L) { /* labeled failure */
int luaopen_lpeglabel (lua_State *L); /* labeled failure */
int luaopen_lpeglabel (lua_State *L) { /* labeled failure */
luaL_newmetatable(L, PATTERN_T);
lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */
lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX);
Expand Down
14 changes: 7 additions & 7 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LIBNAME = lpeglabelrec
LIBNAME = lpeglabel
LUADIR = ../lua/

COPT = -O2
Expand Down Expand Up @@ -29,24 +29,24 @@ FILES = lpvm.o lpcap.o lptree.o lpcode.o lpprint.o

# For Linux
linux:
make lpeglabelrec.so "DLLFLAGS = -shared -fPIC"
make lpeglabel.so "DLLFLAGS = -shared -fPIC"

# For Mac OS
macosx:
make lpeglabelrec.so "DLLFLAGS = -bundle -undefined dynamic_lookup"
make lpeglabel.so "DLLFLAGS = -bundle -undefined dynamic_lookup"

lpeglabelrec.so: $(FILES)
env $(CC) $(DLLFLAGS) $(FILES) -o lpeglabelrec.so
lpeglabel.so: $(FILES)
env $(CC) $(DLLFLAGS) $(FILES) -o lpeglabel.so

$(FILES): makefile

test: test.lua testlabel.lua testerrors.lua relabel.lua lpeglabelrec.so
test: test.lua testlabel.lua testerrors.lua relabel.lua lpeglabel.so
lua test.lua
lua testlabel.lua
lua testerrors.lua

clean:
rm -f $(FILES) lpeglabelrec.so
rm -f $(FILES) lpeglabel.so


lpcap.o: lpcap.c lpcap.h lptypes.h
Expand Down
2 changes: 1 addition & 1 deletion relabel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local pcall = pcall
local setmetatable = setmetatable
local unpack, tinsert, concat = table.unpack or unpack, table.insert, table.concat
local rep = string.rep
local m = require"lpeglabelrec"
local m = require"lpeglabel"

-- 'm' will be used to parse expressions, and 'mm' will be used to
-- create expressions; that is, 're' runs on 'm', creating patterns
Expand Down
4 changes: 2 additions & 2 deletions test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

-- require"strict" -- just to be pedantic

local m = require"lpeglabelrec"
local m = require"lpeglabel"


-- for general use
Expand Down Expand Up @@ -1110,7 +1110,7 @@ checkeq(t, {'a', 'aa', 20, 'a', 'aaa', 'aaa'})
-- Tests for 're' module
-------------------------------------------------------------------

local re = require "relabelrec"
local re = require "relabel"

local match, compile = re.match, re.compile

Expand Down
4 changes: 2 additions & 2 deletions testlabel.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local m = require 'lpeglabelrec'
local m = require 'lpeglabel'

local p, r, l, s, serror

Expand Down Expand Up @@ -363,7 +363,7 @@ assert(r == nil and l == 5 and serror == s)
print("+")


local re = require 'relabelrec'
local re = require 'relabel'

g = re.compile[['a' //{4,9} [a-z]
]]
Expand Down
2 changes: 1 addition & 1 deletion testrelabelparser.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local re = require 'relabelrec'
local re = require 'relabel'

function testerror(repatt, msg)
msg = msg:match("^%s*(.-)%s*$") -- trim
Expand Down

0 comments on commit 1968c31

Please sign in to comment.