EvalScriptingErrorHandler.st
author Claus Gittinger <cg@exept.de>
Sun, 03 May 2020 23:44:59 +0200
changeset 4650 e9b212d470ff
parent 4308 18c925435b88
child 4723 524785227024
permissions -rw-r--r--
#FEATURE by cg class: ParseError added: #position

"{ Encoding: utf8 }"

"
 COPYRIGHT (c) 2014 by eXept Software AG
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libcomp' }"

"{ NameSpace: Smalltalk }"

CompilationErrorHandler subclass:#EvalScriptingErrorHandler
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'System-Compiler'
!

!EvalScriptingErrorHandler class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2014 by eXept Software AG
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    I am the ErrorHandler used when executing eval-scripts
"
! !

!EvalScriptingErrorHandler methodsFor:'error handling'!

error:aMessage position:position to:endPos from:aCompiler
    "error notification.
     This is sent by the compiler/evaluator if it detects errors."

    self showErrorOrWarning:aMessage as:'Error' position:position to:endPos from:aCompiler.
    ^ #Error
!

showErrorOrWarning:aMessage as:errorOrWarning position:position to:endPos from:aCompiler
    "error notification.
     This is sent by the compiler/evaluator if it detects errors."

    |lineNr pos|

    lineNr := myStream isNil ifTrue:[1] ifFalse:[myStream lineNumber ? '?'].
    pos := position ? '?'.

    Stderr nextPutLine:('[%1 %2/%3] %4' bindWith:errorOrWarning with:lineNr with:pos with:aMessage).
    currentSource notNil ifTrue:[
        Error handle:[:ex |
        ] do:[
            Stderr 
                nextPutLine:currentSource;
                spaces:position?0;
                nextPutLine:'^'.
        ].
    ].
    ^ #Error

    "Modified: / 24-09-2018 / 14:18:02 / Claus Gittinger"
!

warning:aMessage position:position to:endPos from:aCompiler
    "warning notification.
     This is sent by the compiler/evaluator if it detects something strange."

    self showErrorOrWarning:aMessage as:'Warning' position:position to:endPos from:aCompiler.
    ^ false
! !

!EvalScriptingErrorHandler methodsFor:'queries'!

autoDefineVariables
    "when evaluating with --eval, auto define any variables as workspace vars"

    ^ #workspace. "/ true
! !

!EvalScriptingErrorHandler class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
! !