[Pkg] The Trunk: Kernel-eem.866.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Aug 6 17:38:12 UTC 2014


Eliot Miranda uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-eem.866.mcz

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

Name: Kernel-eem.866
Author: eem
Time: 6 August 2014, 10:37:24.712 am
UUID: 906bb1aa-c7f8-4630-ba45-5374209ddf52
Ancestors: Kernel-eem.865

Fix the bug in SqNumberParser whereby a fractional value is
parsed as a Fraction not as a Float.  Fractions are not literals
and hence factional values must be answered as Floats.
Ensure that the semantics of ExtendedNumberParser are
unchanged; it /is/ free to answer fractional values as Fractions.
Update ExtendedNumberParser's comment to reflect this.

=============== Diff against Kernel-eem.865 ===============

Item was changed:
  SqNumberParser subclass: #ExtendedNumberParser
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'Kernel-Numbers'!
  
+ !ExtendedNumberParser commentStamp: 'eem 8/6/2014 10:34' prior: 0!
+ An ExtendedNumberParser parses numbers, extending Squeak number syntax with these rules
- !ExtendedNumberParser commentStamp: 'nice 2/13/2010 00:39' prior: 0!
- An ExtendedNumberParser is extending Squeak number syntax with these rules
  
  - allow partial specification of integer and fraction parts:
  1.e2 .1e3 are both 100.0
  - allow plus sign before number and in exponent
+ - integers raised to exponents, the results of which are fractional, are answered as Fractions, not Floats
- 
  !

Item was added:
+ ----- Method: ExtendedNumberParser>>makeIntegerOrScaledInteger (in category 'parsing-private') -----
+ makeIntegerOrScaledInteger
+ 	"at this point, there is no digit, nor fractionPart.
+ 	maybe it can be a scaled decimal with fraction omitted..."
+ 	
+ 	neg
+ 		ifTrue: [integerPart := integerPart negated].
+ 	self readExponent
+ 		ifTrue: [^integerPart * (base raisedToInteger: exponent)].
+ 	(self readScaleWithDefaultNumberOfDigits: 0)
+ 		ifTrue: [^integerPart asScaledDecimal: scale].
+ 	^ integerPart!

Item was changed:
  ----- Method: SqNumberParser>>makeIntegerOrScaledInteger (in category 'parsing-private') -----
  makeIntegerOrScaledInteger
+ 	"At this point, there is no digit, nor fractionPart.
+ 	 Maybe it can be a scaled decimal with fraction omitted...
+ 	 Maybe it can be a Float with a negative exponent"
- 	"at this point, there is no digit, nor fractionPart.
- 	maybe it can be a scaled decimal with fraction omitted..."
  	
+ 	neg ifTrue:
+ 		[integerPart := integerPart negated].
+ 	self readExponent ifTrue:
+ 		["Check that the result is an integer, otherwise answer a Float.  Fractions are /not/ valid literals."
+ 		 (exponent >= 0 or: [(integerPart * (base raisedToInteger: exponent)) isInteger]) ifFalse:
+ 			[base := base asFloat].
+ 		^integerPart * (base raisedToInteger: exponent)].
+ 	(self readScaleWithDefaultNumberOfDigits: 0) ifTrue:
+ 		[^integerPart asScaledDecimal: scale].
- 	neg
- 		ifTrue: [integerPart := integerPart negated].
- 	self readExponent
- 		ifTrue: [^integerPart * (base raisedToInteger: exponent)].
- 	(self readScaleWithDefaultNumberOfDigits: 0)
- 		ifTrue: [^integerPart asScaledDecimal: scale].
  	^ integerPart!



More information about the Packages mailing list