diff options
author | Undecidable Robot <undecidabot@gmail.com> | 2016-08-18 12:00:47 +0800 |
---|---|---|
committer | Undecidable Robot <undecidabot@gmail.com> | 2016-08-18 12:00:47 +0800 |
commit | ef26e7c4b777ebe9c9c3844bcc818de811369fff (patch) | |
tree | 917926c063a8e713fcbfa138f53c722929131576 /testrelabelparser.lua | |
parent | 28a44f01cb7a75068b75a99c0badb3abdaf7047a (diff) | |
download | lpeglabel-ef26e7c4b777ebe9c9c3844bcc818de811369fff.tar.gz lpeglabel-ef26e7c4b777ebe9c9c3844bcc818de811369fff.tar.bz2 lpeglabel-ef26e7c4b777ebe9c9c3844bcc818de811369fff.zip |
Removing error recovery (moving it out to a different branch)
Diffstat (limited to 'testrelabelparser.lua')
-rw-r--r-- | testrelabelparser.lua | 174 |
1 files changed, 14 insertions, 160 deletions
diff --git a/testrelabelparser.lua b/testrelabelparser.lua index 1c5bb9f..46e01ee 100644 --- a/testrelabelparser.lua +++ b/testrelabelparser.lua | |||
@@ -199,9 +199,6 @@ testerror([[{ {~ } ~}]], [[ | |||
199 | L1:C5: expected a pattern after '{~' | 199 | L1:C5: expected a pattern after '{~' |
200 | { {~ } ~} | 200 | { {~ } ~} |
201 | ^ | 201 | ^ |
202 | L1:C10: missing closing '}' | ||
203 | { {~ } ~} | ||
204 | ^ | ||
205 | ]]) | 202 | ]]) |
206 | 203 | ||
207 | testerror([[{~ ^_^ ~}]], [[ | 204 | testerror([[{~ ^_^ ~}]], [[ |
@@ -421,9 +418,6 @@ testerror([[{: group: 'p' :}]], [[ | |||
421 | L1:C9: missing closing ':}' | 418 | L1:C9: missing closing ':}' |
422 | {: group: 'p' :} | 419 | {: group: 'p' :} |
423 | ^ | 420 | ^ |
424 | L1:C9: unexpected characters after the pattern | ||
425 | {: group: 'p' :} | ||
426 | ^ | ||
427 | ]]) | 421 | ]]) |
428 | 422 | ||
429 | testerror([[S <- {: 'p' T <- 'q']], [[ | 423 | testerror([[S <- {: 'p' T <- 'q']], [[ |
@@ -447,9 +441,6 @@ testerror([['p' {| 'q' / 'r' }]], [[ | |||
447 | L1:C17: missing closing '|}' | 441 | L1:C17: missing closing '|}' |
448 | 'p' {| 'q' / 'r' } | 442 | 'p' {| 'q' / 'r' } |
449 | ^ | 443 | ^ |
450 | L1:C18: unexpected characters after the pattern | ||
451 | 'p' {| 'q' / 'r' } | ||
452 | ^ | ||
453 | ]]) | 444 | ]]) |
454 | 445 | ||
455 | -- testing MisClose5 | 446 | -- testing MisClose5 |
@@ -485,186 +476,49 @@ L1:C12: missing closing '}' | |||
485 | -- testing MisClose8 | 476 | -- testing MisClose8 |
486 | 477 | ||
487 | testerror([[[]], [[ | 478 | testerror([[[]], [[ |
488 | L1:C1: missing closing ']' | 479 | L1:C2: missing closing ']' |
489 | [ | 480 | [ |
490 | ^ | 481 | ^ |
491 | ]]) | 482 | ]]) |
492 | 483 | ||
493 | testerror([[[^]], [[ | 484 | testerror([[[^]], [[ |
494 | L1:C1: missing closing ']' | 485 | L1:C3: missing closing ']' |
495 | [^ | 486 | [^ |
496 | ^ | 487 | ^ |
497 | ]]) | 488 | ]]) |
498 | 489 | ||
499 | testerror([[[] ]], [[ | 490 | testerror([[[] ]], [[ |
500 | L1:C1: missing closing ']' | 491 | L1:C4: missing closing ']' |
501 | [] | 492 | [] |
502 | ^ | 493 | ^ |
503 | ]]) | 494 | ]]) |
504 | 495 | ||
505 | testerror([[[^] ]], [[ | 496 | testerror([[[^] ]], [[ |
506 | L1:C1: missing closing ']' | 497 | L1:C6: missing closing ']' |
507 | [^] | 498 | [^] |
508 | ^ | 499 | ^ |
509 | ]]) | 500 | ]]) |
510 | 501 | ||
511 | testerror([[[_-___-_|]], [[ | 502 | testerror([[[_-___-_|]], [[ |
512 | L1:C1: missing closing ']' | 503 | L1:C10: missing closing ']' |
513 | [_-___-_| | 504 | [_-___-_| |
514 | ^ | 505 | ^ |
515 | ]]) | 506 | ]]) |
516 | 507 | ||
517 | -- testing MisTerm1 | 508 | -- testing MisTerm1 |
518 | 509 | ||
519 | testerror([['That is the question...]], [[ | 510 | testerror([['That is the question...]], [[ |
520 | L1:C1: missing terminating single quote | 511 | L1:C25: missing terminating single quote |
521 | 'That is the question... | 512 | 'That is the question... |
522 | ^ | 513 | ^ |
523 | ]]) | 514 | ]]) |
524 | 515 | ||
525 | -- testing MisTerm2 | 516 | -- testing MisTerm2 |
526 | 517 | ||
527 | testerror([[Q <- "To be or not to be...]], [[ | 518 | testerror([[Q <- "To be or not to be...]], [[ |
528 | L1:C6: missing terminating double quote | 519 | L1:C28: missing terminating double quote |
529 | Q <- "To be or not to be... | 520 | Q <- "To be or not to be... |
530 | ^ | 521 | ^ |
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 | ]]) | 522 | ]]) |
669 | 523 | ||
670 | -- testing non-syntax errors | 524 | -- testing non-syntax errors |