my class Grammar is Cursor { 
    method parse($target, :$rule = 'TOP',  Parcel :$args = (), Mu :$actions = Mu, *%opt) {
        my $*ACTIONS = $actions;
        my $result = 
            self."!cursor_init"($target, |%opt)."$rule"(|$args).MATCH;
        $result = Nil unless $result.to == $target.chars;
        nqp::getlexcaller('$/') = $result;
    }
    method subparse($target, :$rule = 'TOP', Parcel :$args = (),  Mu :$actions = Mu, *%opt) {
        my $*ACTIONS = $actions;
        nqp::getlexcaller('$/') =
            self."!cursor_init"($target, |%opt)."$rule"(|$args).MATCH;
    }
    method parsefile(Cool $filename as Str, *%opts) {
        my $fh    := open($filename);
        my $match := self.parse($fh.slurp, |%opts);
        $fh.close;
        nqp::getlexcaller('$/') = $match;
    }
}

# vim: ft=perl6 expandtab sw=4

my class Grammar is Cursor { 
    method parse($target, :$rule = 'TOP',  Parcel :$args = (), Mu :$actions = Mu, *%opt) {
        my $*ACTIONS = $actions;
        my $result = 
            self."!cursor_init"($target, |%opt)."$rule"(|$args).MATCH;
        $result = Nil unless $result.to == $target.chars;
        nqp::getlexcaller('$/') = $result;
    }
    method subparse($target, :$rule = 'TOP', Parcel :$args = (),  Mu :$actions = Mu, *%opt) {
        my $*ACTIONS = $actions;
        nqp::getlexcaller('$/') =
            self."!cursor_init"($target, |%opt)."$rule"(|$args).MATCH;
    }
    method parsefile(Cool $filename as Str, *%opts) {
        my $match := self.parse($filename.IO.slurp, |%opts);
        nqp::getlexcaller('$/') = $match;
    }

method wemusthavethishereotherwiserakudowontcompile { }

}

# vim: ft=perl6 expandtab sw=4

Simplify .parsefile, spotted by masak++
Simplify .parsefile, spotted by masak++

Please note there is a dummy method in there, as without it, the settings
would not compile: instead you would get:

Stage parse      : moar(22277,0x7fff7bf29310) malloc: *** error for object 0x7fda5c32bf40: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
