PreviousUpNext

15.4.620  src/lib/compiler/front/typer-stuff/symbolmapstack/prettyprint-symbolmapstack.pkg

## prettyprint-symbolmapstack.pkg

# Compiled by:
#     src/lib/compiler/core.sublib

stipulate
    package mld =  module_level_declarations;                                   # module_level_declarations     is from   src/lib/compiler/front/typer-stuff/modules/module-level-declarations.pkg
    package pp  =  standard_prettyprinter;                                      # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
    package sxe =  symbolmapstack_entry;                                        # symbolmapstack_entry          is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack-entry.pkg
    package sy  =  symbol;                                                      # symbol                        is from   src/lib/compiler/front/basics/map/symbol.pkg
    package syx =  symbolmapstack;                                              # symbolmapstack                is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg
    package tdt =  type_declaration_types;                                      # type_declaration_types        is from   src/lib/compiler/front/typer-stuff/types/type-declaration-types.pkg
    package upl =  unparse_package_language;                                    # unparse_package_language      is from   src/lib/compiler/front/typer/print/unparse-package-language.pkg
    package ut  =  unparse_type;                                                # unparse_type                  is from   src/lib/compiler/front/typer/print/unparse-type.pkg
    package uv  =  unparse_value;                                               # unparse_value                 is from   src/lib/compiler/front/typer/print/unparse-value.pkg
    package vac =  variables_and_constructors;                                  # variables_and_constructors    is from   src/lib/compiler/front/typer-stuff/deep-syntax/variables-and-constructors.pkg

    Pp = pp::Pp;

    include package   symbolmapstack_entry;
herein


    package   prettyprint_symbolmapstack
    :         Prettyprint_Symbolmapstack                                        # Prettyprint_Symbolmapstack    is from   src/lib/compiler/front/typer-stuff/symbolmapstack/prettyprint-symbolmapstack.api
    {
                                                                                # 




        # 2007-12-05: At the moment we are called only from
        #
        #       src/lib/compiler/toplevel/main/translate-raw-syntax-to-execode-g.pkg
        #
        fun prettyprint_symbolmapstack  (pp:Pp)  symbolmapstack # "pps" == "prettyprint_stream"
            =
            {    map
                     do_symbol_binding
                     symbolmapstack_contents; 

                 pp.newline();
            }
            where

                 symbolmapstack_contents                        # A list of (symbol, value) pairs.
                     = 
                     syx::to_sorted_list  symbolmapstack;


                 fun do_symbol_binding (symbol, binding)                        # symbol        is from   src/lib/compiler/front/basics/map/symbol.pkg
                     =
                     {
                         fun print_tagged_name ()
                              =
                              {   namespace =   sy::name_space_to_string (sy::name_space symbol);
                                  name      =                             sy::name       symbol;

                                  pp.lit   (namespace + " " + name + ":  " );
                              };

                         fun print_name ()
                              =
                              {   name      =   sy::name       symbol;

                                  pp.lit   name;
                              };

                          case binding

                               NAMED_VARIABLE             (v:   vac::Variable)
                                   =>
                                   uv::unparse_variable
                                       pp
                                       (symbolmapstack, v);

                               NAMED_CONSTRUCTOR          (v:   tdt::Valcon)
                                   =>
                                   {   uv::unparse_constructor
                                           pp
                                           symbolmapstack
                                           v;

                                       pp.lit   ";";
                                   };

                               NAMED_TYPE                 (t:   tdt::Type)
                                   =>
                                   {   ut::unparse_type
                                           symbolmapstack                       # XXX BUGGO FIXME we need to standardize on "stream symbolmapstack" or "symbolmapstack stream" arg order.
                                           pp
                                           t;

                                       pp.lit   ";";
                                   };

                               NAMED_API                  (m:   mld::Api)
                                   =>
                                   {   pp.newline();
                                       pp.lit  "api ";
                                       print_name ();   
                                       pp.newline();
                                       pp.lit  "=";
                                       pp.newline();
                                       upl::unparse_api
                                           pp
                                           (m, symbolmapstack, /* max prettyprint recursion depth: */ 200);
                                   };

                               NAMED_PACKAGE              (m:   mld::Package)
                                   =>
                                   {   pp.newline();
                                       pp.lit  "package ";
                                       print_name ();   
                                       pp.newline();
                                       pp.lit  ":";
                                       pp.newline();
                                       upl::unparse_package
                                           pp
                                           (m, symbolmapstack, /* max prettyprint recursion depth: */ 200);
                                   };

                               NAMED_GENERIC_API          (m:   mld::Generic_Api)
                                   =>
                                   {   pp.newline();
                                       pp.lit  "generic_api ";
                                       print_name ();   
                                       pp.newline();
                                       pp.lit  ":";
                                       pp.newline();
                                       upl::unparse_generic_api
                                           pp
                                           (m, symbolmapstack, /* max prettyprint recursion depth: */ 200);
                                   };
    #                          print_tagged_name ();

                               NAMED_GENERIC              (m:   mld::Generic)
                                   =>
                                   {   pp.newline();
                                       pp.lit  "generic ";
                                       print_name ();   
                                       pp.newline();
                                       pp.lit  ":";
                                       pp.newline();
                                       upl::unparse_generic
                                           pp
                                           (m, symbolmapstack, /* max prettyprint recursion depth: */ 200);
                                   };
    #                          print_tagged_name ();

                               NAMED_FIXITY               (f:   fixity::Fixity)
                                   =>
                                   print_tagged_name ();
                          esac;     

                          pp.newline();
                     };                         # fun do_symbol_binding    in   fun prettyprint_symbolmapstack
            end;
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext