Browse Source

* Src/Lexer/CSharp/Lexer.cs:

* Src/Lexer/AbstractLexer.cs: #if/#elif preprocessor directive now
  contain the arg as string representation too (arg was null).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3937 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Mike Krüger 17 years ago
parent
commit
cec95aa60d
  1. 6
      src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs
  2. 7
      src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

6
src/Libraries/NRefactory/Project/Src/Lexer/AbstractLexer.cs

@ -73,10 +73,16 @@ namespace ICSharpCode.NRefactory.Parser @@ -73,10 +73,16 @@ namespace ICSharpCode.NRefactory.Parser
return col;
}
}
protected bool recordRead = false;
protected StringBuilder recordedText = new StringBuilder ();
protected int ReaderRead()
{
++col;
int val = reader.Read();
if (recordRead)
recordedText.Append ((char)val);
if ((val == '\r' && reader.Peek() != '\n') || val == '\n') {
++line;
col = 1;

7
src/Libraries/NRefactory/Project/Src/Lexer/CSharp/Lexer.cs

@ -1092,7 +1092,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -1092,7 +1092,12 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
PPWhitespace();
if (parseIfExpression && directive == "#if" || parseElifExpression && directive == "#elif") {
recordedText.Length = 0;
recordRead = true;
Ast.Expression expr = PPExpression();
string arg = recordedText.ToString ();
recordRead = false;
Location endLocation = new Location(Col, Line);
int c = ReaderRead();
if (c >= 0 && !HandleLineEnd((char)c)) {
@ -1103,7 +1108,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp @@ -1103,7 +1108,7 @@ namespace ICSharpCode.NRefactory.Parser.CSharp
}
SkipToEndOfLine(); // skip comment
}
return new PreprocessingDirective(directive, null, start, endLocation) { Expression = expr, LastLineEnd = lastLineEnd };
return new PreprocessingDirective(directive, arg, start, endLocation) { Expression = expr, LastLineEnd = lastLineEnd };
} else {
Location endLocation = new Location(Col, Line);
string arg = ReadToEndOfLine();

Loading…
Cancel
Save