Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.408.mcz ==================== Summary ==================== Name: Kernel-nice.408 Author: nice Time: 25 February 2010, 2:48:03.13 am UUID: fbd33dfc-72c8-f84f-ae5d-bc0cdec1ca9f Ancestors: Kernel-ar.407 Let NumberParser failBlock take 2 optional arguments (errorString and source position) thanks to new cull: protocol. This will help Parser inserting error message inline. =============== Diff against Kernel-ar.407 =============== Item was changed: ----- Method: NumberParser>>expected: (in category 'error') ----- + expected: aString + | errorString | + errorString := aString , ' expected'. - expected: errorString requestor isNil ifFalse: [requestor + notify: errorString + at: sourceStream position + 1 - notify: errorString , ' ->' - at: sourceStream position in: sourceStream]. + failBlock ifNotNil: [^failBlock cull: errorString cull: sourceStream position + 1]. + self error: 'Reading a number failed: ' , errorString! - ^ self fail! Item was changed: Object subclass: #NumberParser instanceVariableNames: 'sourceStream base neg integerPart fractionPart exponent scale nDigits lastNonZero requestor failBlock' classVariableNames: '' poolDictionaries: '' category: 'Kernel-Numbers'! + !NumberParser commentStamp: 'nice 2/25/2010 02:34' prior: 0! - !NumberParser commentStamp: 'nice 2/13/2010 00:31' prior: 0! NumberParser is an abstract class for parsing and building numbers from string/stream. It offers a framework with utility methods and exception handling. Number syntax is not defined and should be subclassResponsibility. Instance variables: sourceStream <Stream> the stream of characters from which the number is read base <Integer> the radix in which to interpret digits neg <Boolean> true in case of minus sign integerPart <Integer> the integer part of the number fractionPart <Integer> the fraction part of the number if any exponent <Integer> the exponent used in scientific notation if any scale <Integer> the scale used in case of ScaledDecimal number if any nDigits <Integer> number of digits read to form an Integer lasNonZero <Integer> position of last non zero digit, starting at 1 from left, 0 if all digits are zero + requestor <TextEditor | nil> can be used to insert an error message in the requestor + failBlock <BlockClosure> Block to execute whenever an error occurs. + The fail block can have 0, 1 or 2 arguments (errorString and source position)! - requestor <?> could eventually be used to insert an error message in a text editor - failBlock <BlockClosure> Block to execute whenever an error occurs! Item was removed: - ----- Method: NumberParser>>fail (in category 'error') ----- - fail - failBlock ifNotNil: [^failBlock value]. - self error: 'Reading a number failed'! |
Free forum by Nabble | Edit this page |