aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md48
1 files changed, 24 insertions, 24 deletions
diff --git a/README.md b/README.md
index 9bc162d..5deec35 100644
--- a/README.md
+++ b/README.md
@@ -35,21 +35,21 @@ Below there is a brief summary of the new functions provided by LpegLabel:
35 35
36<table border="1"> 36<table border="1">
37<tbody><tr><td><b>Function</b></td><td><b>Description</b></td></tr> 37<tbody><tr><td><b>Function</b></td><td><b>Description</b></td></tr>
38<tr><td><a href="#f-t"><code>lpeglabelrec.T (l)</code></a></td> 38<tr><td><a href="#f-t"><code>lpeglabel.T (l)</code></a></td>
39 <td>Throws a label <code>l</code> to signal an error</td></tr> 39 <td>Throws a label <code>l</code> to signal an error</td></tr>
40<tr><td><a href="#f-rec"><code>lpeglabelrec.Rec (p1, p2, l1 [, l2, ..., ln])</code></a></td> 40<tr><td><a href="#f-rec"><code>lpeglabel.Rec (p1, p2, l1 [, l2, ..., ln])</code></a></td>
41 <td>Specifies a recovery pattern <code>p2</code> for <code>p1</code>, 41 <td>Specifies a recovery pattern <code>p2</code> for <code>p1</code>,
42 when the matching of <code>p1</code> gives one of the labels l1, ..., ln.</td></tr> 42 when the matching of <code>p1</code> gives one of the labels l1, ..., ln.</td></tr>
43<tr><td><a href="#re-t"><code>%{l}</code></a></td> 43<tr><td><a href="#re-t"><code>%{l}</code></a></td>
44 <td>Syntax of <em>relabelrec</em> module. Equivalent to <code>lpeglabelrec.T(l)</code> 44 <td>Syntax of <em>relabel</em> module. Equivalent to <code>lpeglabel.T(l)</code>
45 </td></tr> 45 </td></tr>
46<tr><td><a href="#re-rec"><code>p1 //{l1 [, l2, ..., ln} p2</code></a></td> 46<tr><td><a href="#re-rec"><code>p1 //{l1 [, l2, ..., ln} p2</code></a></td>
47 <td>Syntax of <em>relabelrec</em> module. Equivalent to <code>lpeglabelrec.Rec(p1, p2, l1, ..., ln)</code> 47 <td>Syntax of <em>relabel</em> module. Equivalent to <code>lpeglabel.Rec(p1, p2, l1, ..., ln)</code>
48 </td></tr> 48 </td></tr>
49<tr><td><a href="#re-line"><code>relabelrec.calcline(subject, i)</code></a></td> 49<tr><td><a href="#re-line"><code>relabel.calcline(subject, i)</code></a></td>
50 <td>Calculates line and column information regarding position <i>i</i> of the subject</code> 50 <td>Calculates line and column information regarding position <i>i</i> of the subject</code>
51 </td></tr> 51 </td></tr>
52<tr><td><a href="#re-setl"><code>relabelrec.setlabels (tlabel)</code></a></td> 52<tr><td><a href="#re-setl"><code>relabel.setlabels (tlabel)</code></a></td>
53 <td>Allows to specicify a table with mnemonic labels. 53 <td>Allows to specicify a table with mnemonic labels.
54 </td></tr> 54 </td></tr>
55</tbody></table> 55</tbody></table>
@@ -58,14 +58,14 @@ Below there is a brief summary of the new functions provided by LpegLabel:
58### Functions 58### Functions
59 59
60 60
61#### <a name="f-t"></a><code>lpeglabelrec.T(l)</code> 61#### <a name="f-t"></a><code>lpeglabel.T(l)</code>
62 62
63 63
64Returns a pattern that throws the label `l`. 64Returns a pattern that throws the label `l`.
65A label must be an integer between 1 and 255. 65A label must be an integer between 1 and 255.
66 66
67 67
68#### <a name="f-rec"></a><code>lpeglabelrec.Rec(p1, p2, l1, ..., ln)</code> 68#### <a name="f-rec"></a><code>lpeglabel.Rec(p1, p2, l1, ..., ln)</code>
69 69
70Returns a *recovery pattern*. 70Returns a *recovery pattern*.
71If the matching of `p1` gives one of the labels `l1, ..., ln`, 71If the matching of `p1` gives one of the labels `l1, ..., ln`,
@@ -76,23 +76,23 @@ Otherwise, the result of the matching of `p1` is the pattern's result.
76 76
77#### <a name="re-t"></a><code>%{l}</code> 77#### <a name="re-t"></a><code>%{l}</code>
78 78
79Syntax of *relabelrec* module. Equivalent to `lpeg.T(l)`. 79Syntax of *relabel* module. Equivalent to `lpeg.T(l)`.
80 80
81 81
82#### <a name="re-lc"></a><code>p1 //{l1, ..., ln} p2</code> 82#### <a name="re-lc"></a><code>p1 //{l1, ..., ln} p2</code>
83 83
84Syntax of *relabelrec* module. Equivalent to `lpeglabelrec.Rec(p1, p2, l1, ..., ln)`. 84Syntax of *relabel* module. Equivalent to `lpeglabel.Rec(p1, p2, l1, ..., ln)`.
85 85
86The `//{}` operator is left-associative. 86The `//{}` operator is left-associative.
87 87
88 88
89 89
90#### <a name="re-line"></a><code>relabelrec.calcline (subject, i)</code> 90#### <a name="re-line"></a><code>relabel.calcline (subject, i)</code>
91 91
92Returns line and column information regarding position <i>i</i> of the subject. 92Returns line and column information regarding position <i>i</i> of the subject.
93 93
94 94
95#### <a name="re-setl"></a><code>relabelrec.setlabels (tlabel)</code> 95#### <a name="re-setl"></a><code>relabel.setlabels (tlabel)</code>
96 96
97Allows to specicify a table with labels. They keys of 97Allows to specicify a table with labels. They keys of
98`tlabel` must be integers between 1 and 255, 98`tlabel` must be integers between 1 and 255,
@@ -118,8 +118,8 @@ table and to return the index associated with each error message.
118 118
119 119
120```lua 120```lua
121local m = require'lpeglabelrec' 121local m = require'lpeglabel'
122local re = require'relabelrec' 122local re = require'relabel'
123 123
124local terror = {} 124local terror = {}
125 125
@@ -176,7 +176,7 @@ the <em>regular</em> matching. For example, in the example below
176we expect to match rule `A`, but when a failure occur the label 42 176we expect to match rule `A`, but when a failure occur the label 42
177is thrown and then we will try to match the recovery pattern `recp`: 177is thrown and then we will try to match the recovery pattern `recp`:
178```lua 178```lua
179local m = require'lpeglabelrec' 179local m = require'lpeglabel'
180 180
181local recp = m.P"oast" 181local recp = m.P"oast"
182 182
@@ -223,8 +223,8 @@ When the matching of an identifier fails, a defaul value ('NONE')
223is provided. 223is provided.
224 224
225```lua 225```lua
226local m = require'lpeglabelrec' 226local m = require'lpeglabel'
227local re = require'relabelrec' 227local re = require'relabel'
228 228
229local terror = {} 229local terror = {}
230 230
@@ -311,14 +311,14 @@ print(mymatch(grec, "one\n two123, \nthree,"))
311-- Error at line 3 (col 6): expecting an identifier 311-- Error at line 3 (col 6): expecting an identifier
312``` 312```
313 313
314##### *relabelrec* syntax 314##### *relabel* syntax
315 315
316Below we describe again a grammar that matches a list of identifiers, 316Below we describe again a grammar that matches a list of identifiers,
317now using the syntax supported by *relabelrec*, where `//{}` is the 317now using the syntax supported by *relabel*, where `//{}` is the
318recovery operator, and `%{}` is the throw operator: 318recovery operator, and `%{}` is the throw operator:
319 319
320```lua 320```lua
321local re = require 'relabelrec' 321local re = require 'relabel'
322 322
323local errinfo = { 323local errinfo = {
324 {"errUndef", "undefined"}, 324 {"errUndef", "undefined"},
@@ -428,8 +428,8 @@ task to build manually the recovery grammar `grec`. In the next example
428we will show how to build the recovery grammar in a more automatic way. 428we will show how to build the recovery grammar in a more automatic way.
429 429
430```lua 430```lua
431local m = require"lpeglabelrec" 431local m = require"lpeglabel"
432local re = require"relabelrec" 432local re = require"relabel"
433 433
434local labels = { 434local labels = {
435 {"ExpTermFirst", "expected an expression"}, 435 {"ExpTermFirst", "expected an expression"},
@@ -566,8 +566,8 @@ In the example below we also throw an error when the grammar
566does not match the whole subject. 566does not match the whole subject.
567 567
568```lua 568```lua
569local m = require"lpeglabelrec" 569local m = require"lpeglabel"
570local re = require"relabelrec" 570local re = require"relabel"
571 571
572local num = m.R("09")^1 / tonumber 572local num = m.R("09")^1 / tonumber
573local op = m.S("+-") 573local op = m.S("+-")