Help language development. Donate to The Perl Foundation

Grammar::PrettyErrors cpan:BDUGGAN last updated on 2019-10-09


use Grammar::PrettyErrors;

use Test;
plan 5;

grammar G does Grammar::PrettyErrors {
  rule TOP {
    a b

my $g =,:!colors);

ok so $g.parse('a b'), 'parsed a valid string';
nok $g.parse('a   c'), 'failed on an invalid string';
is $, q:to/MSG/, "nice report";
      1 │▶a   c

    Uh oh, something went wrong around line 1.
    Unable to parse TOP.

$*ERR.^find_method('print').wrap: -> |c { }
ok so G.parse('a b'), 'parsed a valid string, class method';
nok G.parse('a c'), 'class method failed on an invalid string';