PreviousUpNext

15.3.291  src/lib/compiler/toplevel/interact/read-eval-print-loops.api

## read-eval-print-loops.api 

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



###                 "A language that doesn't have everything
###                  is actually easier to program in than
###                  some that do."
###
###                                    -- Dennis M Ritchie



stipulate
    package acf =  anormcode_form;                                              # anormcode_form                is from   src/lib/compiler/back/top/anormcode/anormcode-form.pkg
    package cms =  compiler_mapstack_set;                                       # compiler_mapstack_set         is from   src/lib/compiler/toplevel/compiler-state/compiler-mapstack-set.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

    api Read_Eval_Print_Loops {
        #
        exception CONTROL_C_SIGNAL;
        #
        read_eval_print_from_script:  String -> Void;
        read_eval_print_from_file:    String -> Void;
        read_eval_print_from_stream:  fil::Input_Stream -> Void;
        read_eval_print_from_user:    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(
              { 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.


        evaluate_stream
          :
          ( fil::Input_Stream,
            cms::Compiler_Mapstack_Set
          )
          ->
          cms::Compiler_Mapstack_Set;

        with_exception_trapping
          :
          { treat_as_user:      Bool,                                           # TRUE means to treat all exceptions like usercode exceptions.
            pp:                 Null_Or( pp::Prettyprinter )
          }
          ->
          { thunk:              Void -> Void,
            flush:              Void -> Void,
            fate:               Exception  -> Void
          }
          ->
          Void;

        redump_heap_fate
            :
            Ref( fate::Fate( String ) );

    };
end;

## COPYRIGHT (c) 1996 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