Index: src/Boo.Lang.Parser/boo.g =================================================================== --- src/Boo.Lang.Parser/boo.g (revision 1773) +++ src/Boo.Lang.Parser/boo.g (working copy) @@ -245,9 +245,9 @@ return LPAREN != token && LBRACK != token; } - static double ParseDouble(string text) + static double ParseDouble(string s) { - return double.Parse(text, CultureInfo.InvariantCulture); + return double.Parse(s, NumberStyles.Float, CultureInfo.InvariantCulture); } protected IntegerLiteralExpression ParseIntegerLiteralExpression( @@ -260,11 +260,13 @@ if (s.StartsWith(HEX_PREFIX)) { value = long.Parse( - s.Substring(HEX_PREFIX.Length), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture); + s.Substring(HEX_PREFIX.Length), NumberStyles.AllowHexSpecifier, + CultureInfo.InvariantCulture); } else { - value = long.Parse(s, CultureInfo.InvariantCulture); + value = long.Parse(s, NumberStyles.Integer | NumberStyles.AllowExponent, + CultureInfo.InvariantCulture); } return new IntegerLiteralExpression(ToLexicalInfo(token), value, isLong); } @@ -2569,16 +2571,24 @@ INT : ("0x"(HEXDIGIT)+)(('l' | 'L') { $setType(LONG); })? | (DIGIT)+ + (('e'|'E')('+'|'-')? (DIGIT)+)? ( ('l' | 'L') { $setType(LONG); } | ( - ({BooLexer.IsDigit(LA(2))}? ('.' (DIGIT)+) { $setType(DOUBLE); })? + ( + {BooLexer.IsDigit(LA(2))}? + ( + '.' (DIGIT)+ + (('e'|'E')('+'|'-')? (DIGIT)+)? + ) + { $setType(DOUBLE); } + )? (("ms" | 's' | 'm' | 'h' | 'd') { $setType(TIMESPAN); })? ) ) ; -DOT : '.' ((DIGIT)+ {$setType(DOUBLE);})?; +DOT : '.' ((DIGIT)+ (('e'|'E')('+'|'-')? (DIGIT)+)? {$setType(DOUBLE);})?; COLON : ':'; Index: src/Boo.Lang.Parser/booel.g =================================================================== --- src/Boo.Lang.Parser/booel.g (revision 1773) +++ src/Boo.Lang.Parser/booel.g (working copy) @@ -61,16 +61,24 @@ INT : ("0x"(HEXDIGIT)+)(('l' | 'L') { $setType(LONG); })? | (DIGIT)+ + (('e'|'E')('+'|'-')? (DIGIT)+)? ( ('l' | 'L') { $setType(LONG); } | ( - ({BooLexer.IsDigit(LA(2))}? ('.' (DIGIT)+) { $setType(DOUBLE); })? + ( + {BooLexer.IsDigit(LA(2))}? + ( + '.' (DIGIT)+ + (('e'|'E')('+'|'-')? (DIGIT)+)? + ) + { $setType(DOUBLE); } + )? (("ms" | 's' | 'm' | 'h' | 'd') { $setType(TIMESPAN); })? ) ) ; -DOT : '.' ((DIGIT)+ {$setType(DOUBLE);})?; +DOT : '.' ((DIGIT)+ (('e'|'E')('+'|'-')? (DIGIT)+)? {$setType(DOUBLE);})?; COLON : ':'; Index: tests/testcases/compilation/exponential0.boo =================================================================== --- tests/testcases/compilation/exponential0.boo (revision 0) +++ tests/testcases/compilation/exponential0.boo (revision 0) @@ -0,0 +1,53 @@ +""" +100 System.Int32 +100 System.Int32 +110 System.Double +0.011 System.Double +100 System.Int64 +00:10:00 System.TimeSpan +00:00:03.6000000 System.TimeSpan +90 System.Double +100 +100 +110 +0.011 +100 +00:10:00 +00:00:03.6000000 +90 +""" + +x = 1e+2 +print x, x.GetType() //100 +x2 = 1e2 +print x2, x2.GetType() //100 +x4 = 1.1e+2 +print x4, x4.GetType() //110 +x5 = 1.1e-2 +print x5, x5.GetType() //0.011 +x6 = 1e+2L +print x6, x6.GetType() //100 long +x7 = 6e+2s +print x7, x7.GetType() //10:00 +x8 = 10.0e-4h +print x8, x8.GetType() //3.6 seconds +x9 = .9e2 +print x9, x9.GetType() //90 + +s = "${1e+2}" +print s +s2 = "${1e2}" +print s2 +s4 = "${1.1e+2}" +print s4 +s5 = "${1.1e-2}" +print s5 +s6 = "${1e+2L}" +print s6 +s7 = "${6e+2s}" +print s7 +s8 = "${10.0e-4h}" +print s8 +s9 = "${.9e2}" +print s9 +