Re: [Squeak-ev] Übersetzungen

Marcus Denker marcus at ira.uka.de
Sam Nov 15 13:57:27 UTC 2003


Am 15.11.2003 um 14:21 schrieb Klaus Füller:

> Ich habe eine einfache Turtle-Graphik in squeak geschrieben, um sie im 
> Jahrgang 6 in Mathematik einzusetzen (es geht da um Winkel). Ich 
> müsste nun einige Meldungen des Compilers und des Laufzeitsystems 
> ändern und möchte das "quick-and-dirty" tun.
>
> Wie finde ich Meldungen, wie "Nothing more expected" oder "Message not 
> understood"?
>
Ok.
Nothing more expected. Das macht der Parser.

dort findet sich eine methode "expected:":


expected: aString
	"Notify a problem at token 'here'."

	tokenType == #doIt ifTrue: [hereMark _ hereMark + 1].
	hereType == #doIt ifTrue: [hereMark _ hereMark + 1].
	^ self notify: aString , ' expected' at: hereMark + requestorOffset


Aha. die bekommet einen String, haengt "expected" ran und ruft eine 
andere
Methode auf. Hier koennte man sich reinhaengen, am einfachsten testet
man, was in "aString" ist, uebersetzt es, also so:



expected: aString
	| transString |
	"Notify a problem at token 'here'."

	tokenType == #doIt ifTrue: [hereMark _ hereMark + 1].
	hereType == #doIt ifTrue: [hereMark _ hereMark + 1].
	
	transString := aString.
	aString = 'Nothing more' ifTrue: [ transString := 'Nichts mehr'].
	
	^ self notify: transString , ' erwartet' at: hereMark + requestorOffset


das kann man dann nach bedarf erweitern.

Bei MessageNotUnderstood ist die sache etwas ungeschickter, das das der
Name des Klasse ist. Hier koennte man folgendes machen:

1) Eine Subklasse "NachrichtNichtVerstanden" von "MessageNotUnderstood" 
erstellen.
und 2) dann aendert man Object>>#doesNotUnderstand so, dass die neue 
Klasse
aufgerufen wird:


doesNotUnderstand: aMessage
	 "Handle the fact that there was an attempt to send the given message 
to the receiver but the receiver does not understand this message 
(typically sent from the machine when a message is sent to the receiver 
and no method is defined for that selector)."
	"Testing: (3 activeProcess)"

	(Preferences autoAccessors and: [self tryToDefineVariableAccess: 
aMessage])
		ifTrue: [^ aMessage sentTo: self].

	^ NachrichtNichtVerstanden new
		message: aMessage;
		receiver: self;
		signal



--
Marcus Denker marcus at ira.uka.de