PreviousUpNext

15.3.290  src/lib/compiler/toplevel/interact/read-eval-print-loop.api

## read-eval-print-loop.api 
 
# Compiled by:
#     src/lib/compiler/core.sublib



###        "The price of reliability is the pursuit of the utmost simplicity.
###         It is a price which the very rich find most hard to pay."
###
###                                                 -- E.W. Dijkstra



stipulate
    package acf =  anormcode_form;                                                                      # anormcode_form                is from   src/lib/compiler/back/top/anormcode/anormcode-form.pkg
    package cs  =  compiler_state;                                                                      # compiler_state                is from   src/lib/compiler/toplevel/interact/compiler-state.pkg
    package ds  =  deep_syntax;                                                                         # deep_syntax                   is from   src/lib/compiler/front/typer-stuff/deep-syntax/deep-syntax.pkg
    package fil =  file__premicrothread;                                                                # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
    package it  =  import_tree;                                                                         # import_tree                   is from   src/lib/compiler/execution/main/import-tree.pkg
    package lt  =  linking_mapstack;                                                                    # linking_mapstack              is from   src/lib/compiler/execution/linking-mapstack/linking-mapstack.pkg
    package pcs =  per_compile_stuff;                                                                   # per_compile_stuff             is from   src/lib/compiler/front/typer-stuff/main/per-compile-stuff.pkg
    package ph  =  picklehash;                                                                          # picklehash                    is from   src/lib/compiler/front/basics/map/picklehash.pkg
    package pp  =  standard_prettyprinter;                                                              # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
    package raw =  raw_syntax;                                                                          # raw_syntax                    is from   src/lib/compiler/front/parser/raw-syntax/raw-syntax.pkg
    package sci =  sourcecode_info;                                                                     # sourcecode_info               is from   src/lib/compiler/front/basics/source/sourcecode-info.pkg
    package seg =  code_segment;                                                                        # code_segment                  is from   src/lib/compiler/execution/code-segments/code-segment.pkg
    package syx =  symbolmapstack;                                                                      # symbolmapstack                is from   src/lib/compiler/front/typer-stuff/symbolmapstack/symbolmapstack.pkg
    package tmp =  highcode_codetemp;                                                                   # highcode_codetemp             is from   src/lib/compiler/back/top/highcode/highcode-codetemp.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/compiler/toplevel/interact/read-eval-print-loop-g.pkg
    #
    api Read_Eval_Print_Loop {
        #
        exception CONTROL_C_SIGNAL; 

        read_eval_print_from_script
          :
          String -> Void;                                                                               # 'String' is "<stdin>" else filename for script.

        read_eval_print_from_user
          :
          Void -> Void;

        read_eval_print_from_stream
          :
          ( String,
            fil::Input_Stream
          )
          ->
          Void;

        with_exception_trapping
          :
          { treat_as_user:                              Bool,
            pp:                                         Null_Or( pp::Prettyprinter )                    # Evaluation results will be prettyprinted into this.
          }                                                                                             # TRUE means to treat all exceptionns like usercode exceptions.
          ->
          { thunk:                                      Void -> Void,
            flush:                                      Void -> Void,
            fate:                                       Exception -> Void
          }
          ->
          Void;

        parse_string_to_raw_declarations                                                                # This facility created for   src/lib/x-kit/widget/edit/eval-mode.pkg
           :
          {                                                                                             # 
            sourcecode_info:                            sci::Sourcecode_Info,                           # Source code to compile, also error sink.
            pp:                                         pp::Prettyprinter                               # Where to prettyprint results.
          }                                                                                             #
          ->                                                                                            #
          List( raw::Declaration );                                                                     # 

        compile_raw_declaration_to_package_closure                                                      # This facility created for   src/lib/x-kit/widget/edit/eval-mode.pkg
          :
          {                                                                                             # 
            declaration:                                raw::Declaration,                               #
            sourcecode_info:                            sci::Sourcecode_Info,                           # Source code to compile, also error sink.
            pp:                                         pp::Prettyprinter,                              # Where to prettyprint results.
            compiler_state_stack:                       (cs::Compiler_State, List(cs::Compiler_State)), # Compiler symbol tables to use for this compile.
            options:                                    List( cs::Compile_And_Eval_String_Option )      # Future-proofing, lets us add more parameters in future without breaking backward compatibility at the client-call level.
          }                                                                                             #
          ->
          Null_Or (
              {                                                                                         # This record should have a typename somewhere...  XXX SUCKO FIXME.
                package_closure:                        seg::Package_Closure,
                import_trees:                           List( it::Import_Tree ),
                export_picklehash:                      Null_Or( ph::Picklehash ),
                linking_mapstack:                       lt::Picklehash_To_Heapchunk_Mapstack,
                code_and_data_segments:                 seg::Code_And_Data_Segments,
                new_symbolmapstack:                     syx::Symbolmapstack,                            # A symbol table delta containing (only) stuff from raw_declaration.
                deep_syntax_declaration:                ds::Declaration,                                # Typechecked form of  raw_declaration.
                exported_highcode_variables:            List( tmp::Codetemp ),
                inline_expression:                      Null_Or( acf::Function ),
                top_level_pkg_etc_defs_jar:             cs::Compiler_Mapstack_Set_Jar,
                get_current_compiler_mapstack_set:      Void -> cs::Compiler_Mapstack_Set,
                compiler_verbosity:                     pcs::Compiler_Verbosity,
                compiler_state_stack:                   (cs::Compiler_State, List(cs::Compiler_State))
              }
          );

        link_and_run_package_closure                                                                    # This facility created for   src/lib/x-kit/widget/edit/eval-mode.pkg
          :
          { sourcecode_info:                            sci::Sourcecode_Info,                           # Source code to compile, also error sink.
            pp:                                         pp::Prettyprinter                               # Where to prettyprint results.
          }
          ->
          { package_closure:                            seg::Package_Closure,
            import_trees:                               List( it::Import_Tree ),
            export_picklehash:                          Null_Or( ph::Picklehash ),
            linking_mapstack:                           lt::Picklehash_To_Heapchunk_Mapstack,
            code_and_data_segments:                     seg::Code_And_Data_Segments,
            new_symbolmapstack:                         syx::Symbolmapstack,                            # A symbol table delta containing (only) stuff from raw_declaration.
            deep_syntax_declaration:                    ds::Declaration,                                # Typechecked form of  raw_declaration.
            exported_highcode_variables:                List( tmp::Codetemp ),
            inline_expression:                          Null_Or( acf::Function ),
            top_level_pkg_etc_defs_jar:                 cs::Compiler_Mapstack_Set_Jar,
            get_current_compiler_mapstack_set:          Void -> cs::Compiler_Mapstack_Set,
            compiler_verbosity:                         pcs::Compiler_Verbosity,
            compiler_state_stack:                       (cs::Compiler_State, List(cs::Compiler_State))  # Compiler symbol tables to use for this compile.
          }                                                                                             #
          ->                                                                                            #
          (cs::Compiler_State, List(cs::Compiler_State));                                               # Updated compiler symbol tables.  Caller may keep or discard.


    };
end;

## Copyright 1996 by Bell Laboratories 
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext