PreviousUpNext

15.4.619  src/lib/compiler/front/typer-stuff/symbolmapstack/latex-print-symbolmapstack.pkg

## latex-print-symbolmapstack.pkg

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

# Invoked from src/lib/compiler/front/typer-stuff/symbolmapstack/latex-print-compiler-state.pkg

# This is a clone of prettyprint-symbolmapstack.pkg
# specialized to produce LaTeX output intended to be
# run through Hevea to produce online HTML docs of
# our interfaces.
#

stipulate
    include symbolmapstack_entry;                                               # symbolmapstack_entry          is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack-entry.pkg
    #
    package mld =  module_level_declarations;                                   # module_level_declarations     is from   src/lib/compiler/front/typer-stuff/modules/module-level-declarations.pkg
    package pp  =  prettyprint;                                                 # prettyprint                   is from   src/lib/prettyprint/big/src/prettyprint.pkg
    package psx =  posixlib;                                                    # posixlib                      is from   src/lib/std/src/psx/posixlib.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 ty  =  types;                                                       # types                         is from   src/lib/compiler/front/typer-stuff/types/types.pkg
    package vac =  variables_and_constructors;                                  # variables_and_constructors    is from   src/lib/compiler/front/typer-stuff/deep-syntax/variables-and-constructors.pkg
herein


    package   latex_print_symbolmapstack
    :         Latex_Print_Symbolmapstack                                        # Latex_Print_Symbolmapstack    is from   src/lib/compiler/front/typer-stuff/symbolmapstack/latex-print-symbolmapstack.api
    {


                                                                                # latex_print_value             is from   src/lib/compiler/front/typer/print/latex-print-value.pkg
                                                                                # latex_print_type              is from   src/lib/compiler/front/typer/print/latex-print-type.pkg
                                                                                # latex_print_package_language  is from   src/lib/compiler/front/typer/print/latex-print-package-language.pkg


        fun is_file  filename
            =
            psx::stat::is_file (psx::stat  filename)
            except
                _ = FALSE;

        # 2007-12-05: At the moment we are called only from
        #
        #   src/lib/compiler/toplevel/main/translate-raw-syntax-to-execode-g.pkg
        #
        fun latex_print_symbolmapstack
                pps                         # "pps" == "prettyprint_stream"
                { directory:       String,
                  filename_prefix: String,
                  filename_suffix: String
                }
                symbolmapstack
            =
            {    map
                     do_symbol_binding
                     symbolmapstack_contents; 

                 pp::newline pps;
            }
            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::string  pps   (namespace + " " + name + ":  " );
                              };

                         backslash_latex_special_chars = latex_print_value::backslash_latex_special_chars;

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

                                  pp::string  pps   name;
                              };

                         case binding

                               NAMED_VARIABLE             (v:   vac::Variable)
                                   =>
                                   latex_print_value::latex_print_variable
                                       pps
                                       (symbolmapstack, v);

                               NAMED_CONSTRUCTOR          (v:   ty::Valcon)
                                   =>
                                   {   latex_print_value::latex_print_constructor
                                           pps
                                           symbolmapstack
                                           v;

                                       pp::string  pps   ";";
                                   };

                               NAMED_TYPE                 (t:   ty::Typ)
                                   =>
                                   {   latex_print_type::latex_print_type
                                           symbolmapstack                     # XXX BUGGO FIXME we need to standardize on "stream symbolmapstack" or "symbolmapstack stream" arg order.
                                           pps
                                           t;

                                       pp::string  pps   ";";
                                   };

                               NAMED_API                  (our_api:   mld::Api)
                                   =>
                                   {
                                       # Open a separate   doc/tex/tmp*.tex
                                       # output file for this api:
                                       #  
                                       api_name  =   sy::name       symbol;

                                       # Filename for autogenerated content:
                                       #
                                       prettyprint_filepath
                                           =
                                           directory + "/"   +
                                           filename_prefix   +
                                           "api-"            +
                                           api_name          +
                                           filename_suffix;


                                       # Filename for matching top-of-file manually generated content, if any:
                                       #
                                       top_manually_generated_content_filename
                                           =
                                           "top-"            +
                                           "api-"            +
                                           api_name          +
                                           filename_suffix;
                                       #
                                       top_manually_generated_content_filepath
                                           =
                                           directory + "/"   +  top_manually_generated_content_filename;


                                       # Filename for matching bottom-of-file manually generated content, if any:
                                       #
                                       bot_manually_generated_content_filename
                                           =
                                           "bot-"            +
                                           "api-"            +
                                           api_name          +
                                           filename_suffix;
                                       #
                                       bot_manually_generated_content_filepath
                                           =
                                           directory + "/"   +  bot_manually_generated_content_filename;


                                       pp  = prettyprinter::make_file_prettyprinter  prettyprint_filepath;
                                       pps = pp.stream;


                                       pp::string   pps  ("\\inde" + "x[api]{" + (backslash_latex_special_chars api_name) + "}");
                                       pp::newline  pps;

                                       pp::string   pps  ("\\labe" + "l{api:"  + (backslash_latex_special_chars api_name) + "}");
                                       pp::newline  pps;

                                       # Include top-of-file manually generated content if available:
                                       #
                                       if (is_file  top_manually_generated_content_filepath)
                                           pp::newline  pps;
                                           pp::string   pps  ("\\in" + "put{" + top_manually_generated_content_filename + "}");                               pp::newline  pps;      pp::newline  pps;
                                           pp::string   pps  "{\\tiny \\it The above information is manually maintained and may contain errors.}";            pp::newline  pps;      pp::newline  pps;
                                       fi;  

                                       pp::string   pps  ("\\begi" + "n{verbatim}");        # The break is to avoid confusing Hevea when it formats this file.
                                       pp::newline  pps;

                                       # Upon return from next call, this will be a
                                       # list of TeX index entry strings like
                                       # "(backslash)index[fun]{foo}" or such:
                                       #
                                       index_entries = REF [];

                                       latex_print_package_language::latex_print_api
                                           pps
                                           (our_api, symbolmapstack, /* max prettyprint recursion depth: */ 200, index_entries );

                                       pp::newline  pps;
                                       pp::string   pps  ("\\en" + "d{verbatim}");          # The break is to avoid confusing Hevea when it formats this file.

                                       # Print any index table entries generated during the above:
                                       #
                                       foreach *index_entries .{
                                           pp::string   pps  #entry;
                                       };

                                       # Include bottom-of-file manually generated content if available:
                                       #
                                       if (is_file  bot_manually_generated_content_filepath)
                                           pp::newline  pps;
                                           pp::string   pps  "{\\tiny \\it The following information is manually maintained and may contain errors.}";            pp::newline  pps;      pp::newline  pps;
                                           pp::string   pps  ("\\in" + "put{" + bot_manually_generated_content_filename + "}");                                   pp::newline  pps;
                                       fi;  

                                       pp::newline  pps;
                                       pp::newline  pps;
                                       pp::string   pps   "% This file generated by do_symbol_binding  from";                                                     pp::newline  pps;
                                       pp::string   pps   "%    src/lib/compiler/front/typer-stuff/symbolmapstack/latex-print-symbolmapstack.pkg";           pp::newline  pps;

                                       pp.flush ();
                                       pp.close ();
                                   };

                               NAMED_PACKAGE              (our_pkg:   mld::Package)
                                   =>
                                   {
                                       # Open a separate   doc/tex/tmp*.tex
                                       # output file for this pkg:
                                       #  
                                       pkg_name  =   sy::name       symbol;

                                       # Filename for autogenerated content:
                                       #
                                       prettyprint_filepath
                                           =
                                           directory + "/"   +
                                           filename_prefix   +
                                           "pkg-"            +
                                           pkg_name          +
                                           filename_suffix;

                                       # Filename for matching top-of-file manually generated content, if any:
                                       #
                                       top_manually_generated_content_filename
                                           =
                                           "top-"            +
                                           "pkg-"            +
                                           pkg_name          +
                                           filename_suffix;
                                       #
                                       top_manually_generated_content_filepath
                                           =
                                           directory + "/"   +  top_manually_generated_content_filename;

                                       # Filename for matching bottom-of-file manually generated content, if any:
                                       #
                                       bot_manually_generated_content_filename
                                           =
                                           "bot-"            +
                                           "pkg-"            +
                                           pkg_name          +
                                           filename_suffix;
                                       #
                                       bot_manually_generated_content_filepath
                                           =
                                           directory + "/"   +  bot_manually_generated_content_filename;

                                       pp  = prettyprinter::make_file_prettyprinter  prettyprint_filepath;
                                       pps = pp.stream;


                                       pp::string   pps  ("\\inde" + "x[pkg]{" + (backslash_latex_special_chars pkg_name) + "}");
                                       pp::newline  pps;

                                       pp::string   pps  ("\\labe" + "l{pkg:" + (backslash_latex_special_chars  pkg_name) + "}");
                                       pp::newline  pps;

                                       # Include top-of-file manually generated content if available:
                                       #
                                       if (is_file  top_manually_generated_content_filepath)
                                           pp::newline  pps;
                                           pp::string   pps  ("\\in" + "put{" + top_manually_generated_content_filename + "}");                               pp::newline  pps;      pp::newline  pps;
                                           pp::string   pps  "{\\tiny \\it The above information is manually maintained and may contain errors.}";            pp::newline  pps;      pp::newline  pps;
                                       fi;  

                                       pp::string   pps  ("\\begi" + "n{verbatim}");        # The break is to avoid confusing Hevea when it formats this file.
                                       pp::newline  pps;

                                       latex_print_package_language::latex_print_package
                                           pps
                                           (our_pkg, symbolmapstack, /* max prettyprint recursion depth: */ 200, /*currently unused index entry return channel:*/ REF []);

                                       pp::newline  pps;
                                       pp::string   pps  ("\\en" + "d{verbatim}");          # The break is to avoid confusing Hevea when it formats this file.

                                       # Include manually generated bottom-of-file content if available:
                                       #
                                       if (is_file  bot_manually_generated_content_filepath)
                                           pp::newline  pps;
                                           pp::string   pps  "{\\tiny\\it The following information is manually maintained and may contain errors.}";             pp::newline  pps;      pp::newline  pps;
                                           pp::string   pps  ("\\in" + "put{" + bot_manually_generated_content_filename + "}");                                   pp::newline  pps;
                                       fi;  

                                       pp::newline  pps;
                                       pp::newline  pps;
                                       pp::string   pps   "% This file generated by do_symbol_binding  from";                                                     pp::newline  pps;
                                       pp::string   pps   "%    src/lib/compiler/front/typer-stuff/symbolmapstack/latex-print-symbolmapstack.pkg";           pp::newline  pps;

                                       pp.flush ();
                                       pp.close ();


    #                                   pp::newline pps;
    #                                  pp::string  pps  "package ";
    #                                   print_name ();      
    #                                  pp::newline pps;
    #                                  pp::string  pps  ":";
    #                                  pp::newline pps;
    #                                   latex_print_package_language::latex_print_package
    #                                      pps
    #                                       (m, symbolmapstack, /* max prettyprint recursion depth: */ 200);
                                   };

                               NAMED_GENERIC_API          (m:   mld::Generic_Api)
                                   =>
                                   {   pp::newline pps;
                                       pp::string  pps  "generic_api ";
                                       print_name ();       
                                       pp::newline pps;
                                       pp::string  pps  ":";
                                       pp::newline pps;
                                       latex_print_package_language::latex_print_generic_api
                                           pps
                                           (m, symbolmapstack, /* max prettyprint recursion depth: */ 200, /*currently unused index entry return channel:*/ REF []);
                                   };
    #                              print_tagged_name ();

                               NAMED_GENERIC              (m:   mld::Generic)
                                   =>
                                   {   pp::newline pps;
                                       pp::string  pps  "generic ";
                                       print_name ();       
                                       pp::newline pps;
                                       pp::string  pps  ":";
                                       pp::newline pps;
                                       latex_print_package_language::latex_print_generic
                                           pps
                                           (m, symbolmapstack, /* max prettyprint recursion depth: */ 200, /*currently unused index entry return channel:*/ REF []);
                                   };
    #                              print_tagged_name ();

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

                          pp::newline pps;
                     };                             # fun do_symbol_binding    in   fun prettyprint_symbolmapstack


            end;
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext