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