@ -44,9 +44,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
return new Token ( Tokens . Identifier , x , y , s ) ;
return new Token ( Tokens . Identifier , x , y , s ) ;
}
}
if ( Char . IsDigit ( ch ) ) {
Token token ;
return ReadDigit ( ch , Col - 1 ) ;
}
switch ( ch ) {
switch ( ch ) {
case '/' :
case '/' :
@ -54,6 +52,8 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
if ( peek = = '/' | | peek = = '*' ) {
if ( peek = = '/' | | peek = = '*' ) {
ReadComment ( ) ;
ReadComment ( ) ;
continue ;
continue ;
} else {
token = ReadOperator ( '/' ) ;
}
}
break ;
break ;
case '#' :
case '#' :
@ -63,35 +63,43 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
this . specialTracker . AddPreProcessingDirective ( directive , argument . Trim ( ) , start , new Point ( start . X + directive . Length + argument . Length , start . Y ) ) ;
this . specialTracker . AddPreProcessingDirective ( directive , argument . Trim ( ) , start , new Point ( start . X + directive . Length + argument . Length , start . Y ) ) ;
continue ;
continue ;
case '"' :
case '"' :
return ReadString ( ) ;
token = ReadString ( ) ;
break ;
case '\'' :
case '\'' :
return ReadChar ( ) ;
token = ReadChar ( ) ;
break ;
case '@' :
case '@' :
int next = ReaderRead ( ) ;
int next = ReaderRead ( ) ;
if ( next = = - 1 ) {
if ( next = = - 1 ) {
errors . Error ( Line , Col , String . Format ( "EOF after @" ) ) ;
errors . Error ( Line , Col , String . Format ( "EOF after @" ) ) ;
continue ;
} else {
} else {
int x = Col - 1 ;
int x = Col - 1 ;
int y = Line ;
int y = Line ;
ch = ( char ) next ;
ch = ( char ) next ;
if ( ch = = '"' ) {
if ( ch = = '"' ) {
return ReadVerbatimString ( ) ;
token = ReadVerbatimString ( ) ;
} else if ( Char . IsLetterOrDigit ( ch ) ) {
token = new Token ( Tokens . Identifier , x - 1 , y , ReadIdent ( ch ) ) ;
} else {
errors . Error ( y , x , String . Format ( "Unexpected char in Lexer.Next() : {0}" , ch ) ) ;
continue ;
}
}
if ( Char . IsLetterOrDigit ( ch ) ) {
}
return new Token ( Tokens . Identifier , x - 1 , y , ReadIdent ( ch ) ) ;
break ;
}
default :
errors . Error ( y , x , String . Format ( "Unexpected char in Lexer.Next() : {0}" , ch ) ) ;
if ( Char . IsDigit ( ch ) ) {
token = ReadDigit ( ch , Col - 1 ) ;
} else {
token = ReadOperator ( ch ) ;
}
}
break ;
break ;
}
}
Token token = ReadOperator ( ch ) ;
// try error recovery (token = null -> continue with next char)
if ( token ! = null ) {
// try error recovery :)
return token ;
if ( token = = null ) {
return Next ( ) ;
}
}
return token ;
}
}
return new Token ( Tokens . EOF , Col , Line , String . Empty ) ;
return new Token ( Tokens . EOF , Col , Line , String . Empty ) ;
@ -606,7 +614,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
return new Token ( Tokens . LessThan , x , y ) ;
return new Token ( Tokens . LessThan , x , y ) ;
case '>' :
case '>' :
switch ( ReaderPeek ( ) ) {
switch ( ReaderPeek ( ) ) {
// Removed because of generics:
// Removed because of generics:
// case '>':
// case '>':
// ReaderRead();
// ReaderRead();
// if (ReaderPeek() != -1) {
// if (ReaderPeek() != -1) {
@ -640,7 +648,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
// Prevent OverflowException when ReaderPeek returns -1
// Prevent OverflowException when ReaderPeek returns -1
int tmp = ReaderPeek ( ) ;
int tmp = ReaderPeek ( ) ;
if ( tmp > 0 & & Char . IsDigit ( ( char ) tmp ) ) {
if ( tmp > 0 & & Char . IsDigit ( ( char ) tmp ) ) {
return ReadDigit ( '.' , Col - 1 ) ;
return ReadDigit ( '.' , Col - 1 ) ;
}
}
return new Token ( Tokens . Dot , x , y ) ;
return new Token ( Tokens . Dot , x , y ) ;
case ')' :
case ')' :
@ -702,7 +710,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
curWord . Length = 0 ;
curWord . Length = 0 ;
if ( specialCommentHash . ContainsKey ( tag ) ) {
if ( specialCommentHash . ContainsKey ( tag ) ) {
Point p = new Point ( Col , Line ) ;
Point p = new Point ( Col , Line ) ;
string comment = ReadToEOL ( ) ;
string comment = ch + ReadToEOL ( ) ;
tagComments . Add ( new TagComment ( tag , comment , p , new Point ( Col , Line ) ) ) ;
tagComments . Add ( new TagComment ( tag , comment , p , new Point ( Col , Line ) ) ) ;
sb . Append ( comment ) ;
sb . Append ( comment ) ;
break ;
break ;