The Trunk: Kernel-nice.399.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-nice.399.mcz

commits-2
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.399.mcz

==================== Summary ====================

Name: Kernel-nice.399
Author: nice
Time: 13 February 2010, 5:14:04.309 pm
UUID: 426cc492-dbd7-ac48-9efb-d32c46007a76
Ancestors: Kernel-nice.398

Merge minor changes from Pharo.
Correct a bug (concatenating aString , aCharacter)

=============== Diff against Kernel-nice.398 ===============

Item was changed:
  ----- Method: SqNumberParser>>readNamedFloatOrFail (in category 'parsing-private') -----
  readNamedFloatOrFail
  "This method is used when there is no digit encountered:
  It try and read a named Float NaN or Infinity.
  Negative sign for -Infinity has been read before sending this method, and is indicated in the neg inst.var.
  Fail if no named Float is found"
 
  neg ifFalse: [(sourceStream nextMatchAll: 'NaN')
  ifTrue: [^ Float nan]].
  (sourceStream nextMatchAll: 'Infinity')
  ifTrue: [^ neg
  ifTrue: [Float infinity negated]
  ifFalse: [Float infinity]].
+ ^self expected: 'a digit between 0 and ' , (String with: (Character digitValue: base - 1))!
- ^self expected: 'a digit between 0 and ' , (Character digitValue: base - 1)!

Item was changed:
  ----- Method: NumberParser>>readExponent (in category 'parsing-private') -----
  readExponent
  "read the exponent if any (stored in instVar).
  Answer true if found, answer false if none.
  If exponent letter is not followed by a digit,
  this is not considered as an error.
  Exponent are always read in base 10."
 
  | eneg epos |
  exponent := 0.
  sourceStream atEnd ifTrue: [^ false].
  (self exponentLetters includes: sourceStream peek)
  ifFalse: [^ false].
  sourceStream next.
  eneg := sourceStream peekFor: $-.
  epos := eneg not and: [self allowPlusSignInExponent and: [sourceStream peekFor: $+]].
  exponent := self nextUnsignedIntegerOrNilBase: 10.
+ exponent ifNil: ["Oops, there was no digit after the exponent letter.Ungobble the letter"
- exponent isNil ifTrue: ["Oops, there was no digit after the exponent letter.Ungobble the letter"
  exponent := 0.
  sourceStream
  skip: ((eneg or: [epos])
  ifTrue: [-2]
  ifFalse: [-1]).
  ^ false].
  eneg ifTrue: [exponent := exponent negated].
  ^true!

Item was changed:
  ----- Method: SqNumberParser>>nextNumber (in category 'parsing-public') -----
  nextNumber
  "main method for reading a number.
  This one can read Float Integer and ScaledDecimal"
 
  | numberOfTrailingZeroInIntegerPart |
  base := 10.
  neg := self peekSignIsMinus.
  integerPart := self nextUnsignedIntegerOrNilBase: base.
  integerPart ifNil: [
  "This is not a regular number beginning with a digit
  It is time to check for exceptional condition NaN and Infinity"
  ^self readNamedFloatOrFail].
  numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero.
  (sourceStream peekFor: $r)
  ifTrue: ["<base>r<integer>"
  (base := integerPart) < 2
  ifTrue: [^ self expected: 'an integer greater than 1 as valid radix'].
+ self peekSignIsMinus
- (sourceStream peekFor: $-)
  ifTrue: [neg := neg not].
  integerPart := self nextUnsignedIntegerBase: base.
  numberOfTrailingZeroInIntegerPart := nDigits - lastNonZero].
  ^ (sourceStream peekFor: $.)
  ifTrue: [self readNumberWithFractionPartNumberOfTrailingZeroInIntegerPart: numberOfTrailingZeroInIntegerPart]
  ifFalse: [self makeIntegerOrScaledInteger]!

Item was changed:
  ----- Method: NumberParser>>expected: (in category 'error') -----
  expected: errorString
  requestor isNil
  ifFalse: [requestor
  notify: errorString , ' ->'
  at: sourceStream position
  in: sourceStream].
+ ^ self fail!
- self fail!

Item was changed:
  ----- Method: Number class>>readFrom: (in category 'instance creation') -----
  readFrom: stringOrStream
  "Answer a number as described on aStream.  The number may
  be any accepted Smalltalk literal Number format.
  It can include a leading radix specification, as in 16rFADE.
+ It can as well be NaN, Infinity or -Infinity for conveniency.
+ If stringOrStream does not start with a valid number description, fail."
- It can as well be NaN, Infinity or -Infinity for conveniency."
 
  ^(SqNumberParser on: stringOrStream) nextNumber!

Item was changed:
  ----- Method: NumberParser>>on: (in category 'initialize-release') -----
+ on: aStringOrStream
+ sourceStream := aStringOrStream isString
+ ifTrue: [ aStringOrStream readStream ]
+ ifFalse: [ aStringOrStream ].
- on: aStringOrStream
- sourceStream := aStringOrStream isString
- ifTrue: [ReadStream on: aStringOrStream]
- ifFalse: [aStringOrStream].
  base := 10.
  neg := false.
  integerPart := fractionPart := exponent := scale := 0.
+ requestor := failBlock := nil!
- requestor := failBlock := nil.!

Item was changed:
  ----- Method: NumberParser>>fail (in category 'error') -----
  fail
+ failBlock ifNotNil: [^failBlock value].
- failBlock isNil ifFalse: [^failBlock value].
  self error: 'Reading a number failed'!