/* pokefmt.pk - Poke support code for pokefmt application.  */

/* Copyright (C) 2023, 2024, 2025 Mohammad-Reza Nabipoor.  */

/* This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/* Printer for Poke expressions (Poke code between "%(" and ")%".

   User can re-write this function to customize the expression printer.  */

fun pokefmt_expr_printer = (any val) void:
{
  _pkl_print_any (val);
}

/* Default exception handler.

   User can re-write this function to customize the default exception
   handling.  */

fun pokefmt_exception_handler = (Exception exc) void:
{
  if (exc.code != EC_exit && exc.code != EC_signal)
    {
      printf ("unhandled %<warning:%s exception%>\n",
              exc.name == "" ? "unknown" : exc.name);

      if (exc.location != "" || exc.msg != "")
        {
          if (exc.location != "")
            print (exc.location + " ");
          print (exc.msg + "\n");
        }
    }
}
