From 2e4d29589dd716dfb879d74b6da8d86c544f6d69 Mon Sep 17 00:00:00 2001 From: Vadim Belman Date: Thu, 29 Aug 2019 22:39:27 -0400 Subject: [PATCH] Revert accidentally applied patch for 6.c version of Grammar --- src/core.c/Grammar.pm6 | 61 ++---------------------------------------- 1 file changed, 2 insertions(+), 59 deletions(-) diff --git a/src/core.c/Grammar.pm6 b/src/core.c/Grammar.pm6 index db77f082a54..2c9d637ba3d 100644 --- a/src/core.c/Grammar.pm6 +++ b/src/core.c/Grammar.pm6 @@ -1,62 +1,5 @@ my class Grammar is Match { - # (oughta be down in Match or even nqp really) - method locprepost() { - my $orig = self.orig; - my $marked = self.?MARKED('ws'); - my $pos = $marked && index(" }])>ยป", substr($orig, self.pos, 1)) < 0 ?? $marked.from !! self.pos; - - my $prestart = $pos - 40; - $prestart = 0 if $prestart < 0; - my $pre = substr($orig, $prestart, $pos - $prestart); - $pre = $pre.subst(/.*\n/, ""); - $pre = '' if $pre eq ''; - - my $postchars = $pos + 40 > chars($orig) ?? chars($orig) - $pos !! 40; - my $post = substr($orig, $pos, $postchars); - $post = $post.subst(/\n.*/, ""); - $post = '' if $post eq ''; - - [$pre, $post] - } - - # stolen and trimmed down from World - method typed_exception(X::Comp $ex, *%opts) { - # If the highwater is beyond the current position, force the cursor to that location. - my @expected; - my $high = self.'!highwater'(); - - if $high >= self.pos() { - self.'!cursor_pos'($high); - my $highexpect := self.'!highexpect'(); - if nqp::islist($highexpect) { - my %seen; - for ^nqp::elems($highexpect) { - my $x = nqp::hllizefor(nqp::shift($highexpect),'perl6'); - push @expected, $x unless %seen{$x}++; - } - @expected .= sort; - } - } - - my @locprepost := self.locprepost(); - # Build and throw exception object. - %opts = HLL::Compiler.lineof(self.orig, self.pos, :cache(1)); - # only set if it's not already set: - %opts //= self.pos; - %opts
             = @locprepost[0];
-        %opts            = @locprepost[1];
-        %opts      = @expected if @expected;
-        %opts = 1;
-        Failure.new($ex.new(|%opts))
-    }
-
-    method SETFAIL($failed, :$filename) {
-        return Nil unless self.defined && nqp::isge_s(CLIENT::LEXICAL::, 'e');
-        self.'!cursor_pos'($failed.pos);
-        self.typed_exception(X::Syntax::Confused, filename => ($filename // ""))
-    }
-
     method parse(\target, :$rule, :$args, Mu :$actions, :$filename) is raw {
         my $*LINEPOSCACHE;
         nqp::stmts(
@@ -85,9 +28,9 @@ my class Grammar is Match {
                   ),
                   $match := ($cursor := $cursor.'!cursor_next'()).MATCH
                 ),
-                $match || $grammar.SETFAIL($match, :$filename),
+                $match || Nil,
               ),
-              $grammar.SETFAIL($cursor, :$filename),
+              Nil,
             )
           )
         )