@ -538,11 +538,11 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -538,11 +538,11 @@ namespace ICSharpCode.NRefactory.Parser.VB
digit + = ch ;
}
bool ish ex = false ;
bool isok t = false ;
bool iss ingle = false ;
bool isd ouble = false ;
bool isd ecimal = false ;
bool isH ex = false ;
bool isOc t = false ;
bool isS ingle = false ;
bool isD ouble = false ;
bool isD ecimal = false ;
if ( ReaderPeek ( ) = = - 1 ) {
if ( ch = = '&' ) {
@ -552,8 +552,8 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -552,8 +552,8 @@ namespace ICSharpCode.NRefactory.Parser.VB
}
if ( ch = = '.' ) {
if ( Char . IsDigit ( ( char ) ReaderPeek ( ) ) ) {
isd ouble = true ; // double is default
if ( ishex | | isok t ) {
isD ouble = true ; // double is default
if ( isHex | | isOc t ) {
errors . Error ( Line , Col , String . Format ( "No hexadecimal or oktadecimal floating point values allowed" ) ) ;
}
while ( ReaderPeek ( ) ! = - 1 & & Char . IsDigit ( ( char ) ReaderPeek ( ) ) ) { // read decimal digits beyond the dot
@ -568,7 +568,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -568,7 +568,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
sb . Append ( ch ) ;
digit + = Char . ToUpper ( ch , CultureInfo . InvariantCulture ) ;
}
ish ex = true ;
isH ex = true ;
} else if ( ReaderPeek ( ) ! = - 1 & & ch = = '&' & & PeekUpperChar ( ) = = 'O' ) {
const string okt = "01234567" ;
sb . Append ( ( char ) ReaderRead ( ) ) ; // skip 'O'
@ -577,7 +577,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -577,7 +577,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
sb . Append ( ch ) ;
digit + = Char . ToUpper ( ch , CultureInfo . InvariantCulture ) ;
}
isok t = true ;
isOc t = true ;
} else {
while ( ReaderPeek ( ) ! = - 1 & & Char . IsDigit ( ( char ) ReaderPeek ( ) ) ) {
ch = ( char ) ReaderRead ( ) ; ;
@ -591,7 +591,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -591,7 +591,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , 0 , LiteralFormat . DecimalNumber ) ;
}
if ( ReaderPeek ( ) ! = - 1 & & "%&SILU" . IndexOf ( PeekUpperChar ( ) ) ! = - 1 | | ishex | | isok t ) {
if ( ReaderPeek ( ) ! = - 1 & & "%&SILU" . IndexOf ( PeekUpperChar ( ) ) ! = - 1 | | isHex | | isOc t ) {
bool unsigned = false ;
if ( ReaderPeek ( ) ! = - 1 ) {
ch = ( char ) ReaderPeek ( ) ;
@ -609,7 +609,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -609,7 +609,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
}
}
try {
if ( isok t ) {
if ( isOc t ) {
ReaderRead ( ) ;
ulong number = 0L ;
for ( int i = 0 ; i < digit . Length ; + + i ) {
@ -638,26 +638,26 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -638,26 +638,26 @@ namespace ICSharpCode.NRefactory.Parser.VB
}
}
}
LiteralFormat literalFormat = ish ex ? LiteralFormat . HexadecimalNumber : LiteralFormat . DecimalNumber ;
LiteralFormat literalFormat = isH ex ? LiteralFormat . HexadecimalNumber : LiteralFormat . DecimalNumber ;
if ( ch = = 'S' ) {
ReaderRead ( ) ;
if ( unsigned )
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , UInt16 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , UInt16 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
else
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int16 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int16 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
} else if ( ch = = '%' | | ch = = 'I' ) {
ReaderRead ( ) ;
if ( unsigned )
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , UInt32 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , UInt32 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
else
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int32 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int32 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
} else if ( ch = = '&' | | ch = = 'L' ) {
ReaderRead ( ) ;
if ( unsigned )
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , UInt64 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , UInt64 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
else
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int64 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
} else if ( ish ex ) {
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int64 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , literalFormat ) ;
} else if ( isH ex ) {
ulong number = UInt64 . Parse ( digit , NumberStyles . HexNumber ) ;
if ( number > uint . MaxValue ) {
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , unchecked ( ( long ) number ) , literalFormat ) ;
@ -668,14 +668,17 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -668,14 +668,17 @@ namespace ICSharpCode.NRefactory.Parser.VB
} catch ( OverflowException ex ) {
errors . Error ( Line , Col , ex . Message ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , 0 , LiteralFormat . None ) ;
} catch ( FormatException ex2 ) {
errors . Error ( Line , Col , String . Format ( "{0} is not a parseable number" , digit ) ) ;
return new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , 0 , LiteralFormat . None ) ;
}
}
Token nextToken = null ; // if we accedently read a 'dot'
if ( ! isd ouble & & ReaderPeek ( ) = = '.' ) { // read floating point number
Token nextToken = null ; // if we acci dently read a 'dot'
if ( ! isD ouble & & ReaderPeek ( ) = = '.' ) { // read floating point number
ReaderRead ( ) ;
if ( ReaderPeek ( ) ! = - 1 & & Char . IsDigit ( ( char ) ReaderPeek ( ) ) ) {
isd ouble = true ; // double is default
if ( ishex | | isok t ) {
isD ouble = true ; // double is default
if ( isHex | | isOc t ) {
errors . Error ( Line , Col , String . Format ( "No hexadecimal or oktadecimal floating point values allowed" ) ) ;
}
digit + = '.' ;
@ -688,7 +691,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -688,7 +691,7 @@ namespace ICSharpCode.NRefactory.Parser.VB
}
if ( ReaderPeek ( ) ! = - 1 & & PeekUpperChar ( ) = = 'E' ) { // read exponent
isd ouble = true ;
isD ouble = true ;
digit + = ( char ) ReaderRead ( ) ;
if ( ReaderPeek ( ) ! = - 1 & & ( ReaderPeek ( ) = = '-' | | ReaderPeek ( ) = = '+' ) ) {
digit + = ( char ) ReaderRead ( ) ;
@ -703,46 +706,46 @@ namespace ICSharpCode.NRefactory.Parser.VB
@@ -703,46 +706,46 @@ namespace ICSharpCode.NRefactory.Parser.VB
case 'R' :
case '#' :
ReaderRead ( ) ;
isd ouble = true ;
isD ouble = true ;
break ;
case 'D' :
case '@' :
ReaderRead ( ) ;
isd ecimal = true ;
isD ecimal = true ;
break ;
case 'F' :
case '!' :
ReaderRead ( ) ;
iss ingle = true ;
isS ingle = true ;
break ;
}
}
try {
if ( iss ingle ) {
if ( isS ingle ) {
return new Token ( Tokens . LiteralSingle , x , y , sb . ToString ( ) , Single . Parse ( digit , CultureInfo . InvariantCulture ) , LiteralFormat . DecimalNumber ) ;
}
if ( isd ecimal ) {
if ( isD ecimal ) {
return new Token ( Tokens . LiteralDecimal , x , y , sb . ToString ( ) , Decimal . Parse ( digit , NumberStyles . Currency | NumberStyles . AllowExponent , CultureInfo . InvariantCulture ) , LiteralFormat . DecimalNumber ) ;
}
if ( isd ouble ) {
if ( isD ouble ) {
return new Token ( Tokens . LiteralDouble , x , y , sb . ToString ( ) , Double . Parse ( digit , CultureInfo . InvariantCulture ) , LiteralFormat . DecimalNumber ) ;
}
} catch ( FormatException ) {
errors . Error ( Line , Col , String . Format ( "{0} is not a parseable number" , digit ) ) ;
if ( iss ingle )
if ( isS ingle )
return new Token ( Tokens . LiteralSingle , x , y , sb . ToString ( ) , 0f , LiteralFormat . DecimalNumber ) ;
if ( isd ecimal )
if ( isD ecimal )
return new Token ( Tokens . LiteralDecimal , x , y , sb . ToString ( ) , 0 m , LiteralFormat . DecimalNumber ) ;
if ( isd ouble )
if ( isD ouble )
return new Token ( Tokens . LiteralDouble , x , y , sb . ToString ( ) , 0.0 , LiteralFormat . DecimalNumber ) ;
}
Token token ;
try {
token = new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int32 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , ish ex ? LiteralFormat . HexadecimalNumber : LiteralFormat . DecimalNumber ) ;
token = new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int32 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , isH ex ? LiteralFormat . HexadecimalNumber : LiteralFormat . DecimalNumber ) ;
} catch ( Exception ) {
try {
token = new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int64 . Parse ( digit , ish ex ? NumberStyles . HexNumber : NumberStyles . Number ) , ish ex ? LiteralFormat . HexadecimalNumber : LiteralFormat . DecimalNumber ) ;
token = new Token ( Tokens . LiteralInteger , x , y , sb . ToString ( ) , Int64 . Parse ( digit , isH ex ? NumberStyles . HexNumber : NumberStyles . Number ) , isH ex ? LiteralFormat . HexadecimalNumber : LiteralFormat . DecimalNumber ) ;
} catch ( FormatException ) {
errors . Error ( Line , Col , String . Format ( "{0} is not a parseable number" , digit ) ) ;
// fallback, when nothing helps :)