diff options
author | sqmedeiros <sqmedeiros@gmail.com> | 2022-12-23 15:48:12 -0300 |
---|---|---|
committer | sqmedeiros <sqmedeiros@gmail.com> | 2022-12-23 15:48:12 -0300 |
commit | ff2dbe372a8759acb1c52bb6296ae7b0866180d5 (patch) | |
tree | 8be667d7d426368a24cca993f01b00d9d498d801 | |
parent | b5d7638608b4e0b65344c361fd4b8d65a742038f (diff) | |
download | lpeglabel-ff2dbe372a8759acb1c52bb6296ae7b0866180d5.tar.gz lpeglabel-ff2dbe372a8759acb1c52bb6296ae7b0866180d5.tar.bz2 lpeglabel-ff2dbe372a8759acb1c52bb6296ae7b0866180d5.zip |
Removing label ExpItem. Label MisClose8 signals a missing closing ']' or an empty char class
-rw-r--r-- | relabel.lua | 6 | ||||
-rw-r--r-- | testrelabelparser.lua | 38 |
2 files changed, 20 insertions, 24 deletions
diff --git a/relabel.lua b/relabel.lua index f4f4546..5190a98 100644 --- a/relabel.lua +++ b/relabel.lua | |||
@@ -56,8 +56,6 @@ local errinfo = { | |||
56 | 56 | ||
57 | ExpNameOrLab = "expected a name or label after '%' (no space)", | 57 | ExpNameOrLab = "expected a name or label after '%' (no space)", |
58 | 58 | ||
59 | ExpItem = "expected at least one item after '[' or '^'", | ||
60 | |||
61 | MisClose1 = "missing closing ')'", | 59 | MisClose1 = "missing closing ')'", |
62 | MisClose2 = "missing closing ':}'", | 60 | MisClose2 = "missing closing ':}'", |
63 | MisClose3 = "missing closing '~}'", | 61 | MisClose3 = "missing closing '~}'", |
@@ -67,7 +65,7 @@ local errinfo = { | |||
67 | MisClose6 = "missing closing '>'", | 65 | MisClose6 = "missing closing '>'", |
68 | MisClose7 = "missing closing '}'", -- for the labels | 66 | MisClose7 = "missing closing '}'", -- for the labels |
69 | 67 | ||
70 | MisClose8 = "missing closing ']'", | 68 | MisClose8 = "missing closing ']' or empty char class", |
71 | 69 | ||
72 | MisTerm1 = "missing terminating single quote", | 70 | MisTerm1 = "missing terminating single quote", |
73 | MisTerm2 = "missing terminating double quote", | 71 | MisTerm2 = "missing terminating double quote", |
@@ -187,7 +185,7 @@ local item = (defined + Range + m.C(any)) / m.P | |||
187 | local Class = | 185 | local Class = |
188 | "[" | 186 | "[" |
189 | * (m.C(m.P"^"^-1)) -- optional complement symbol | 187 | * (m.C(m.P"^"^-1)) -- optional complement symbol |
190 | * m.Cf(expect(item, "ExpItem") * (item - "]")^0, mt.__add) | 188 | * m.Cf(item * (item - "]")^0, mt.__add) |
191 | / function (c, p) return c == "^" and any - p or p end | 189 | / function (c, p) return c == "^" and any - p or p end |
192 | * expect("]", "MisClose8") | 190 | * expect("]", "MisClose8") |
193 | 191 | ||
diff --git a/testrelabelparser.lua b/testrelabelparser.lua index 0399ff6..27c3e52 100644 --- a/testrelabelparser.lua +++ b/testrelabelparser.lua | |||
@@ -8,14 +8,14 @@ function testerror(repatt, msg) | |||
8 | -- expecting a syntax error | 8 | -- expecting a syntax error |
9 | err = err:match("^[^\n]*\n(.-)$") -- remove first line (filename) | 9 | err = err:match("^[^\n]*\n(.-)$") -- remove first line (filename) |
10 | err = err:gsub("[ \t]*\n", "\n") -- remove trailing spaces | 10 | err = err:gsub("[ \t]*\n", "\n") -- remove trailing spaces |
11 | -- if err ~= msg then | 11 | --if err ~= msg then |
12 | -- print(#err, #msg) | 12 | --print(#err, #msg) |
13 | -- print('--') | 13 | --print('--') |
14 | -- print(err) | 14 | --print(err) |
15 | -- print('--') | 15 | --print('--') |
16 | -- print(msg) | 16 | --print(msg) |
17 | -- print('--') | 17 | --print('--') |
18 | -- end | 18 | --end |
19 | assert(err == msg) | 19 | assert(err == msg) |
20 | else | 20 | else |
21 | -- expecting a non-syntax error | 21 | -- expecting a non-syntax error |
@@ -366,16 +366,14 @@ L1:C2: expected a name or label after '%' (no space) | |||
366 | ^ | 366 | ^ |
367 | ]]) | 367 | ]]) |
368 | 368 | ||
369 | -- testing ExpItem | 369 | -- testing empty char set (MisClose8, previously MisItem) |
370 | 370 | ||
371 | testerror([[ | 371 | testerror([[ |
372 | "p" [ | 372 | "p" [] "q" |
373 | abc | ||
374 | ] "q" | ||
375 | ]], [[ | 373 | ]], [[ |
376 | L1:C6: expected at least one item after '[' or '^' | 374 | L2:C1: missing closing ']' or empty char class |
377 | "p" [ | 375 | |
378 | ^ | 376 | ^ |
379 | ]]) | 377 | ]]) |
380 | 378 | ||
381 | -- testing MisClose1 | 379 | -- testing MisClose1 |
@@ -451,31 +449,31 @@ L1:C9: missing closing '}' | |||
451 | -- testing MisClose8 | 449 | -- testing MisClose8 |
452 | 450 | ||
453 | testerror([[[]], [[ | 451 | testerror([[[]], [[ |
454 | L1:C2: missing closing ']' | 452 | L1:C2: missing closing ']' or empty char class |
455 | [ | 453 | [ |
456 | ^ | 454 | ^ |
457 | ]]) | 455 | ]]) |
458 | 456 | ||
459 | testerror([[[^]], [[ | 457 | testerror([[[^]], [[ |
460 | L1:C3: missing closing ']' | 458 | L1:C3: missing closing ']' or empty char class |
461 | [^ | 459 | [^ |
462 | ^ | 460 | ^ |
463 | ]]) | 461 | ]]) |
464 | 462 | ||
465 | testerror([[[] ]], [[ | 463 | testerror([[[] ]], [[ |
466 | L1:C4: missing closing ']' | 464 | L1:C4: missing closing ']' or empty char class |
467 | [] | 465 | [] |
468 | ^ | 466 | ^ |
469 | ]]) | 467 | ]]) |
470 | 468 | ||
471 | testerror([[[^] ]], [[ | 469 | testerror([[[^] ]], [[ |
472 | L1:C6: missing closing ']' | 470 | L1:C6: missing closing ']' or empty char class |
473 | [^] | 471 | [^] |
474 | ^ | 472 | ^ |
475 | ]]) | 473 | ]]) |
476 | 474 | ||
477 | testerror([[[_-___-_|]], [[ | 475 | testerror([[[_-___-_|]], [[ |
478 | L1:C10: missing closing ']' | 476 | L1:C10: missing closing ']' or empty char class |
479 | [_-___-_| | 477 | [_-___-_| |
480 | ^ | 478 | ^ |
481 | ]]) | 479 | ]]) |