# Do not edit this file - Generated by Perlito5 9.025

{
    package main;
    package Perlito5::Grammar::Print;
    use strict ;
    our %Print = ("print", 1, "printf", 1, "say", 1, "exec", 1, "system", 1);
    sub Perlito5::Grammar::Print::print_decl {
        my $str = $_[0];
        my $pos = $_[1];
        my $MATCH = {"str" => $str, "from" => $pos, "to" => $pos, };
        my $tmp = ((do {
            my $tmp101 = $MATCH->{"to"};
            ((("p" eq $str->[($MATCH->{"to"}) + 0]) && ("r" eq $str->[($MATCH->{"to"}) + 1]) && ("i" eq $str->[($MATCH->{"to"}) + 2]) && ("n" eq $str->[($MATCH->{"to"}) + 3]) && ("t" eq $str->[($MATCH->{"to"}) + 4]) && ("f" eq $str->[($MATCH->{"to"}) + 5]) && ($MATCH->{"to"} += 6))) || ($MATCH->{"to"} = $tmp101, (("p" eq $str->[($MATCH->{"to"}) + 0]) && ("r" eq $str->[($MATCH->{"to"}) + 1]) && ("i" eq $str->[($MATCH->{"to"}) + 2]) && ("n" eq $str->[($MATCH->{"to"}) + 3]) && ("t" eq $str->[($MATCH->{"to"}) + 4]) && ($MATCH->{"to"} += 5))) || ($MATCH->{"to"} = $tmp101, (("s" eq $str->[($MATCH->{"to"}) + 0]) && ("a" eq $str->[($MATCH->{"to"}) + 1]) && ("y" eq $str->[($MATCH->{"to"}) + 2]) && ($MATCH->{"to"} += 3))) || ($MATCH->{"to"} = $tmp101, (("e" eq $str->[($MATCH->{"to"}) + 0]) && ("x" eq $str->[($MATCH->{"to"}) + 1]) && ("e" eq $str->[($MATCH->{"to"}) + 2]) && ("c" eq $str->[($MATCH->{"to"}) + 3]) && ($MATCH->{"to"} += 4))) || ($MATCH->{"to"} = $tmp101, (("s" eq $str->[($MATCH->{"to"}) + 0]) && ("y" eq $str->[($MATCH->{"to"}) + 1]) && ("s" eq $str->[($MATCH->{"to"}) + 2]) && ("t" eq $str->[($MATCH->{"to"}) + 3]) && ("e" eq $str->[($MATCH->{"to"}) + 4]) && ("m" eq $str->[($MATCH->{"to"}) + 5]) && ($MATCH->{"to"} += 6)))
        }));
        $tmp ? $MATCH : undef
    }
    sub Perlito5::Grammar::Print::the_object {
        my $str = $_[0];
        my $pos = $_[1];
        my $MATCH = {"str" => $str, "from" => $pos, "to" => $pos, };
        my $tmp = (((do {
            my $tmp107 = $MATCH->{"to"};
            (((do {
                my $tmp = $MATCH;
                $MATCH = {"from" => $tmp->{"to"}, "to" => $tmp->{"to"}, };
                my $res = (("\$" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1));
                $MATCH = $tmp;
                $res ? 1 : 0
            }) && (do {
                my $m2 = Perlito5::Grammar::Sigil::term_sigil($str, $MATCH->{"to"});
                if ($m2) {
                    $MATCH->{"to"} = $m2->{"to"};
                    $MATCH->{"Perlito5::Grammar::Sigil::term_sigil"} = $m2;
                    1
                }
                else {;
                    0
                }
            }) && (do {
                my $tmp = $MATCH;
                $MATCH = {"from" => $tmp->{"to"}, "to" => $tmp->{"to"}, };
                my $res = (("+" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1));
                $MATCH = $tmp;
                $res ? 0 : 1
            }) && (do {
                $MATCH->{"capture"} = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Sigil::term_sigil"})->[1];
                1
            }))) || ($MATCH->{"to"} = $tmp107, ((do {
                my $tmp = $MATCH;
                $MATCH = {"from" => $tmp->{"to"}, "to" => $tmp->{"to"}, };
                my $res = (("{" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1));
                $MATCH = $tmp;
                $res ? 1 : 0
            }) && (do {
                my $m2 = Perlito5::Grammar::Block::block($str, $MATCH->{"to"});
                if ($m2) {
                    $MATCH->{"to"} = $m2->{"to"};
                    $MATCH->{"Perlito5::Grammar::Block::block"} = $m2;
                    1
                }
                else {;
                    0
                }
            }) && (do {
                $MATCH->{"capture"} = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Block::block"});
                1
            }))) || ($MATCH->{"to"} = $tmp107, ((do {
                my $m2 = Perlito5::Grammar::Print::typeglob($str, $MATCH->{"to"});
                if ($m2) {
                    $MATCH->{"to"} = $m2->{"to"};
                    $MATCH->{"typeglob"} = $m2;
                    1
                }
                else {;
                    0
                }
            }) && (do {
                $MATCH->{"capture"} = Perlito5::Match::flat($MATCH->{"typeglob"});
                1
            })))
        }) && (do {
            my $m2 = Perlito5::Grammar::Space::opt_ws($str, $MATCH->{"to"});
            if ($m2) {
                $MATCH->{"to"} = $m2->{"to"};
                1
            }
            else {;
                0
            }
        }) && (do {
            my $tmp = $MATCH;
            $MATCH = {"from" => $tmp->{"to"}, "to" => $tmp->{"to"}, };
            my $res = (do {
                my $tmp108 = $MATCH->{"to"};
                ((("," eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1))) || ($MATCH->{"to"} = $tmp108, (("?" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1))) || ($MATCH->{"to"} = $tmp108, (("-" eq $str->[($MATCH->{"to"}) + 0]) && (">" eq $str->[($MATCH->{"to"}) + 1]) && ($MATCH->{"to"} += 2))) || ($MATCH->{"to"} = $tmp108, (("[" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1))) || ($MATCH->{"to"} = $tmp108, (("{" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1)))
            });
            $MATCH = $tmp;
            $res ? 0 : 1
        }) && (do {
            my $pos = $MATCH->{"to"};
            my $s = $str->[$pos];
            if ($s eq "+") {
                my $m = Perlito5::Grammar::Space::ws($MATCH->{"str"}, $pos + 1);
                if ($m) {;
                    return
                }
            }
            else {
                my $m = Perlito5::Grammar::Precedence::op_parse($MATCH->{"str"}, $pos, 1);
                my $next_op = $m ? Perlito5::Match::flat($m)->[1] : '';
                my $is_infix = Perlito5::Grammar::Precedence::is_fixity_type("infix", $next_op);
                $is_infix && $next_op ne "<<" && return
            }
            1
        })));
        $tmp ? $MATCH : undef
    }
    sub Perlito5::Grammar::Print::typeglob {
        my $str = $_[0];
        my $pos = $_[1];
        my $MATCH = {"str" => $str, "from" => $pos, "to" => $pos, };
        my $tmp = (((do {
            my $m2 = Perlito5::Grammar::Print::typeglob_bareword($str, $MATCH->{"to"});
            if ($m2) {
                $MATCH->{"to"} = $m2->{"to"};
                $MATCH->{"typeglob_bareword"} = $m2;
                1
            }
            else {;
                0
            }
        }) && (do {
            my $tmp = $MATCH;
            $MATCH = {"from" => $tmp->{"to"}, "to" => $tmp->{"to"}, };
            my $res = (("(" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1));
            $MATCH = $tmp;
            $res ? 0 : 1
        }) && (do {
            $MATCH->{"capture"} = Perlito5::Match::flat($MATCH->{"typeglob_bareword"});
            1
        })));
        $tmp ? $MATCH : undef
    }
    sub Perlito5::Grammar::Print::typeglob_bareword {
        my $str = $_[0];
        my $pos = $_[1];
        my $p = $pos;
        my $m_namespace = Perlito5::Grammar::optional_namespace_before_ident($str, $p);
        my $namespace = Perlito5::Match::flat($m_namespace);
        $p = $m_namespace->{"to"};
        my $m_name = Perlito5::Grammar::ident($str, $p);
        if (!$m_name) {
            if ($namespace) {
                $m_namespace->{"capture"} = Perlito5::AST::Var::->new("sigil", "::", "name", '', "namespace", $namespace);
                return $m_namespace
            }
            return
        }
        my $name = Perlito5::Match::flat($m_name);
        $p = $m_name->{"to"};
        my $s = $str->[$p];
        my $s2 = $s . ($str->[$p + 1]);
        if ($s2 eq "::") {
            $m_name->{"to"} = $p + 2;
            $m_name->{"capture"} = Perlito5::AST::Var::->new("sigil", "::", "name", '', "namespace", $namespace . "::" . $name);
            return $m_name
        }
        my $effective_name = ($namespace || $Perlito5::PKG_NAME) . "::" . $name;
        if (exists($Perlito5::PROTO->{$effective_name}) || exists(&{$effective_name})) {;
            return
        }
        if ((!$namespace || $namespace eq "CORE") && exists($Perlito5::CORE_PROTO->{"CORE::" . $name})) {;
            return
        }
        my $full_name = $name;
        $namespace && ($full_name = $namespace . "::" . $name);
        $m_name->{"capture"} = Perlito5::AST::Var::->new("sigil", "::", "name", '', "namespace", $full_name);
        return $m_name
    }
    sub Perlito5::Grammar::Print::print_ast {
        (my $decl, my $the_object, my $expr) = @_;
        Perlito5::AST::Apply::->new("namespace", '', "code", $decl, "special_arg", $the_object, "arguments", $expr)
    }
    sub Perlito5::Grammar::Print::term_print {
        my $str = $_[0];
        my $pos = $_[1];
        my $MATCH = {"str" => $str, "from" => $pos, "to" => $pos, };
        my $tmp = (((do {
            my $m2 = Perlito5::Grammar::Print::print_decl($str, $MATCH->{"to"});
            if ($m2) {
                $MATCH->{"to"} = $m2->{"to"};
                $MATCH->{"print_decl"} = $m2;
                1
            }
            else {;
                0
            }
        }) && (do {
            my $m2 = Perlito5::Grammar::Space::opt_ws($str, $MATCH->{"to"});
            if ($m2) {
                $MATCH->{"to"} = $m2->{"to"};
                1
            }
            else {;
                0
            }
        }) && (do {
            my $tmp154 = $MATCH->{"to"};
            (((("(" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1)) && (do {
                my $m2 = Perlito5::Grammar::Space::opt_ws($str, $MATCH->{"to"});
                if ($m2) {
                    $MATCH->{"to"} = $m2->{"to"};
                    1
                }
                else {;
                    0
                }
            }) && (do {
                $MATCH->{"_scope"} = $#Perlito5::SCOPE_STMT;
                1
            }) && (do {
                my $tmp155 = $MATCH->{"to"};
                (((do {
                    my $m2 = Perlito5::Grammar::Print::the_object($str, $MATCH->{"to"});
                    if ($m2) {
                        $MATCH->{"to"} = $m2->{"to"};
                        $MATCH->{"the_object"} = $m2;
                        1
                    }
                    else {;
                        0
                    }
                }) && (do {
                    my $m2 = Perlito5::Grammar::Expression::list_parse($str, $MATCH->{"to"});
                    if ($m2) {
                        $MATCH->{"to"} = $m2->{"to"};
                        $MATCH->{"Perlito5::Grammar::Expression::list_parse"} = $m2;
                        1
                    }
                    else {;
                        0
                    }
                }))) || ($MATCH->{"to"} = $tmp155, (do {
                    $#Perlito5::SCOPE_STMT = $MATCH->{"_scope"};
                    return;
                    1
                }))
            }) && ((")" eq $str->[($MATCH->{"to"}) + 0]) && ($MATCH->{"to"} += 1)) && (do {
                my $list = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Expression::list_parse"});
                !ref($list) && return;
                $MATCH->{"capture"} = ["term", Perlito5::Grammar::Print::print_ast(Perlito5::Match::flat($MATCH->{"print_decl"}), Perlito5::Match::flat($MATCH->{"the_object"}), Perlito5::Grammar::Expression::expand_list($list))];
                1
            }))) || ($MATCH->{"to"} = $tmp154, ((do {
                $MATCH->{"_scope"} = $#Perlito5::SCOPE_STMT;
                1
            }) && (do {
                my $tmp156 = $MATCH->{"to"};
                (((do {
                    my $m2 = Perlito5::Grammar::Print::the_object($str, $MATCH->{"to"});
                    if ($m2) {
                        $MATCH->{"to"} = $m2->{"to"};
                        $MATCH->{"the_object"} = $m2;
                        1
                    }
                    else {;
                        0
                    }
                }) && (do {
                    my $m2 = Perlito5::Grammar::Expression::list_parse($str, $MATCH->{"to"});
                    if ($m2) {
                        $MATCH->{"to"} = $m2->{"to"};
                        $MATCH->{"Perlito5::Grammar::Expression::list_parse"} = $m2;
                        1
                    }
                    else {;
                        0
                    }
                }))) || ($MATCH->{"to"} = $tmp156, (do {
                    $#Perlito5::SCOPE_STMT = $MATCH->{"_scope"};
                    return;
                    1
                }))
            }) && (do {
                my $list = Perlito5::Match::flat($MATCH->{"Perlito5::Grammar::Expression::list_parse"});
                !ref($list) && return;
                $MATCH->{"capture"} = ["term", Perlito5::Grammar::Print::print_ast(Perlito5::Match::flat($MATCH->{"print_decl"}), Perlito5::Match::flat($MATCH->{"the_object"}), Perlito5::Grammar::Expression::expand_list($list))];
                1
            })))
        })));
        $tmp ? $MATCH : undef
    }
    Perlito5::Grammar::Precedence::add_term("print", \&term_print);
    Perlito5::Grammar::Precedence::add_term("printf", \&term_print);
    Perlito5::Grammar::Precedence::add_term("say", \&term_print);
    Perlito5::Grammar::Precedence::add_term("exec", \&term_print);
    Perlito5::Grammar::Precedence::add_term("system", \&term_print);
    1
}
;1
