PreviousUpNext

15.3.231  src/lib/compiler/front/basics/source/sourcecode-info.api

## sourcecode-info.api

# Compiled by:
#     src/lib/compiler/front/basics/basics.sublib


stipulate
    package fil =  file__premicrothread;                                # file__premicrothread          is from   src/lib/std/src/posix/file--premicrothread.pkg
    package lnd =  line_number_db;                                      # line_number_db                is from   src/lib/compiler/front/basics/source/line-number-db.pkg
    package pp  =  standard_prettyprinter;                              # standard_prettyprinter        is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
herein

    # This api is implemented in:
    #
    #     src/lib/compiler/front/basics/source/sourcecode-info.pkg
    #
    api Sourcecode_Info {
        #
        Sourcecode_Info
          =
          { line_number_db:  lnd::Sourcemap,
            file_opened:     String,
            #
            is_interactive:  Bool,                                      # 'is_interactive' is intended to track whether there is a live user entering code line-by-line.
            #                                                           # If 'is_interactive' is TRUE, in src/lib/compiler/front/parser/main/mythryl-parser-guts.pkg
            #                                                           # we will (1) Read input a line at a time instead of a char at a time.
            #                                                           #         (2) Operate with 0 rather than 30 symbols of lookahead.
            source_stream:   fil::Input_Stream, 
            saw_errors:      Ref( Bool ),
            error_consumer:  pp::Prettyprint_Output_Stream
          };

        make_sourcecode_info
          :
          { file_name:  String,
            line_num:   Int,
            source_stream:      fil::Input_Stream,
            is_interactive:     Bool,
            error_consumer:     pp::Prettyprint_Output_Stream
          }
          ->
          Sourcecode_Info;

        close_source: Sourcecode_Info -> Void;

        filepos:  Sourcecode_Info
                   -> lnd::Charpos
                   -> ( String,
                        Int,
                        Int
                      );

    };
end;

#  The [[fileOpened]] field contains the name of the file that was opened   
#  to produce a particular [[Input_Source]].                                
#  It is used only to derive related file names.                            
#  (For an example, see [[translate_raw_syntax_to_execode_g::codeopt]] and [[translate_raw_syntax_to_execode_g::parse]] in    
#  \texttt { build/translate-raw-syntax-to-execode-g.pkg }.)                                          
#                                                                           
#  [[make_source]] has some old warts build in.  It takes as argument a       
#  file and line number, and it assumes column-1.  The reason we don't      
#  simply pass a [[lnd::sourcemap]] is that we have to hide the        
#  Awful truth about the beginning position according to mythryl-lex (it's-2).   
#  That position, and therefore the creation of the source map, are         
#  encapsulated inside [[make_source]].                                       
#                                                                           
#  [[filepos]] is kept around for historical reasons, to avoid having to    
#  Change lots of code elsewhere in the compiler; it wraps a                
#  Call to [[lnd::filepos]] and massages the return type.              
#  It probably should be eliminated, but then somebody would have to fix    
#  All those call sites.                                                    
#                                                                           
#  <sourcecode-info.api>=                                                            



## 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