Ticket #132: ticket132-number-fractional-lit.patch
File ticket132-number-fractional-lit.patch, 4.3 KB (added by hopscc, 16 years ago) |
---|
-
Source/CobraParser.cobra
220 220 _tokens = nil 221 221 if _tokenizer is nil 222 222 _tokenizer = CobraTokenizer(tokVerbosity) 223 _tokenizer.typeProvider = .typeProvider 224 223 225 tokenizer = _tokenizer 224 226 try 225 227 tokens = tokenizer.startSource(_fileName, source).allTokens -
Source/CobraTokenizer.cobra
54 54 var _inSubstStringDouble = false 55 55 var _inDocString = false 56 56 var _inCommentBlock = 0 57 57 set typeProvider from var as ITypeProvider? 58 58 59 def init 59 60 base.init 60 61 … … 498 499 def onFRACTIONAL_LIT(tok as IToken) as IToken? 499 500 s = tok.text.replace('_', '') 500 501 try 501 tok.value = decimal.parse(s, Utils.cultureInfoForNumbers) 502 numTypeStr = 'decimal' 503 assert _typeProvider 504 numberType = _typeProvider.numberType 505 # parse literal to same type as numberType 506 if numberType inherits DecimalType 507 tok.value = decimal.parse(s, Utils.cultureInfoForNumbers) 508 else 509 numTypeStr = 'float' 510 tok.value = float.parse(s, Utils.cultureInfoForNumbers) 511 tok.which = 'FLOAT_LIT' 512 tok.info = if(numberType == _typeProvider.floatType(32), 32, 64) 502 513 catch FormatException 503 514 assert false, 'not expecting to get here given regex' 504 515 catch OverflowException 505 assert false, 'TODO: FRACTIONAL_LIT Overflow'516 .throwError('[numTypeStr] Overflow in parse of Fractional Literal [tok.text]') 506 517 return tok 507 518 508 519 def onINTEGER_LIT(tok as IToken) as IToken? -
Tests/820-errors/600-other/130-number-lit-decimal.cobra
1 class NumbFloat 2 def main is shared 3 a as number = 79_228_162_514_264_337_593_543_950_33.4 4 assert a.getType is Single 5 # literal > max decimal 6 b as number = 80_228_162_514_264_337_593_543_950_335.1 #.error. decimal overflow in parse 7 assert b.getType is Single 8 9 c = 85_228_162_514_264_337_593_543_950_335.1 # .error. decimal overflow in parse 10 assert c.getType is Single -
Tests/200-misc/300-number-type/110-number-lit-float.cobra
1 # .args. -number:float 2 class NumbFloat 3 def main is shared 4 # < max Decimal 5 a as number = 79_228_162_514_264_337_593_543_950_33.4 6 # literal > max decimal 7 b as number = 80_228_162_514_264_337_593_543_950_335.1 8 assert a.getType is Double 9 assert b.getType is Double 10 11 c = 85_228_162_514_264_337_593_543_950_335.1 12 assert c.getType is Double -
Tests/200-misc/300-number-type/112-number-lit-float32.cobra
1 # .args. -number:float32 2 class NumbFloat 3 def main is shared 4 # < max Decimal 5 a as number = 79_228_162_514_264_337_593_543_950_33.4 6 assert a.getType is Single 7 # literal > max decimal 8 b as number = 80_228_162_514_264_337_593_543_950_335.1 9 assert b.getType is Single 10 11 c = 85_228_162_514_264_337_593_543_950_335.1 12 assert c.getType is Single -
Developer/IntermediateReleaseNotes.text
295 295 * Fixed: Cannot qualify an attribute. ticket:121 296 296 297 297 * Fixed: Cannot read nested classes in binary libraries in some circumstances. ticket:127 298 299 * Fixed: Fractional Literals dont parse to non Decimal -number setting. ticket:132