aboutsummaryrefslogtreecommitdiff
path: root/testrelabelparser.lua
diff options
context:
space:
mode:
authorUndecidable Robot <undecidabot@gmail.com>2016-08-18 12:00:47 +0800
committerUndecidable Robot <undecidabot@gmail.com>2016-08-18 12:00:47 +0800
commitef26e7c4b777ebe9c9c3844bcc818de811369fff (patch)
tree917926c063a8e713fcbfa138f53c722929131576 /testrelabelparser.lua
parent28a44f01cb7a75068b75a99c0badb3abdaf7047a (diff)
downloadlpeglabel-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.lua174
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([[{ {~ } ~}]], [[
199L1:C5: expected a pattern after '{~' 199L1:C5: expected a pattern after '{~'
200{ {~ } ~} 200{ {~ } ~}
201 ^ 201 ^
202L1:C10: missing closing '}'
203{ {~ } ~}
204 ^
205]]) 202]])
206 203
207testerror([[{~ ^_^ ~}]], [[ 204testerror([[{~ ^_^ ~}]], [[
@@ -421,9 +418,6 @@ testerror([[{: group: 'p' :}]], [[
421L1:C9: missing closing ':}' 418L1:C9: missing closing ':}'
422{: group: 'p' :} 419{: group: 'p' :}
423 ^ 420 ^
424L1:C9: unexpected characters after the pattern
425{: group: 'p' :}
426 ^
427]]) 421]])
428 422
429testerror([[S <- {: 'p' T <- 'q']], [[ 423testerror([[S <- {: 'p' T <- 'q']], [[
@@ -447,9 +441,6 @@ testerror([['p' {| 'q' / 'r' }]], [[
447L1:C17: missing closing '|}' 441L1:C17: missing closing '|}'
448'p' {| 'q' / 'r' } 442'p' {| 'q' / 'r' }
449 ^ 443 ^
450L1: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
487testerror([[[]], [[ 478testerror([[[]], [[
488L1:C1: missing closing ']' 479L1:C2: missing closing ']'
489[ 480[
490^ 481 ^
491]]) 482]])
492 483
493testerror([[[^]], [[ 484testerror([[[^]], [[
494L1:C1: missing closing ']' 485L1:C3: missing closing ']'
495[^ 486[^
496^ 487 ^
497]]) 488]])
498 489
499testerror([[[] ]], [[ 490testerror([[[] ]], [[
500L1:C1: missing closing ']' 491L1:C4: missing closing ']'
501[] 492[]
502^ 493 ^
503]]) 494]])
504 495
505testerror([[[^] ]], [[ 496testerror([[[^] ]], [[
506L1:C1: missing closing ']' 497L1:C6: missing closing ']'
507[^] 498[^]
508^ 499 ^
509]]) 500]])
510 501
511testerror([[[_-___-_|]], [[ 502testerror([[[_-___-_|]], [[
512L1:C1: missing closing ']' 503L1:C10: missing closing ']'
513[_-___-_| 504[_-___-_|
514^ 505 ^
515]]) 506]])
516 507
517-- testing MisTerm1 508-- testing MisTerm1
518 509
519testerror([['That is the question...]], [[ 510testerror([['That is the question...]], [[
520L1:C1: missing terminating single quote 511L1: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
527testerror([[Q <- "To be or not to be...]], [[ 518testerror([[Q <- "To be or not to be...]], [[
528L1:C6: missing terminating double quote 519L1:C28: missing terminating double quote
529Q <- "To be or not to be... 520Q <- "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
536testerror([[&'p'/&/!/'p'^'q']], [[
537L1:C7: expected a pattern after '&'
538&'p'/&/!/'p'^'q'
539 ^
540L1:C9: expected a pattern after '!'
541&'p'/&/!/'p'^'q'
542 ^
543L1:C14: expected a number after '^', '+' or '-' (no space)
544&'p'/&/!/'p'^'q'
545 ^
546]])
547
548testerror([[
549 A <- 'a' (B 'b'
550 B <- 'x' / !
551 C <- 'c'
552]], [[
553L1:C18: missing closing ')'
554 A <- 'a' (B 'b'
555 ^
556L2:C15: expected a pattern after '!'
557 B <- 'x' / !
558 ^
559]])
560
561testerror([['a' / &@ ('c' / 'd')]], [[
562L1:C8: expected a pattern after '&'
563'a' / &@ ('c' / 'd')
564 ^
565]])
566
567testerror([['x' / & / 'y']], [[
568L1:C8: expected a pattern after '&'
569'x' / & / 'y'
570 ^
571]])
572
573testerror([[&/'p'/!/'q']], [[
574L1:C2: expected a pattern after '&'
575&/'p'/!/'q'
576 ^
577L1:C8: expected a pattern after '!'
578&/'p'/!/'q'
579 ^
580]])
581
582testerror([['p'//'q']], [[
583L1:C5: expected a pattern after '/' or the label(s)
584'p'//'q'
585 ^
586]])
587
588testerror([[
589 S <- 'forgot to close / T
590 T <- 'T' & / 't'
591]], [[
592L1:C8: missing terminating single quote
593 S <- 'forgot to close / T
594 ^
595L2:C13: expected a pattern after '&'
596 T <- 'T' & / 't'
597 ^
598]])
599
600testerror([[
601 S <- [a-z / T
602 T <- 'x' / & / 'y'
603]], [[
604L1:C8: missing closing ']'
605 S <- [a-z / T
606 ^
607L2:C15: expected a pattern after '&'
608 T <- 'x' / & / 'y'
609 ^
610]])
611
612testerror([[
613 S <- ('p' -- comment
614]], [[
615L1: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
622testerror([[
623 X <- ('p / Q (R
624 / S))
625 Q <- 'q'
626 R <- 'r'
627 S <- 's'
628]], [[
629L1:C9: missing terminating single quote
630 X <- ('p / Q (R
631 ^
632L2:C9: unexpected characters after the pattern
633 / S))
634 ^
635]])
636
637testerror([[
638 A <- 'A' /{'lab'} B / !
639
640 B <- %{1, 2 3} 'b' / '6' & / 'B'
641
642 C <- A^B
643]], [[
644L1:C14: expected at least one label after '{'
645 A <- 'A' /{'lab'} B / !
646 ^
647L1:C26: expected a pattern after '!'
648 A <- 'A' /{'lab'} B / !
649 ^
650L3:C15: missing closing '}'
651 B <- %{1, 2 3} 'b' / '6' & / 'B'
652 ^
653L3:C29: expected a pattern after '&'
654 B <- %{1, 2 3} 'b' / '6' & / 'B'
655 ^
656L5:C10: expected a number after '^', '+' or '-' (no space)
657 C <- A^B
658 ^
659]])
660
661testerror([['p'/{1/'q'/&]], [[
662L1:C7: missing closing '}'
663'p'/{1/'q'/&
664 ^
665L1:C13: expected a pattern after '&'
666'p'/{1/'q'/&
667 ^
668]]) 522]])
669 523
670-- testing non-syntax errors 524-- testing non-syntax errors