diff options
-rw-r--r-- | testerrors.lua | 759 |
1 files changed, 604 insertions, 155 deletions
diff --git a/testerrors.lua b/testerrors.lua index 6e9c83e..afa80c6 100644 --- a/testerrors.lua +++ b/testerrors.lua | |||
@@ -1,161 +1,610 @@ | |||
1 | local re = require 'relabel' | 1 | local re = require 'relabel' |
2 | 2 | ||
3 | local npass, ntests = 0, 0 | 3 | function testerror(repatt, msg) |
4 | 4 | msg = msg:match("^%s*(.-)%s*$") -- trim | |
5 | function testerror(repatt) | ||
6 | ntests = ntests + 1 | ||
7 | local ok, err = pcall(function () re.compile(repatt) end) | 5 | local ok, err = pcall(function () re.compile(repatt) end) |
8 | 6 | assert(not ok) | |
9 | if ok then | 7 | err = err:match("^[^\n]*\n(.-)$") -- remove first line (filename) |
10 | print("FAIL", ntests) | 8 | err = err:gsub(" *\n", "\n") -- remove trailing spaces |
11 | else | 9 | -- if err ~= msg then |
12 | npass = npass + 1 | 10 | -- print(#err, #msg) |
13 | print("PASS", ntests, err) | 11 | -- print('--') |
14 | end | 12 | -- print(err) |
13 | -- print('--') | ||
14 | -- print(msg) | ||
15 | -- print('--') | ||
16 | -- end | ||
17 | assert(err == msg) | ||
15 | end | 18 | end |
16 | 19 | ||
17 | local patterns = { | 20 | testerror([[~]],[[ |
18 | -- 1-5 | 21 | L1:C1: no pattern found |
19 | [[~]], | 22 | ~ |
20 | [[???]], | 23 | ^ |
21 | [['p'~]], | 24 | ]]) |
22 | [['p'?$?]], | 25 | |
23 | [['p' /{1}]], | 26 | testerror([[???]], [[ |
24 | -- 6-10 | 27 | L1:C1: no pattern found |
25 | [['p' /{1} /{2} 'q']], | 28 | ??? |
26 | [['p' /]], | 29 | ^ |
27 | [['p' / / 'q']], | 30 | ]]) |
28 | [[&]], | 31 | |
29 | [[& / 'p']], | 32 | testerror([['p'~]], [[ |
30 | -- 11-15 | 33 | L1:C4: unexpected characters after the pattern |
31 | [['p' &]], | 34 | 'p'~ |
32 | [['p' / & / 'q']], | 35 | ^ |
33 | [[&&]], | 36 | ]]) |
34 | [[!&]], | 37 | |
35 | [[!]], | 38 | testerror([['p'?$?]], [[ |
36 | -- 16-20 | 39 | L1:C5: unexpected characters after the pattern |
37 | [[! / 'p']], | 40 | 'p'?$? |
38 | [['p' !]], | 41 | ^ |
39 | [['p' / ! / 'q']], | 42 | ]]) |
40 | [[!!]], | 43 | |
41 | [[&!]], | 44 | testerror([['p' /{1}]], [[ |
42 | -- 21-25 | 45 | L1:C9: expected a pattern after '/' or the label(s) |
43 | [['p' ^ n]], | 46 | 'p' /{1} |
44 | [['p'^+(+1)]], | 47 | ^ |
45 | [['p'^-/'q']], | 48 | ]]) |
46 | [['p' -> {]], | 49 | |
47 | [['p' -> {'q'}]], | 50 | testerror([['p' /{1} /{2} 'q']], [[ |
48 | -- 26-30 | 51 | L1:C9: expected a pattern after '/' or the label(s) |
49 | [['p' -> / 'q']], | 52 | 'p' /{1} /{2} 'q' |
50 | [['p' -> [0-9] ]], | 53 | ^ |
51 | [['p' =>]], | 54 | ]]) |
52 | [['p' => 'q']], | 55 | |
53 | [[()]], | 56 | testerror([['p' /]], [[ |
54 | -- 31-35 | 57 | L1:C6: expected a pattern after '/' or the label(s) |
55 | [[($$$)]], | 58 | 'p' / |
56 | [[('p' ('q' / 'r')]], | 59 | ^ |
57 | [[% s]], | 60 | ]]) |
58 | [[% {1}]], | 61 | |
59 | [[{: *** :}]], | 62 | testerror([['p' / / 'q']], [[ |
60 | -- 36-40 | 63 | L1:C6: expected a pattern after '/' or the label(s) |
61 | [[{:group: *** :}]], | 64 | 'p' / / 'q' |
62 | [[{: group: 'p' :}]], | 65 | ^ |
63 | [[S <- {: 'p' T <- 'q']], | 66 | ]]) |
64 | [['<' {:tag: [a-z]+ :} '>' '<' = '>']], | 67 | |
65 | [['<' {:tag: [a-z]+ :} '>' '<' = tag '>']], | 68 | testerror([[&]], [[ |
66 | -- 41-45 | 69 | L1:C2: expected a pattern after '&' |
67 | [[{~~}]], | 70 | & |
68 | [[{ {~ } ~}]], | 71 | ^ |
69 | [[{~ ^_^ ~}]], | 72 | ]]) |
70 | [['p' {~ ('q' 'r') / 's']], | 73 | |
71 | [[{0}]], | 74 | testerror([[& / 'p']], [[ |
72 | -- 46-50 | 75 | L1:C2: expected a pattern after '&' |
73 | [[{ :'p': }]], | 76 | & / 'p' |
74 | [[{ 'p' ]], | 77 | ^ |
75 | [[<>]], | 78 | ]]) |
76 | [[<123>]], | 79 | |
77 | [[< hello >]], | 80 | testerror([['p' &]], [[ |
78 | -- 51-55 | 81 | L1:C6: expected a pattern after '&' |
79 | [[<<S>>]], | 82 | 'p' & |
80 | [[<patt]], | 83 | ^ |
81 | [[<insert your name here>]], | 84 | ]]) |
82 | [[S <-]], | 85 | |
83 | [[S <- 'p' T <-]], | 86 | testerror([['p' / & / 'q']], [[ |
84 | -- 55-60 | 87 | L1:C8: expected a pattern after '&' |
85 | [[[]], | 88 | 'p' / & / 'q' |
86 | [[[^]], | 89 | ^ |
87 | [[[] ]], | 90 | ]]) |
88 | [[[^] ]], | 91 | |
89 | [[[_-___-_|]], | 92 | testerror([[&&]], [[ |
90 | -- 60-65 | 93 | L1:C3: expected a pattern after '&' |
91 | [['p' /{} 'q']], | 94 | && |
92 | [[%{ 'label' }]], | 95 | ^ |
93 | [['p' /{1,2,3,} 'q']], | 96 | ]]) |
94 | [[%{ a,,b,,c }]], | 97 | |
95 | [['{' %{ a, b '}']], | 98 | testerror([[!&]], [[ |
96 | -- 65-70 | 99 | L1:C3: expected a pattern after '&' |
97 | [[Q <- "To be or not to be...]], | 100 | !& |
98 | [['That is the question...]], | 101 | ^ |
99 | [[{||}]], | 102 | ]]) |
100 | [[{|@|}]], | 103 | |
101 | [['p' {| 'q' / 'r' }]], | 104 | testerror([[!]], [[ |
102 | -- 71-75 | 105 | L1:C2: expected a pattern after '!' |
103 | [['a'/{1}'b'/'c']], -- should not fail anymore | 106 | ! |
104 | [[x <- {:x:}]], | 107 | ^ |
105 | [[&'p'/&/!/'p'^'q']], | 108 | ]]) |
106 | [[ | 109 | |
107 | A <- 'a' (B 'b' | 110 | testerror([[! / 'p']], [[ |
108 | B <- 'x' / ! | 111 | L1:C2: expected a pattern after '!' |
109 | C <- 'c' | 112 | ! / 'p' |
110 | ]], | 113 | ^ |
111 | [[ | 114 | ]]) |
112 | A <- %nosuch %def | 115 | |
113 | A <- 'A again' | 116 | testerror([['p' !]], [[ |
114 | A <- 'and again' | 117 | L1:C6: expected a pattern after '!' |
115 | ]], | 118 | 'p' ! |
116 | -- 76 - 80 | 119 | ^ |
117 | [[names not in grammar]], | 120 | ]]) |
118 | [[ | 121 | |
119 | A <- %nosuch %def | 122 | testerror([['p' / ! / 'q']], [[ |
120 | A <- 'A again' | 123 | L1:C8: expected a pattern after '!' |
121 | A <- 'and again' | 124 | 'p' / ! / 'q' |
122 | ]], | 125 | ^ |
123 | [[ A <- %nosuch ('error' ]], | 126 | ]]) |
124 | [[A <- Unknown Rules]], | 127 | |
125 | [['a' / &@ ('c' / 'd')]], | 128 | testerror([[!!]], [[ |
126 | -- 81 - 85 | 129 | L1:C3: expected a pattern after '!' |
127 | [['x' / & / 'y']], | 130 | !! |
128 | [[&/'p'/!/'q']], | 131 | ^ |
129 | [['p'//'q']], | 132 | ]]) |
130 | [[ | 133 | |
131 | S <- 'forgot to close / T | 134 | testerror([[&!]], [[ |
132 | T <- 'T' & / 't' | 135 | L1:C3: expected a pattern after '!' |
133 | ]], | 136 | &! |
134 | [[ | 137 | ^ |
135 | S <- [a-z / T | 138 | ]]) |
136 | T <- 'x' / & / 'y' | 139 | |
137 | ]], | 140 | testerror([['p' ^ n]], [[ |
138 | -- 86 - 88 | 141 | L1:C6: expected a number after '^', '+' or '-' (no space) |
139 | [[ | 142 | 'p' ^ n |
140 | S <- ('p' -- comment | 143 | ^ |
141 | ]], | 144 | ]]) |
142 | [[ | 145 | |
143 | X <- ('p / Q (R | 146 | testerror([['p'^+(+1)]], [[ |
144 | / S)) | 147 | L1:C5: expected a number after '^', '+' or '-' (no space) |
145 | Q <- 'q' | 148 | 'p'^+(+1) |
146 | R <- 'r' | 149 | ^ |
147 | S <- 's' | 150 | ]]) |
148 | ]], | 151 | |
149 | [[ | 152 | testerror([['p'^-/'q']], [[ |
150 | A <- 'A' /{'lab'} B / ! | 153 | L1:C5: expected a number after '^', '+' or '-' (no space) |
151 | 154 | 'p'^-/'q' | |
152 | B <- %{1, 2 3} 'b' / '6' & / 'B' | 155 | ^ |
153 | ]] | 156 | ]]) |
154 | } | 157 | |
155 | 158 | testerror([['p' -> {]], [[ | |
156 | for i, patt in ipairs(patterns) do | 159 | L1:C7: expected a string, number, '{}' or name after '->' |
157 | testerror(patt) | 160 | 'p' -> { |
158 | end | 161 | ^ |
162 | ]]) | ||
163 | |||
164 | testerror([['p' -> {'q'}]], [[ | ||
165 | L1:C7: expected a string, number, '{}' or name after '->' | ||
166 | 'p' -> {'q'} | ||
167 | ^ | ||
168 | ]]) | ||
169 | |||
170 | testerror([['p' -> / 'q']], [[ | ||
171 | L1:C7: expected a string, number, '{}' or name after '->' | ||
172 | 'p' -> / 'q' | ||
173 | ^ | ||
174 | ]]) | ||
175 | |||
176 | testerror([['p' -> [0-9] ]], [[ | ||
177 | L1:C7: expected a string, number, '{}' or name after '->' | ||
178 | 'p' -> [0-9] | ||
179 | ^ | ||
180 | ]]) | ||
181 | |||
182 | testerror([['p' =>]], [[ | ||
183 | L1:C7: expected the name of a rule after '=>' | ||
184 | 'p' => | ||
185 | ^ | ||
186 | ]]) | ||
187 | |||
188 | testerror([['p' => 'q']], [[ | ||
189 | L1:C7: expected the name of a rule after '=>' | ||
190 | 'p' => 'q' | ||
191 | ^ | ||
192 | ]]) | ||
193 | |||
194 | testerror([[()]], [[ | ||
195 | L1:C2: expected a pattern after '(' | ||
196 | () | ||
197 | ^ | ||
198 | ]]) | ||
199 | |||
200 | testerror([[($$$)]], [[ | ||
201 | L1:C2: expected a pattern after '(' | ||
202 | ($$$) | ||
203 | ^ | ||
204 | ]]) | ||
205 | |||
206 | testerror([[('p' ('q' / 'r')]], [[ | ||
207 | L1:C17: missing closing ')' | ||
208 | ('p' ('q' / 'r') | ||
209 | ^ | ||
210 | ]]) | ||
211 | |||
212 | testerror([[% s]], [[ | ||
213 | L1:C2: expected a name or label after '%' (no space) | ||
214 | % s | ||
215 | ^ | ||
216 | ]]) | ||
217 | |||
218 | testerror([[% {1}]], [[ | ||
219 | L1:C2: expected a name or label after '%' (no space) | ||
220 | % {1} | ||
221 | ^ | ||
222 | ]]) | ||
223 | |||
224 | testerror([[{: *** :}]], [[ | ||
225 | L1:C3: expected a pattern after ':' | ||
226 | {: *** :} | ||
227 | ^ | ||
228 | ]]) | ||
229 | |||
230 | testerror([[{:group: *** :}]], [[ | ||
231 | L1:C9: expected a pattern after ':' | ||
232 | {:group: *** :} | ||
233 | ^ | ||
234 | ]]) | ||
235 | |||
236 | testerror([[{: group: 'p' :}]], [[ | ||
237 | L1:C9: missing closing ':}' | ||
238 | {: group: 'p' :} | ||
239 | ^ | ||
240 | L1:C9: unexpected characters after the pattern | ||
241 | {: group: 'p' :} | ||
242 | ^ | ||
243 | ]]) | ||
244 | |||
245 | testerror([[S <- {: 'p' T <- 'q']], [[ | ||
246 | L1:C12: missing closing ':}' | ||
247 | S <- {: 'p' T <- 'q' | ||
248 | ^ | ||
249 | ]]) | ||
250 | |||
251 | testerror([['<' {:tag: [a-z]+ :} '>' '<' = '>']], [[ | ||
252 | L1:C31: expected the name of a rule after '=' (no space) | ||
253 | '<' {:tag: [a-z]+ :} '>' '<' = '>' | ||
254 | ^ | ||
255 | ]]) | ||
256 | |||
257 | testerror([['<' {:tag: [a-z]+ :} '>' '<' = tag '>']], [[ | ||
258 | L1:C31: expected the name of a rule after '=' (no space) | ||
259 | '<' {:tag: [a-z]+ :} '>' '<' = tag '>' | ||
260 | ^ | ||
261 | ]]) | ||
262 | |||
263 | testerror([[{~~}]], [[ | ||
264 | L1:C3: expected a pattern after '{~' | ||
265 | {~~} | ||
266 | ^ | ||
267 | ]]) | ||
268 | |||
269 | testerror([[{ {~ } ~}]], [[ | ||
270 | L1:C5: expected a pattern after '{~' | ||
271 | { {~ } ~} | ||
272 | ^ | ||
273 | L1:C10: missing closing '}' | ||
274 | { {~ } ~} | ||
275 | ^ | ||
276 | ]]) | ||
277 | |||
278 | testerror([[{~ ^_^ ~}]], [[ | ||
279 | L1:C3: expected a pattern after '{~' | ||
280 | {~ ^_^ ~} | ||
281 | ^ | ||
282 | ]]) | ||
283 | |||
284 | testerror([['p' {~ ('q' 'r') / 's']], [[ | ||
285 | L1:C23: missing closing '~}' | ||
286 | 'p' {~ ('q' 'r') / 's' | ||
287 | ^ | ||
288 | ]]) | ||
159 | 289 | ||
160 | print() | 290 | testerror([[{0}]], [[ |
161 | print("Tests passed: " .. npass .. "/" .. ntests) | 291 | L1:C2: expected a pattern or closing '}' after '{' |
292 | {0} | ||
293 | ^ | ||
294 | ]]) | ||
295 | |||
296 | testerror([[{ :'p': }]], [[ | ||
297 | L1:C2: expected a pattern or closing '}' after '{' | ||
298 | { :'p': } | ||
299 | ^ | ||
300 | ]]) | ||
301 | |||
302 | testerror([[{ 'p' ]], [[ | ||
303 | L1:C6: missing closing '}' | ||
304 | { 'p' | ||
305 | ^ | ||
306 | ]]) | ||
307 | |||
308 | testerror([[<>]], [[ | ||
309 | L1:C2: expected the name of a rule after '<' (no space) | ||
310 | <> | ||
311 | ^ | ||
312 | ]]) | ||
313 | |||
314 | testerror([[<123>]], [[ | ||
315 | L1:C2: expected the name of a rule after '<' (no space) | ||
316 | <123> | ||
317 | ^ | ||
318 | ]]) | ||
319 | |||
320 | testerror([[< hello >]], [[ | ||
321 | L1:C2: expected the name of a rule after '<' (no space) | ||
322 | < hello > | ||
323 | ^ | ||
324 | ]]) | ||
325 | |||
326 | testerror([[<<S>>]], [[ | ||
327 | L1:C2: expected the name of a rule after '<' (no space) | ||
328 | <<S>> | ||
329 | ^ | ||
330 | ]]) | ||
331 | |||
332 | testerror([[<patt]], [[ | ||
333 | L1:C6: missing closing '>' | ||
334 | <patt | ||
335 | ^ | ||
336 | ]]) | ||
337 | |||
338 | testerror([[<insert your name here>]], [[ | ||
339 | L1:C8: missing closing '>' | ||
340 | <insert your name here> | ||
341 | ^ | ||
342 | ]]) | ||
343 | |||
344 | testerror([[S <-]], [[ | ||
345 | L1:C5: expected a pattern after '<-' | ||
346 | S <- | ||
347 | ^ | ||
348 | ]]) | ||
349 | |||
350 | testerror([[S <- 'p' T <-]], [[ | ||
351 | L1:C14: expected a pattern after '<-' | ||
352 | S <- 'p' T <- | ||
353 | ^ | ||
354 | ]]) | ||
355 | |||
356 | testerror([[[]], [[ | ||
357 | L1:C1: missing closing ']' | ||
358 | [ | ||
359 | ^ | ||
360 | ]]) | ||
361 | |||
362 | testerror([[[^]], [[ | ||
363 | L1:C1: missing closing ']' | ||
364 | [^ | ||
365 | ^ | ||
366 | ]]) | ||
367 | |||
368 | testerror([[[] ]], [[ | ||
369 | L1:C1: missing closing ']' | ||
370 | [] | ||
371 | ^ | ||
372 | ]]) | ||
373 | |||
374 | -- testerror([[[^] ]], [[ | ||
375 | -- L1:C1: missing closing ']' | ||
376 | -- [^] | ||
377 | -- ^ | ||
378 | -- ]]) | ||
379 | |||
380 | testerror([[[_-___-_|]], [[ | ||
381 | L1:C1: missing closing ']' | ||
382 | [_-___-_| | ||
383 | ^ | ||
384 | ]]) | ||
385 | |||
386 | testerror([['p' /{} 'q']], [[ | ||
387 | L1:C7: expected at least one label after '{' | ||
388 | 'p' /{} 'q' | ||
389 | ^ | ||
390 | ]]) | ||
391 | |||
392 | testerror([[%{ 'label' }]], [[ | ||
393 | L1:C3: expected at least one label after '{' | ||
394 | %{ 'label' } | ||
395 | ^ | ||
396 | ]]) | ||
397 | |||
398 | testerror([['p' /{1,2,3,} 'q']], [[ | ||
399 | L1:C13: expected a label after the comma | ||
400 | 'p' /{1,2,3,} 'q' | ||
401 | ^ | ||
402 | ]]) | ||
403 | |||
404 | testerror([[%{ a,,b,,c }]], [[ | ||
405 | L1:C6: expected a label after the comma | ||
406 | %{ a,,b,,c } | ||
407 | ^ | ||
408 | ]]) | ||
409 | |||
410 | testerror([['{' %{ a, b '}']], [[ | ||
411 | L1:C12: missing closing '}' | ||
412 | '{' %{ a, b '}' | ||
413 | ^ | ||
414 | ]]) | ||
415 | |||
416 | testerror([[Q <- "To be or not to be...]], [[ | ||
417 | L1:C6: missing terminating double quote | ||
418 | Q <- "To be or not to be... | ||
419 | ^ | ||
420 | ]]) | ||
421 | |||
422 | testerror([['That is the question...]], [[ | ||
423 | L1:C1: missing terminating single quote | ||
424 | 'That is the question... | ||
425 | ^ | ||
426 | ]]) | ||
427 | |||
428 | testerror([[{||}]], [[ | ||
429 | L1:C3: expected a pattern after '{|' | ||
430 | {||} | ||
431 | ^ | ||
432 | ]]) | ||
433 | |||
434 | testerror([[{|@|}]], [[ | ||
435 | L1:C3: expected a pattern after '{|' | ||
436 | {|@|} | ||
437 | ^ | ||
438 | ]]) | ||
439 | |||
440 | testerror([['p' {| 'q' / 'r' }]], [[ | ||
441 | L1:C17: missing closing '|}' | ||
442 | 'p' {| 'q' / 'r' } | ||
443 | ^ | ||
444 | L1:C18: unexpected characters after the pattern | ||
445 | 'p' {| 'q' / 'r' } | ||
446 | ^ | ||
447 | ]]) | ||
448 | |||
449 | testerror([[x <- {:x:}]], [[ | ||
450 | L1:C10: expected a pattern after ':' | ||
451 | x <- {:x:} | ||
452 | ^ | ||
453 | ]]) | ||
454 | |||
455 | testerror([[&'p'/&/!/'p'^'q']], [[ | ||
456 | L1:C7: expected a pattern after '&' | ||
457 | &'p'/&/!/'p'^'q' | ||
458 | ^ | ||
459 | L1:C9: expected a pattern after '!' | ||
460 | &'p'/&/!/'p'^'q' | ||
461 | ^ | ||
462 | L1:C14: expected a number after '^', '+' or '-' (no space) | ||
463 | &'p'/&/!/'p'^'q' | ||
464 | ^ | ||
465 | ]]) | ||
466 | |||
467 | testerror([[ | ||
468 | A <- 'a' (B 'b' | ||
469 | B <- 'x' / ! | ||
470 | C <- 'c' | ||
471 | ]],[[ | ||
472 | L1:C18: missing closing ')' | ||
473 | A <- 'a' (B 'b' | ||
474 | ^ | ||
475 | L2:C15: expected a pattern after '!' | ||
476 | B <- 'x' / ! | ||
477 | ^ | ||
478 | ]]) | ||
479 | |||
480 | testerror([[ | ||
481 | A <- %nosuch %def | ||
482 | A <- 'A again' | ||
483 | A <- 'and again' | ||
484 | ]],[[ | ||
485 | name 'nosuch' undefined | ||
486 | name 'def' undefined | ||
487 | 'A' already defined as a rule | ||
488 | 'A' already defined as a rule | ||
489 | ]]) | ||
490 | |||
491 | testerror([[names not in grammar]], [[ | ||
492 | rule 'names' used outside a grammar | ||
493 | rule 'not' used outside a grammar | ||
494 | rule 'in' used outside a grammar | ||
495 | rule 'grammar' used outside a grammar | ||
496 | ]]) | ||
497 | |||
498 | testerror([[ | ||
499 | A <- %nosuch %def | ||
500 | A <- 'A again' | ||
501 | A <- 'and again' | ||
502 | ]],[[ | ||
503 | name 'nosuch' undefined | ||
504 | name 'def' undefined | ||
505 | 'A' already defined as a rule | ||
506 | 'A' already defined as a rule | ||
507 | ]]) | ||
508 | |||
509 | testerror([[ A <- %nosuch ('error' ]], [[ | ||
510 | L1:C23: missing closing ')' | ||
511 | A <- %nosuch ('error' | ||
512 | ^ | ||
513 | name 'nosuch' undefined | ||
514 | ]]) | ||
515 | |||
516 | -- testerror([[A <- Unknown Rules]], [[]]) | ||
517 | |||
518 | testerror([['a' / &@ ('c' / 'd')]], [[ | ||
519 | L1:C8: expected a pattern after '&' | ||
520 | 'a' / &@ ('c' / 'd') | ||
521 | ^ | ||
522 | ]]) | ||
523 | |||
524 | testerror([['x' / & / 'y']], [[ | ||
525 | L1:C8: expected a pattern after '&' | ||
526 | 'x' / & / 'y' | ||
527 | ^ | ||
528 | ]]) | ||
529 | |||
530 | testerror([[&/'p'/!/'q']], [[ | ||
531 | L1:C2: expected a pattern after '&' | ||
532 | &/'p'/!/'q' | ||
533 | ^ | ||
534 | L1:C8: expected a pattern after '!' | ||
535 | &/'p'/!/'q' | ||
536 | ^ | ||
537 | ]]) | ||
538 | |||
539 | testerror([['p'//'q']], [[ | ||
540 | L1:C5: expected a pattern after '/' or the label(s) | ||
541 | 'p'//'q' | ||
542 | ^ | ||
543 | ]]) | ||
544 | |||
545 | testerror([[ | ||
546 | S <- 'forgot to close / T | ||
547 | T <- 'T' & / 't' | ||
548 | ]],[[ | ||
549 | L1:C8: missing terminating single quote | ||
550 | S <- 'forgot to close / T | ||
551 | ^ | ||
552 | L2:C13: expected a pattern after '&' | ||
553 | T <- 'T' & / 't' | ||
554 | ^ | ||
555 | ]]) | ||
556 | |||
557 | testerror([[ | ||
558 | S <- [a-z / T | ||
559 | T <- 'x' / & / 'y' | ||
560 | ]],[[ | ||
561 | L1:C8: missing closing ']' | ||
562 | S <- [a-z / T | ||
563 | ^ | ||
564 | L2:C15: expected a pattern after '&' | ||
565 | T <- 'x' / & / 'y' | ||
566 | ^ | ||
567 | ]]) | ||
568 | |||
569 | testerror([[ | ||
570 | S <- ('p' -- comment | ||
571 | ]],[[ | ||
572 | L1:C12: missing closing ')' | ||
573 | S <- ('p' -- comment | ||
574 | ^ | ||
575 | ]]) | ||
576 | |||
577 | testerror([[ | ||
578 | X <- ('p / Q (R | ||
579 | / S)) | ||
580 | Q <- 'q' | ||
581 | R <- 'r' | ||
582 | S <- 's' | ||
583 | ]],[[ | ||
584 | L1:C9: missing terminating single quote | ||
585 | X <- ('p / Q (R | ||
586 | ^ | ||
587 | L2:C9: unexpected characters after the pattern | ||
588 | / S)) | ||
589 | ^ | ||
590 | ]]) | ||
591 | |||
592 | testerror([[ | ||
593 | A <- 'A' /{'lab'} B / ! | ||
594 | |||
595 | B <- %{1, 2 3} 'b' / '6' & / 'B' | ||
596 | ]],[[ | ||
597 | L1:C14: expected at least one label after '{' | ||
598 | A <- 'A' /{'lab'} B / ! | ||
599 | ^ | ||
600 | L1:C26: expected a pattern after '!' | ||
601 | A <- 'A' /{'lab'} B / ! | ||
602 | ^ | ||
603 | L3:C15: missing closing '}' | ||
604 | B <- %{1, 2 3} 'b' / '6' & / 'B' | ||
605 | ^ | ||
606 | ]]) | ||
607 | |||
608 | |||
609 | print 'OK' | ||
610 | \ No newline at end of file | ||