Question: #evaluate:in:to:notifying:ifFail:
Tim Olson
tim at jumpnet.com
Sat Mar 28 01:07:50 UTC 1998
>Although the comments in Compiler don't say anything about this,
>in fact the bomb receives many other messages which it does not
>understand as if it were a ParagraphEditor (even if the expression
>is perfectly ok) =:^$. Any simple solution?
If the requestor (the object passed in "notifying:") is not nil or is not
a kind of SyntaxError, then the compiler assumes it is running
interactively and the requestor to notify is a kind of ParagraphEditor,
hence the extra messages.
The easiest thing to do is probably to subclass SyntaxError, adding a new
instance variable 'requestor' to reflect the notification to.
To use it:
| stream |
stream _ ReadWriteStream on: string from: 1 to: string size.
Compiler new
evaluate: stream
in: nil
to: nil
notifying: (SyntaxErrorCollector for: bombInTheCorner)
ifFail: [].
----
'From Squeak 1.31 of Feb 4, 1998 on 27 March 1998 at 7:03:15 pm'!
SyntaxError subclass: #SyntaxErrorCollector
instanceVariableNames: 'requestor '
classVariableNames: ''
poolDictionaries: ''
category: 'Interface-Syntax Errors'!
!SyntaxErrorCollector commentStamp: 'tao 3/27/98 19:03' prior: 0!
I am a kind of SyntaxError that can collect (intercept) compiler syntax
errors and reflect the notification to my receiver. I exist because the
compiler only understands requestors that are either:
nil
SyntaxError
ParagraphEditor
!
!SyntaxErrorCollector methodsFor: 'as yet unclassified' stamp: 'tao
3/27/98 18:59'!
notify: error at: location in: source
^ requestor isNil
ifTrue: [super notify: error at: location in: source]
ifFalse: [requestor notify: error at: location in: source]! !
!SyntaxErrorCollector methodsFor: 'as yet unclassified' stamp: 'tao
3/27/98 18:55'!
requestor
^ requestor! !
!SyntaxErrorCollector methodsFor: 'as yet unclassified' stamp: 'tao
3/27/98 18:56'!
requestor: aRequestor
requestor _ aRequestor! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
SyntaxErrorCollector class
instanceVariableNames: ''!
!SyntaxErrorCollector class methodsFor: 'as yet unclassified' stamp: 'tao
3/27/98 18:55'!
for: aRequestor
^ super new requestor: aRequestor! !
-- tim
More information about the Squeak-dev
mailing list
|