home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-09-27 | 32.7 KB | 1,202 lines |
- # $Header: P:/source/ppee/macros/errorfix.pev 1.85 26 Sep 1990 17:08:52 skipr $
-
- ##############################################################################
- #
- # Sage Software - POLYTRON Division
- # 1700 NW 167th Place
- # Beaverton, OR 97006
- #
- # Copyright 1990, Sage Software, Inc.
- #
- # Permission is hereby granted for licensed users of Sage Professional
- # Editor and PolyAwk to copy and modify this source code for their own
- # personal use. These derivative works may be distributed only to other
- # licensed Sage Professional Editor and PolyAwk users. All other usage
- # is prohibited without express written permission from Sage Software.
- #
- ##############################################################################
-
- #### $Workfile: errorfix.pel $: Compiling and Error locating utilities
-
-
- ## Overview of compile/errorfix language support
- ##
- ## The two most essential global functions defined here are
- ## "compile_buffer()" and "goto_next_error()". Compile_buffer uses the
- ## name of the current buffer to determine what language is being used,
- ## and then issues a command line to the shell invoking the appropriate
- ## compiler. Upon completion of the shell process, the captured error
- ## output is passed on to the goto_next_error() function.
- ## goto_next_error() knows the syntax of the error messages produced by
- ## each compiler, and uses that information to find the name of the
- ## source file where the error occurred, and the location within that
- ## file. The goto_next_error() function may also be invoked again
- ## independently from the keyboard, where it will scan forward in the
- ## error listing for the next error encountered.
- ##
- ## To add support for a new compiler, the arrays "compiler_cmd_array"
- ## and "compiler_err_array" must be augmented and, depending on the
- ## error message syntax of the new compiler, a new compiler-specific
- ## error message parsing function may have to be added. The function
- ## add_compiler() can be used to update the compiler arrays. It may be
- ## called from within the user's local_setup() function, or from within
- ## the sageedit.cfg file. For more information on adding a new error
- ## message function, see the comments in function errorInfo() near the
- ## end of this file.
- ##
- ## ---------------------------------------------------------------------
-
- ## Clipper & FORCE compiler support enhancements provided by
- ## Pedro P. Polakoff III of 3P Software, Inc.
-
-
- ## The following arrays contain compiler specific information:
- global compiler_err_array
- global compiler_cmd_array
-
- local searchFlag = 0x0034 # ignore case | regex | forward
-
- global errorSrcName
- local errorLine
- local errorColumn
- local errorText
- local errorCompleteText
- local errorsFound
-
- local errorBuffer
- local originalBuffer
- local switchedBuffer
- local errorInfoPrefix
-
- ## init_compilers()
- #
- # define lists of known compilers, file extensions and compiler command lines
- #
- global function init_compilers(){
- local ext
- local aeName
-
- ## Two arrays are initialized here:
- ##
- ##
- ## The first array, compiler_cmd_array, defines the command line to
- ## use for each filename extension type. Each command line is a
- ## string which will be executed by the shell after macro
- ## substititions have been performed. Valid command line macros are
- ## as follows:
- ##
- ## $< - expands to complete name of source file
- ## $r - expands to root (basename) of source file, less extension
- ## $e - expands to extension of source file, excluding "."
- ## $p - expands to drive and path of source file (ends in "\")
- ##
- ## for example, given the file "c:\hork\file.ext" :
- ## $< == "c:\hork\file.ext"
- ## $r == "file"
- ## $e == "ext"
- ## $p == "c:\hork\"
- ##
- ##
- ## The second array, compiler_err_array, defines the filename
- ## extensions used by each language. The array subscripts are the
- ## valid extensions associated with a given language. The value of
- ## the array element is the compiler type string, which is used to
- ## determine which error message parsing function to use. This
- ## string is will become the base filename of the error message
- ## file. The compiler type string may be up to 8 characters in
- ## length, and must be a valid base filename.
- ##
- ## -----------------------------------------------------------------
-
- if ( compiler_cmd_array ){
- return # already initialized
- }
-
- ## Sage/POLYTRON Pel compiler
- ext = ".pel"
- compiler_err_array[ ext ] = "pel" # use "pelErrorInfo" function
- # find the full name of the current sageedit.ae file
- if ( (aeName = locate_sageedit_file( SAGEEDIT_FILE_AE ))) {
- aeName = " -o " aeName
- }
- compiler_cmd_array[ ext ] = "pel" aeName " -aisv $<" # shell cmd
-
- ## Sage/POLYTRON Awk Toolkit compiler
- ext = ".awk"
- compiler_err_array[ ext ] = "none" # no error info function is available
- compiler_cmd_array[ ext ] = "awkc $<"
-
- ## Sage PolyMake
- ext = ".mak"
- compiler_err_array[ ext ] = "polymake" # use "genericErrorInfo()"
- compiler_cmd_array[ ext ] = "make -f $<"
-
- ## Microsoft C
- ext = ".c"
- compiler_err_array[ ext ] = \
- compiler_err_array[ ".h" ]= "c" # use "genericErrorInfo()"
- # following command outputs to NUL to check syntax only
- compiler_cmd_array[ ext ] = "cl -c -Fonul $<"
-
- ## Zortech C
- #ext = ".c"
- #compiler_err_array[ ext ] = \
- #compiler_err_array[ ".h" ]= "zortech" # use "zortechErrorInfo()"
- #compiler_cmd_array[ ext ] = "ztc -c -r $<"
-
- ## Zortech C++
- ext = ".cpp"
- compiler_err_array[ ext ] = "zortech" # use "zortechErrorInfo()"
- compiler_cmd_array[ ext ] = "ztc -c -cpp -r $<"
-
- ## Turbo C
- ext = ".c"
- #compiler_err_array[ ext ] = \
- #compiler_err_array[ ".h" ]= "turboc" # use "turbocErrorInfo()"
- #compiler_cmd_array[ ext ] = "tcc -c -w $<"
-
- ## Turbo C++
- ext = ".cpp"
- #compiler_err_array[ ext ] = "turboc" # use "turbocErrorInfo()"
- #compiler_cmd_array[ ext ] = "cpp $<"
-
- ## Microsoft Masm
- ext = ".asm"
- compiler_err_array[ ext ] = "asm" # use "genericErrorInfo()"
- compiler_cmd_array[ ext ] = "masm $<,nul,asm.err;"
-
- ## Turbo Pascal
- ext = ".pas"
- compiler_err_array[ ext ] = "pas" # use "genericErrorInfo()"
- compiler_cmd_array[ ext ] = "tpc $<"
-
- ## Advantage ADA
- ext = ".ada"
- compiler_err_array[ ext ] = "ada" # use "adaErrorInfo()"
- compiler_cmd_array[ ext ] = "ada $<"
-
- ## Microsoft Quick BASIC
- ext = ".bas"
- compiler_err_array[ ext ] = "bas" # use "genericErrorInfo()"
- compiler_cmd_array[ ext ] = "qb $<"
-
- ## Lahey FORTRAN 77
- ext = ".for"
- compiler_err_array[ ext ]= "lahey" # use "laheyErrorInfo()"
- compiler_cmd_array[ ext ]= "f77l $<"
- ext = ".f"
- compiler_err_array[ ext ]= "lahey"
- compiler_cmd_array[ ext ]= "f77l $<"
-
- ## COBOL
- ext = ".cbl"
- compiler_err_array[ ext ] = "none" # no error info function is available
- compiler_cmd_array[ ext ] = "cobol $<"
-
- ## dBASE dialect compilers
- #
- if ( D_DIALECT != "clipper87" \
- && D_DIALECT != "clipper50" \
- && D_DIALECT != "force" ) {
- D_DIALECT = "clipper50" # default if none defined
- }
- ext = ".prg"
- if ( D_DIALECT == "clipper87" ) { # Clipper Summer 87
- # use "clipper87ErrorInfo()"
- compiler_err_array[ ext ] = \
- compiler_err_array[ ".pre" ] = "clipper87"
- # compile with Clipper Summer 87 compiler or preprocessor
- # depending on the filename extension
- compiler_cmd_array[ ext ] = "clipper $< -m -s"
- compiler_cmd_array[ ".pre" ] = "pre $<"
-
- } else if ( D_DIALECT == "clipper50" ) { # Clipper 5.0
- # use "clipper5ErrorInfo()" and version 5.0 compiler
- compiler_err_array[ ext ] = \
- compiler_err_array[ ".ch" ] = \
- compiler_err_array[ ".ppo" ] = "clipper5"
- compiler_cmd_array[ ext ] = "clipper $< /s /w /m"
-
- } else if ( D_DIALECT == "force" ) { # FORCE compiler
- compiler_err_array[ ext ] = \
- compiler_err_array[ ".hdr" ] = "force"
- compiler_cmd_array[ ext ] = "force $<"
- }
- }
-
-
- ## reset_compilers()
- #
- # forces a rebuild of the compiler_cmd_array & compiler_err_array
- # required to change compilers from buffer to buffer or within
- # an editing session.
- #
- global function reset_compilers(){
- # init electric file extension list
- if ( !extensions_initialized ) {
- initialize_extensions()
- }
-
- # prompt for dBase dialect
- if ( buffer_filename ~ file_extensions[ "dbase" ] \
- || buffer_filename ~ file_extensions[ "clipper87" ] \
- || buffer_filename ~ file_extensions[ "clipper50" ] \
- || buffer_filename ~ file_extensions[ "force" ] ) {
- dBaseDialect()
- }
-
- # re-init compilers
- delete compiler_err_array
- delete compiler_cmd_array
- init_compilers()
- }
-
-
- ## edit_compiler()
- #
- # edits a compiler command string
- #
- global function edit_compiler( ext ) {
- local cmd
-
- init_compilers()
-
- if ( ext ) {
- ext = tolower( ext )
- if ( substr( ext, 1, 1 ) != "." ){
- ext = "." ext # prefix with "." if necessary
- }
- if ( length(ext) <= 1 || length(ext) > 4 ) {
- return ""
- }
- } else {
- # default is filename extension of current buffer
- ext = path_ext( buffer_filename )
- }
-
- # prompt for compiler command string
- if ( ext in compiler_cmd_array ){
- cmd = compiler_cmd_array[ ext ]
- }
- cmd = factory_prompt( \
- "Enter compiler command (\"$<\" == current buffer_filename)",
- "COMPILE",
- "cmd: ",
- cmd )
-
- # update the compiler command array
- if ( cmd ) {
- compiler_cmd_array[ ext ] = cmd
- }
- return cmd
- }
-
-
- ## add_compiler() #PUBLIC
- #
- # adds information about a compiler to that defined in init_compilers()
- #
- global function add_compiler( ext_list, cmd_line, error_ruleset ){
- local tmp_array
- local ext
- local status = 0
- local i
-
- # check required arguments
- if ( !ext_list || !cmd_line ){
- warning( "missing argument in call to add_compiler" )
- }
-
- init_compilers()
-
- # process list of source filename extensions
- gsub( /[ \t,]+/, " ", ext_list ) # change delimiters to spaces
- split( ext_list, tmp_array, " " )
- for ( i in tmp_array ){
- ext = tolower( tmp_array[ i ] )
- if ( substr( ext, 1, 1 ) != "." ){
- ext = "." ext # prefix with "." if necessary
- }
- if ( length(ext) > 1 && length(ext) <= 4 ) {
- if ( !status ) {
- # add command line for first extension listed
- status = 1
- compiler_cmd_array[ ext ] = cmd_line
- }
-
- # add source filename extension
- if ( error_ruleset ) {
- compiler_err_array[ ext ] =
- tolower( error_ruleset )
- }
- }
- }
- }
-
-
- ## compile_buffer() #PUBLIC
- #
- # compile the current buffer
- #
- global function compile_buffer() {
- local cmd
- local ext
- local outfile
- local status = -1
-
- # make sure the compile buffer system is initialized
- init_compilers()
-
- ## use the filename extension to decide which compiler to use
-
- ext = path_ext( buffer_filename )
- if ( !ext ){
- # treat the name "makefile" with no extension as if it has
- # a ".mak" extension
- if ( path_fname( buffer_filename ) == "makefile" ) {
- ext = ".mak"
- } else {
- ext = "NULL_ext"
- }
- }
-
- if ( ext in compiler_cmd_array ){
-
- # expand compiler command line macros
- cmd = compiler_cmd_array[ ext ]
- gsub( /\$\</, buffer_filename, cmd )
- gsub( /\$r/, path_fname(buffer_filename), cmd )
- gsub( /\$e/, substr( path_ext(buffer_filename), 2 ), cmd )
- gsub( /\$p/, path_path(buffer_filename), cmd )
-
- # define the error output file
- if ( ext in compiler_err_array ) {
- outfile = compiler_err_array[ ext ]
- }
- if ( outfile == "" || outfile == "none" ) {
- outfile = substr( ext, 2 )
- }
- outfile = outfile ".err"
-
- } else {
- warning( "Don't know how to compile %s files.", ext )
- return status
- }
-
- cmd = factory_prompt( \
- "preparing to issue system command : <Enter> to proceed, <Esc> to cancel",
- "COMPILE",
- "cmd: ",
- cmd )
-
- if ( cmd ) {
- # write current buffer to disk if modified
- write_buffer_key()
-
- # make sure there is no old error buffer to confuse us
- if ( errorBuffer ) {
- closeErrorFile()
- }
-
- # invoke the compiler
- status = system_window_command( cmd, outfile )
- if ( outfile ){
- # parse first error message
- goto_next_error( outfile )
- unlink( outfile )
- }
- if ( status < 0 ) {
- message( "Command returned error code %d.", status )
- }
- }
- return status
- }
-
- # ---------------------------------------------------------------------------
-
- ## display_errors() #PUBLIC
- #
- # put up a window containing the error message file
- #
- global function display_errors( errorFileName, suppressNextError ) {
- local scanCode, keyCode
- local prevLine = -1
- local priorWindow = current_window
- local w
-
- # create a system buffer containing the error file
- if ( !openErrorFile( errorFileName ) ) {
- return
- }
-
- # create a view for the error list display
- w = create_factory_window( 5, 2, 70, 20, \
- WINDOW_MENU + WINDOW_SB_RIGHT )
- if ( !w ) {
- return
- }
-
- current_window = w
- current_buffer = errorBuffer
- attach_window_buffer( current_window, errorBuffer )
-
- # check the size of the error buffer for at least one complete line
- if (buffer_size < 3) {
- delete_window()
- if ( priorWindow ) {
- current_window = priorWindow
- }
- notify( "No errors." )
- return
- }
-
- # record line number of current error message in case of Esc key
- save_position()
-
- # start with the error message centered in the display
- center_cursor()
-
- # display instructions in the dialog window
- if ( 0+suppressNextError ){
- message( "Move cursor, <Enter> or <Esc> to exit" )
- } else {
- message( "Move cursor, <Enter> to select, <Esc> to exit" )
- }
-
- # error list command loop
- while ( 1 ) {
- # get the buffer list command
- if ( prevLine != current_line ) {
- raise_anchor()
- drop_anchor( LINE_SELECTION )
- prevLine = current_line
- }
- display_update()
- keyCode = getkey()
- scanCode = shiftr( keyCode, 8 )
-
- # process cursor motion keys
- if ( !keypad_motion( scanCode )) {
- if (keyCode == KEYCODE_ENTER) {
- break
- }
- if (keyCode == KEYCODE_ESC ) {
- suppressNextError = 1
- break
- }
- }
- }
-
- raise_anchor()
-
- if ( suppressNextError ){
- # leave the position in the error file unchanged
- restore_position( 1 )
- } else {
- # move to the start of the current error message
- goto_bol()
- restore_position( 0 )
- }
-
- # remove the window
- delete_window()
- if ( priorWindow ) {
- current_window = priorWindow
- }
-
- # clear the message line
- message( "" )
-
- if ( !suppressNextError ){
- # look up the source of the current error message
- goto_next_error( "", 1 )
- }
- }
-
-
- ## goto_next_error() #PUBLIC
- #
- # display an individual error message
- #
-
- global function goto_next_error( errorFileName, suppressDisplayErrors ) {
- local priorBuffer = current_buffer
- local dialogWindowToggled
- local errorLevel
-
- # create a system buffer containing the error file
- if ( !openErrorFile( errorFileName ) ) {
- return 0
- }
-
- # locate the next appropriate error message in the Error list buffer
-
- current_buffer = errorBuffer
- errorLevel = errorInfo()
-
- # move the cursor to the context of the error message
-
- if ( errorLevel > 0 ) {
- errorsFound = TRUE
-
- if ( filemode(errorSrcName) != -1 ) {
- switchedBuffer = current_buffer = \
- create_buffer( \
- buildpath(errorSrcName), \
- errorSrcName, \
- 0 )
- goto_old_line( errorLine )
- current_column = errorColumn
- if ( !errorColumn ) {
- search( "[^ \t]|$", searchFlag )
- }
- center_cursor()
- } else {
- current_buffer = originalBuffer
- errorText = errorCompleteText
- }
-
- # Display the current error or warning text in the
- # dialog window.
-
- if ( !dialog_window ) {
- dialogWindowToggled = 1
- toggle_dialog( 1 )
- }
-
- if ( errorLevel == 2 ) {
- warning( "%s", errorText )
- } else {
- notify( "%s", errorText )
- }
-
- # take down the dialog window if we had to create one
- if ( dialogWindowToggled ) {
- display_update()
- while( !keyboard_input_pending ) {
- # wait...
- }
- toggle_dialog( 0 )
- }
-
- } else {
- current_buffer = priorBuffer
- if ( errorLevel == 0 ) {
- # end of error file
- notify( errorsFound \
- ? "No more errors" \
- : "No errors." )
- if ( emulation_mode == "brief" ) {
- current_buffer = errorBuffer
- goto_buffer_top()
- current_buffer = priorBuffer
- }
- } else if ( !(0+suppressDisplayErrors) ) {
- # extension type is unknown
- display_errors( "", 1 )
- }
- # closeErrorFile()
- }
-
- return errorLevel
- }
-
-
- ## openErrorFile()
- #
- # Create a system buffer containing the error list file. Do nothing if
- # one already exists. Also define a variable, errorInfoPrefix, to define
- # which xxxErrorInfo function to use.
- #
-
- local function openErrorFile( errorFileName ){
- local ext
- local sourcefile_ext
- local prevEol
-
- # make sure the compile buffer system is initialized
- init_compilers()
-
- # The errorFileName argument is optional - if the filename for
- # the error file was specifed, use it.
- #
- if ( errorFileName ) {
- if ( errorBuffer ) {
- closeErrorFile()
- }
- if ( filemode(errorFileName) == -1 ) {
- warning( "Cannot open %s", errorFileName )
- return 0
- }
- sourcefile_ext = "." path_fname( errorFileName )
- } else {
-
- # is the corresponding error file buffer already present?
- if ( errorBuffer ) {
- if ( (current_buffer == originalBuffer) || \
- (current_buffer == switchedBuffer) ) {
- # already present, just return
- return 1
- }
- closeErrorFile()
- }
-
- # use the current file basename to find the error file
- ext = path_ext( buffer_filename )
- if ( ext == ".err" ) {
- # if the current buffer is an error file, use it.
- errorFileName = buffer_filename
- sourcefile_ext = "." path_fname( buffer_filename )
- } else {
- # otherwise use current basename with .err extension
- errorFileName = path_fname(buffer_filename) ".err"
- if ( ext == "" && errorFileName == "makefile.err" ) {
- # use ".mak" rules for "makefile"
- sourcefile_ext = ".mak"
- } else {
- sourcefile_ext = ext
- }
- }
-
- # if that doesn't work, try again using the filename extension
- if ( filemode(errorFileName) == -1 ) {
-
- if ( length( ext ) > 1 ) {
- sourcefile_ext = ext
- errorFileName = substr( ext, 2 ) ".err"
-
- if ( filemode(errorFileName) == -1 &&
- ext in compiler_err_array ) {
- errorFileName = \
- compiler_err_array[ ext ] \
- ".err"
- }
- }
-
- if ( filemode(errorFileName) == -1 ) {
- warning( "Cannot open %s", errorFileName )
- return 0
- }
- }
- }
-
- # find error file type given source filename extension
- if ( sourcefile_ext in compiler_err_array ) {
- errorInfoPrefix = compiler_err_array[ sourcefile_ext ]
- } else {
- errorInfoPrefix = substr( sourcefile_ext, 2 )
- }
-
- # create a new system buffer for the error file
-
- originalBuffer = current_buffer
- switchedBuffer = 0
- prevEol = default_buffer_eol_string
- default_buffer_eol_string = "\r\n"
-
- errorBuffer = create_buffer( \
- "Error File", \
- errorFileName, \
- BUFFER_SYSTEM + BUFFER_NO_UNDO )
-
- default_buffer_eol_string = prevEol
-
- errorsFound = FALSE
-
- return 1
- }
-
-
- ## closeErrorFile()
- #
- # Remove the system buffer associated with the error list file.
- #
-
- local function closeErrorFile(){
- delete_buffer( errorBuffer )
- errorBuffer = 0
- }
-
-
- ## errorInfo()
- #
- # Calls the appropriate compiler specific xxxErrorInfo function to find
- # error and warning messages in the error file and extract salient
- # information. Additional functions may be added here, if desired, to
- # support different compilers. Each new function should have a name which
- # consists of the compiler type, as defined in the init_compilers() function,
- # followed by "ErrorInfo". Each new ErrorInfo function should set
- # the following variables:
- #
- #
- # errorSrcName - the name of the source filename appearing in the
- # error message
- #
- # errorLine - the line number in the current source file where the
- # error occurred.
- #
- # errorColumn - the column where the error occurred (or 0 if unknown)
- #
- # errorText - the text of the message to be displayed in the
- # dialog window.
- #
- #
- # In addition, the variable errorCompleteText will be displayed if the file
- # named in errorSrcName cannot be located.
- #
- #
- # The function return value should be as follows:
- # 0 - if no more error or warning messages could be found,
- # 1 - if the message is for a non-fatal error or warning,
- # 2 - if the message is for a severe error.
- #
-
- local function errorInfo(){
- local functionId
-
- # initialize
- errorSrcName = ""
- errorLine = 0
- errorColumn = 0
- errorText = ""
-
- # Determine which xxxErrorInfo function to use. Known compiler
- # types and source file extensions are listed in the function
- # "init_compilers()".
-
- if ( errorInfoPrefix == "none" ) {
- # no errorInfo function exists for this compiler
- return -1
- }
-
- # Append the name "ErrorInfo" to the compiler type and
- # use it if a function by that name exists.
- functionId = function_id( errorInfoPrefix "ErrorInfo" )
- if ( functionId ) {
- return execute_function( functionId )
- } else {
- # otherwise use the default errorfix routine
- return genericErrorInfo()
- }
- }
-
- # ------------------- Generic ErrorInfo function ----------------------------
-
- global function genericErrorInfo(){
-
- #====================================================================
- # This function is invoked whenever no explicit xxxErrorInfo()
- # function has been defined for the current compiler. It supports
- # the error message syntax for several compilers, for example:
- #
- # Microsoft C and MASM:
- # <sourcefile>(<line number>): "error"|"warning" <errno>: <message>
- #
- # Lattice C:
- # <sourcefile> <line number> "Error"|"Warning" <errno>: <message>
- #
- # Borland Turbo Pascal:
- # <sourcefile>(<line number>): "Error"|"Warning" <errno>: <message>
- #
- # FORCE:
- # <sourcefile>(<line number>) : "Error"(<errno>) : <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "[ \t(]+\\c[0-9].*(<error|<warning)[ \t(].*:"
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag ) ) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
- restore_position(1)
-
- # get the source filename
- match( errorCompleteText, /[^( \t]+/ )
- errorSrcName = substr( errorCompleteText, RSTART, RLENGTH )
-
- # get the line and column position of the error
- errorLine = atoi( read_buffer(10) )
-
- # determine the severity of the error
- search( "<error>|<warning>", searchFlag )
- errorLevel = (tolower(read_buffer(5)) == "error") ? 2 : 1
-
- # get the text of the message
- search( ":\\c", searchFlag )
- search( "<", searchFlag )
- errorText = ltrim(read_buffer())
-
- return errorLevel
- }
-
- # ------------------- ErrorInfo function for PEL ----------------------------
-
- global function pelErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Sage - POLYTRON Pel compiler:
- #
- # <sourcefile>(<line number>):"[fatal] error"|"warning":
- # <space>|<newline> <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = ":.*(error|warning).*:\\c"
- local delimit
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag ) ) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- delimit = current_column
- save_position()
- goto_bol()
- errorCompleteText = read_buffer( delimit )
- restore_position(1)
-
- # get the source filename
- match( errorCompleteText, /[^( ]+/ )
- errorSrcName = substr( errorCompleteText, RSTART, RLENGTH )
-
- # get the line and column position of the error
- if ( substr( errorCompleteText, RSTART+RLENGTH, 1 ) == "(" ) {
- errorLine = atoi( substr( errorCompleteText, RSTART+RLENGTH+1 ))
- }
-
- # determine the severity of the error
- errorLevel = (errorCompleteText ~ /warning:/) ? 1 : 2
-
- # get the text of the message
- search( "<", searchFlag )
- errorText = read_buffer()
- errorCompleteText = errorCompleteText errorText
-
- return errorLevel
- }
-
- # ------------------- ErrorInfo function for Turbo C ------------------------
-
- global function turbocErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Borland Turbo C (Version 2.0):
- #
- # "Error"|"Warning" <sourcefile> <line number>: <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "^(Error|Warning).* \\c[0-9]+:"
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag ) ) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
-
- # get the source filename
- match( errorCompleteText, / [^ ]+ / )
- errorSrcName = substr( errorCompleteText, RSTART+1, RLENGTH-2 )
-
- # determine the severity of the error
- errorLevel = (errorCompleteText ~ /^Error/) ? 2 : 1
-
- # get the line and column position of the error
- restore_position(1)
- errorLine = atoi( read_buffer(10) )
- errorColumn = 0
-
- # get the text of the message
- search( ":\\c", searchFlag )
- errorText = ltrim(read_buffer())
-
- return errorLevel
- }
-
- # ------------------- ErrorInfo function for Zortech C and C++ --------------
-
- global function zortechErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Zortech C and C++
- #
- # Zortech C and C++:
- # "<sourcefile>" line <line number>: "warning"|"syntax error"|
- # "preprocessor error"|"fatal error"|"lexical error": <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "(^\".*\",? line \\c[0-9]*[ :]*(warning|(syntax|preprocessor|fatal|lexical) error):?)" \
- "|\\c(Global Optimizer|Intermediate file|Fatal|Syntax|Preprocessor|lexical) error:+"
- local fnameline
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag )) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
-
- # get the source filename
- errorSrcName = substr( errorCompleteText, 2,
- cindex( substr( errorCompleteText, 2 ), "\"" ) - 1)
-
- # determine the severity of the error
- errorLevel = (errorCompleteText ~ /warning:/) ? 1 : 2
-
- # get the line and column position of the error
- restore_position(1)
- errorLine = atoi( read_buffer(10) )
- errorColumn = 0
-
- # get the text of the message
- search( "(warning|error):\\c", searchFlag )
- errorText = ltrim(read_buffer())
-
- return errorLevel
- }
-
- # ------------------- ErrorInfo function for Lahey FORTRAN ------------------
-
- global function laheyErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Lahey FORTRAN 77
- #
- # Lahey FORTRAN 77:
- # "Compiling line : <line num>" This is only shown one time
- # "File <source file name>, line <line num>: <copy of program line>
- # <'^' pointer to Column position of Error>
- # "(FATAL|WARNING) - <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "^(FATAL|WARNING)[ \t]* -\\c"
- local fnameline
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag )) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
- # the error message could span a couple of lines
- while (errorCompleteText !~ /\.$/){
- if (!down())
- break;
- goto_bol();
- errorCompleteText = errorCompleteText read_buffer();
- }
-
-
- # get the source filename
- if (match( errorCompleteText, "File .*, line[ \t]+[0-9]+\\.")) {
- # The line number and file name are on the same line.
- fnameline = substr( errorCompleteText, RSTART+5 );
-
- errorSrcName = trim(ltrim(substr( fnameline, 1,
- cindex( fnameline, "," ) - 1 )))
-
- match( fnameline, "line[ \t]+[0-9]" )
- fnameline = ltrim(substr( fnameline, RSTART + 4 ));
-
- # get the line and column position of the error
- errorLine = atoi( fnameline )
- errorColumn = 0
-
- } else {
- # The line number and file name are on a different line.
- if (!search( "^File[ \t]+.* line +\\c[0-9]*", \
- SEARCH_BACKWARD+SEARCH_REGEX+SEARCH_IGNORE_CASE )){
- restore_position(1)
- return 0;
- }
- save_position();
- current_column = 6;
- fnameline = read_buffer()
- match( fnameline, "," )
- errorSrcName = substr( fnameline, 1, RSTART - 1 )
-
- # get the line and column position of the error
- restore_position(1)
- errorLine = atoi( read_buffer(10) )
- errorColumn = 0
- }
-
- # determine the severity of the error
- errorLevel = (errorCompleteText ~ /^WARNING/) ? 1 : 2
-
- # get the text of the message
- restore_position(1)
- errorText = ltrim(read_buffer())
-
- return errorLevel
- }
-
- # ------------------- ErrorInfo function for Advantage ADA ------------------
-
- global function adaErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Advantage ADA
- #
- # "<filename>", <line num>: <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "^\".*\", \\c[0-9]*:"
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag ) ) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
-
- # get the source filename
- errorSrcName = substr( errorCompleteText, 2,
- cindex( substr( errorCompleteText, 2 ), "\"" ) - 1)
-
- # determine the severity of the error
- errorLevel = (errorCompleteText ~ /error/) ? 2 : 1
-
- # get the line and column position of the error
- restore_position(1)
- errorLine = atoi( read_buffer(10) )
- errorColumn = 0
-
- # get the text of the message
- search( ":\\c", searchFlag )
- errorText = ltrim(read_buffer())
-
- return errorLevel
- }
-
- # ------------------- ErrorInfo functions for Clipper -----------------------
-
- global function clipper87ErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Nantucket Clipper Summer87
- #
- # "Compiling <file>" (This is only shown one time)
- # "line <line>: <message>"
- # <copy of program line>
- # <'^' pointer to Column position of Error>
- #
- #
- # Clipper Support added by P. Polakoff III, 3P Software, Inc.
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "^line \\c[0-9]+:"
- local fnameline
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag ) ) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
-
- # get the source filename
- do {
- goto_pos( current_line-1, 0 )
- fnameline = read_buffer()
- } while( substr(fnameline,1,9) != "Compiling" )
- errorSrcName = ltrim( trim( substr( fnameline, 10 )))
-
- # Clipper errors are always fatal
- errorLevel = 2
-
- # get the line and column position of the error
- restore_position(1)
- errorLine = atoi( read_buffer(10) )
- goto_pos( current_line+2, 1 )
- errorColumn = match( read_buffer(), "\\^" )
-
- # get the text of the message
- errorText = trim( substr( \
- errorCompleteText, \
- match( errorCompleteText, ":" ) + 1 ))
-
- return errorLevel
- }
-
- global function clipper5ErrorInfo(){
-
- #====================================================================
- #
- # error message syntax for Nantucket Clipper 5.0 (B93)
- #
- # <sourcefile>(<line number>) "Error"|"Warning" <errno> <message>
- #
- #====================================================================
-
- local errorLevel
- local searchFor = "\\(\\c[0-9]+\\) +(Error|Warning)"
-
- # scan the error file for the next appropriate message
- if ( !search( searchFor, searchFlag ) ) {
- return 0 # no more applicable messages
- }
-
- # save the complete text of the error message
- save_position()
- goto_bol()
- errorCompleteText = read_buffer()
- restore_position(1)
-
- # get the source filename
- match( errorCompleteText, /[^( \t]+/ )
- errorSrcName = substr( errorCompleteText, RSTART, RLENGTH )
-
- # get the line and column position of the error
- errorLine = atoi( read_buffer(10) )
-
- # determine the severity of the error
- search( "<error>|<warning>", searchFlag )
- errorLevel = (tolower(read_buffer(5)) == "error") ? 2 : 1
-
- # get the text of the message
- errorText = read_buffer()
-
- return errorLevel
- }
-