1 write to TextWindow
Microsoft.CodeAnalysis.CSharp (1)
Parser\AbstractLexer.cs (1)
21
this.
TextWindow
= new SlidingTextWindow(text);
671 references to TextWindow
Microsoft.CodeAnalysis.CSharp (671)
Parser\AbstractLexer.cs (4)
26
this.
TextWindow
.Dispose();
31
TextWindow
.Start();
134
return position >=
TextWindow
.LexemeStartPosition ? position -
TextWindow
.LexemeStartPosition : position;
Parser\Blender.cs (1)
69
_newPosition = lexer.
TextWindow
.Position;
Parser\Blender.Reader.cs (1)
165
if (_lexer.
TextWindow
.Position != _newPosition)
Parser\DirectiveParser.cs (1)
36
var hashPosition = lexer.
TextWindow
.Position;
Parser\LanguageParser.cs (2)
219
return CreateForGlobalFailure(lexer.
TextWindow
.Position, createEmptyNodeFunc(this));
229
builder.Add(SyntaxFactory.BadToken(null, lexer.
TextWindow
.Text.ToString(), null));
Parser\Lexer.cs (479)
172
this.
TextWindow
.Reset(position);
310
this.LexSyntaxTrivia(isFollowingToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
329
this.LexSyntaxTrivia(isFollowingToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
449
int startingPosition =
TextWindow
.Position;
452
character =
TextWindow
.PeekChar();
461
TextWindow
.AdvanceChar();
462
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.SlashEqualsToken : SyntaxKind.SlashToken;
466
if (this.
TextWindow
.PeekChar(1) is >= '0' and <= '9')
468
var atDotPosition = this.
TextWindow
.Position;
470
atDotPosition == this.
TextWindow
.LexemeStartPosition)
478
if (this.
TextWindow
.PreviousChar() is '.')
481
TextWindow
.AdvanceChar();
492
TextWindow
.AdvanceChar();
499
TextWindow
.AdvanceChar();
504
TextWindow
.AdvanceChar();
505
info.Kind =
TextWindow
.TryAdvance(':') ? SyntaxKind.ColonColonToken : SyntaxKind.ColonToken;
509
TextWindow
.AdvanceChar();
514
TextWindow
.AdvanceChar();
519
TextWindow
.AdvanceChar();
520
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.ExclamationEqualsToken : SyntaxKind.ExclamationToken;
524
TextWindow
.AdvanceChar();
526
TextWindow
.TryAdvance('=') ? SyntaxKind.EqualsEqualsToken :
527
TextWindow
.TryAdvance('>') ? SyntaxKind.EqualsGreaterThanToken : SyntaxKind.EqualsToken;
531
TextWindow
.AdvanceChar();
532
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.AsteriskEqualsToken : SyntaxKind.AsteriskToken;
536
TextWindow
.AdvanceChar();
541
TextWindow
.AdvanceChar();
546
TextWindow
.AdvanceChar();
551
TextWindow
.AdvanceChar();
556
TextWindow
.AdvanceChar();
561
TextWindow
.AdvanceChar();
566
TextWindow
.AdvanceChar();
567
info.Kind =
TextWindow
.TryAdvance('?')
568
?
TextWindow
.TryAdvance('=') ? SyntaxKind.QuestionQuestionEqualsToken : SyntaxKind.QuestionQuestionToken
573
TextWindow
.AdvanceChar();
575
TextWindow
.TryAdvance('=') ? SyntaxKind.PlusEqualsToken :
576
TextWindow
.TryAdvance('+') ? SyntaxKind.PlusPlusToken : SyntaxKind.PlusToken;
580
TextWindow
.AdvanceChar();
582
TextWindow
.TryAdvance('=') ? SyntaxKind.MinusEqualsToken :
583
TextWindow
.TryAdvance('-') ? SyntaxKind.MinusMinusToken :
584
TextWindow
.TryAdvance('>') ? SyntaxKind.MinusGreaterThanToken : SyntaxKind.MinusToken;
588
TextWindow
.AdvanceChar();
589
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.PercentEqualsToken : SyntaxKind.PercentToken;
593
TextWindow
.AdvanceChar();
595
TextWindow
.TryAdvance('=') ? SyntaxKind.AmpersandEqualsToken :
596
TextWindow
.TryAdvance('&') ? SyntaxKind.AmpersandAmpersandToken : SyntaxKind.AmpersandToken;
600
TextWindow
.AdvanceChar();
601
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.CaretEqualsToken : SyntaxKind.CaretToken;
605
TextWindow
.AdvanceChar();
607
TextWindow
.TryAdvance('=') ? SyntaxKind.BarEqualsToken :
608
TextWindow
.TryAdvance('|') ? SyntaxKind.BarBarToken : SyntaxKind.BarToken;
612
TextWindow
.AdvanceChar();
614
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanEqualsToken :
615
TextWindow
.TryAdvance('<')
616
?
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanLessThanEqualsToken : SyntaxKind.LessThanLessThanToken
621
TextWindow
.AdvanceChar();
622
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.GreaterThanEqualsToken : SyntaxKind.GreaterThanToken;
629
Debug.Assert(
TextWindow
.PeekChar() == '@');
631
if (
TextWindow
.PeekChar(1) == ':')
636
this.AddError(
TextWindow
.Position + 1, width: 1, ErrorCode.ERR_ExpectedVerbatimLiteral);
639
info.Text =
TextWindow
.GetText(false);
644
info.Text =
TextWindow
.GetText(intern: true);
685
if (!
TextWindow
.IsReallyAtEnd())
716
TextWindow
.AdvanceChar();
721
if (char.IsHighSurrogate(character) && char.IsLowSurrogate(
TextWindow
.PeekChar()))
722
TextWindow
.AdvanceChar();
730
info.Text =
TextWindow
.GetText(intern: true);
734
int end =
TextWindow
.Text.Length;
735
info.Text =
TextWindow
.Text.ToString(TextSpan.FromBounds(startingPosition, end));
736
TextWindow
.Reset(end);
753
Debug.Assert(
TextWindow
.PeekChar() == '@');
756
while (
TextWindow
.PeekChar(index) == '@')
761
if (
TextWindow
.PeekChar(index) == '"')
767
else if (
TextWindow
.PeekChar(index) == '$')
779
Debug.Assert(
TextWindow
.PeekChar() == '$');
781
if (
TextWindow
.PeekChar(1) is '$' or '@' or '"')
806
int start =
TextWindow
.Position;
807
while (
TextWindow
.PeekChar() is >= '0' and <= '9')
809
TextWindow
.AdvanceChar();
812
return start <
TextWindow
.Position;
818
if (
TextWindow
.PeekChar() == '_')
833
char ch =
TextWindow
.PeekChar();
850
TextWindow
.AdvanceChar();
861
int start =
TextWindow
.Position;
876
ch =
TextWindow
.PeekChar();
879
ch =
TextWindow
.PeekChar(1);
882
TextWindow
.AdvanceChar(2);
888
TextWindow
.AdvanceChar(2);
899
if (
TextWindow
.PeekChar() is 'L' or 'l')
901
TextWindow
.AdvanceChar();
903
if (
TextWindow
.PeekChar() is 'u' or 'U')
905
TextWindow
.AdvanceChar();
909
else if (
TextWindow
.PeekChar() is 'u' or 'U')
911
TextWindow
.AdvanceChar();
913
if (
TextWindow
.PeekChar() is 'L' or 'l')
915
TextWindow
.AdvanceChar();
924
if (this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar() == '#')
927
TextWindow
.AdvanceChar();
928
info.StringValue = info.Text =
TextWindow
.GetText(intern: true);
934
if ((ch =
TextWindow
.PeekChar()) == '.')
936
var ch2 =
TextWindow
.PeekChar(1);
941
TextWindow
.AdvanceChar();
948
TextWindow
.Reset(start);
953
if ((ch =
TextWindow
.PeekChar()) is 'E' or 'e')
956
TextWindow
.AdvanceChar();
958
if ((ch =
TextWindow
.PeekChar()) is '-' or '+')
961
TextWindow
.AdvanceChar();
964
if (!(((ch =
TextWindow
.PeekChar()) >= '0' && ch <= '9') || ch == '_'))
977
ch =
TextWindow
.PeekChar();
982
TextWindow
.AdvanceChar();
987
TextWindow
.AdvanceChar();
992
TextWindow
.AdvanceChar();
1002
TextWindow
.AdvanceChar();
1007
TextWindow
.AdvanceChar();
1012
TextWindow
.AdvanceChar();
1017
TextWindow
.AdvanceChar();
1019
if (
TextWindow
.PeekChar() is 'u' or 'U')
1021
TextWindow
.AdvanceChar();
1028
TextWindow
.AdvanceChar();
1029
if (
TextWindow
.PeekChar() is 'L' or 'l')
1031
TextWindow
.AdvanceChar();
1039
this.AddError(MakeError(start,
TextWindow
.Position - start, ErrorCode.ERR_InvalidNumber));
1051
info.Text =
TextWindow
.GetText(true);
1053
var valueText =
TextWindow
.Intern(_builder);
1064
info.DecimalValue = this.GetValueDecimal(valueText, start,
TextWindow
.Position);
1344
var currentOffset =
TextWindow
.Offset;
1345
var characterWindow =
TextWindow
.CharacterWindow;
1346
var characterWindowCount =
TextWindow
.CharacterWindowCount;
1409
TextWindow
.AdvanceChar(length);
1410
info.Text = info.StringValue =
TextWindow
.Intern(characterWindow, startOffset, length);
1442
int start =
TextWindow
.Position;
1445
while (
TextWindow
.PeekChar() == '@')
1447
TextWindow
.AdvanceChar();
1450
var atCount =
TextWindow
.Position - start;
1458
char ch =
TextWindow
.PeekChar();
1481
if (!
TextWindow
.IsReallyAtEnd())
1501
(char.ToLower(
TextWindow
.PeekChar(1)) == 'x'))
1535
if (_identLen == 0 && this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar(1) == '>')
1538
TextWindow
.AdvanceChar(2);
1565
TextWindow
.AdvanceChar();
1589
TextWindow
.AdvanceChar();
1600
var width =
TextWindow
.Width; // exact size of input characters
1603
info.Text =
TextWindow
.GetInternedText();
1612
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1620
var valueText =
TextWindow
.Intern(_identBuffer, objectAddressOffset, _identLen - objectAddressOffset);
1641
TextWindow
.Reset(start);
1657
int start =
TextWindow
.Position;
1676
int beforeConsumed =
TextWindow
.Position;
1680
if (
TextWindow
.PeekChar() == '&')
1685
TextWindow
.Reset(beforeConsumed);
1691
consumedChar =
TextWindow
.NextChar();
1711
if (!isEscaped && (
TextWindow
.Position == beforeConsumed + 1) &&
1712
TextWindow
.PeekChar() is 'u' or 'U')
1718
TextWindow
.Reset(beforeConsumed);
1740
TextWindow
.Reset(beforeConsumed);
1758
TextWindow
.Reset(beforeConsumed);
1761
if (!
TextWindow
.IsReallyAtEnd())
1766
TextWindow
.Reset(beforeConsumed);
1788
TextWindow
.Reset(beforeConsumed);
1809
var width =
TextWindow
.Width; // exact size of input characters
1814
info.StringValue =
TextWindow
.GetInternedText();
1819
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1820
info.Text =
TextWindow
.GetText(intern: false);
1829
TextWindow
.Reset(start);
1898
char ch =
TextWindow
.PeekChar();
1926
if ((ch =
TextWindow
.PeekChar(1)) == '/')
1928
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
1948
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '*' &&
1949
TextWindow
.PeekChar(3) != '*' &&
TextWindow
.PeekChar(3) != '/')
1970
if ((ch =
TextWindow
.PeekChar(1)) == '*')
1973
this.AddError(
TextWindow
.Position, width: 1, ErrorCode.ERR_UnexpectedCharacter, '@');
2004
var savePosition =
TextWindow
.Position;
2010
var text =
TextWindow
.Text.GetSubText(TextSpan.FromBounds(savePosition,
TextWindow
.Position));
2059
var text =
TextWindow
.GetText(false);
2073
var text =
TextWindow
.GetText(false);
2084
var position =
TextWindow
.Position;
2085
var text =
TextWindow
.Text;
2118
this.AddError(
TextWindow
.Position, s_conflictMarkerLength,
2121
var startCh = this.
TextWindow
.PeekChar();
2147
var ch = this.
TextWindow
.PeekChar();
2166
this.
TextWindow
.AdvanceChar();
2169
if (this.
TextWindow
.Width > 0)
2171
this.AddTrivia(SyntaxFactory.DisabledText(
TextWindow
.GetText(false)), ref triviaList);
2185
while (SyntaxFacts.IsNewLine(this.
TextWindow
.PeekChar()))
2187
this.
TextWindow
.AdvanceChar();
2190
if (this.
TextWindow
.Width > 0)
2192
this.AddTrivia(SyntaxFactory.EndOfLine(
TextWindow
.GetText(false)), ref triviaList);
2200
var ch = this.
TextWindow
.PeekChar();
2206
this.
TextWindow
.AdvanceChar();
2209
this.AddTrivia(SyntaxFactory.ConflictMarker(
TextWindow
.GetText(false)), ref triviaList);
2230
Debug.Assert(
TextWindow
.PeekChar() == delimiter &&
TextWindow
.PeekChar(1) == '*');
2231
TextWindow
.AdvanceChar(2);
2236
if ((ch =
TextWindow
.PeekChar()) == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
2241
else if (ch == '*' &&
TextWindow
.PeekChar(1) == delimiter)
2243
TextWindow
.AdvanceChar(2);
2249
TextWindow
.AdvanceChar();
2257
while (!SyntaxFacts.IsNewLine(ch =
TextWindow
.PeekChar()) &&
2258
(ch != SlidingTextWindow.InvalidCharacter || !
TextWindow
.IsReallyAtEnd()))
2260
TextWindow
.AdvanceChar();
2271
switch (ch =
TextWindow
.PeekChar())
2274
TextWindow
.AdvanceChar();
2275
return
TextWindow
.TryAdvance('\n') ? SyntaxFactory.CarriageReturnLineFeed : SyntaxFactory.CarriageReturn;
2277
TextWindow
.AdvanceChar();
2282
TextWindow
.AdvanceChar();
2300
char ch =
TextWindow
.PeekChar();
2312
TextWindow
.AdvanceChar();
2329
if (
TextWindow
.Width == 1 && onlySpaces)
2335
var width =
TextWindow
.Width;
2340
TextWindow
.CharacterWindow,
2341
TextWindow
.LexemeRelativeStart,
2345
TextWindow
);
2349
return CreateWhitespaceTrivia(
TextWindow
);
2408
if (SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()))
2442
int lastLineStart =
TextWindow
.Position;
2448
char ch =
TextWindow
.PeekChar();
2452
if (!
TextWindow
.IsReallyAtEnd())
2458
return
TextWindow
.Width > 0 ? SyntaxFactory.DisabledText(
TextWindow
.GetText(false)) : null;
2462
if (lastLineStart <
TextWindow
.Position && !allWhitespace)
2467
TextWindow
.Reset(lastLineStart); // reset so directive parser can consume the starting whitespace on this line
2468
return
TextWindow
.Width > 0 ? SyntaxFactory.DisabledText(
TextWindow
.GetText(false)) : null;
2472
lastLineStart =
TextWindow
.Position;
2483
TextWindow
.AdvanceChar();
2515
var ch = this.
TextWindow
.PeekChar();
2521
else if (ch is SlidingTextWindow.InvalidCharacter && this.
TextWindow
.IsReallyAtEnd())
2529
this.
TextWindow
.AdvanceChar();
2574
switch (character =
TextWindow
.PeekChar())
2577
if (!
TextWindow
.IsReallyAtEnd())
2592
TextWindow
.AdvanceChar();
2597
TextWindow
.AdvanceChar();
2602
TextWindow
.AdvanceChar();
2607
TextWindow
.AdvanceChar();
2612
TextWindow
.AdvanceChar();
2617
TextWindow
.AdvanceChar();
2622
TextWindow
.AdvanceChar();
2623
if (
TextWindow
.PeekChar() == '=')
2625
TextWindow
.AdvanceChar();
2636
TextWindow
.AdvanceChar();
2637
if (
TextWindow
.PeekChar() == '=')
2639
TextWindow
.AdvanceChar();
2650
if (
TextWindow
.PeekChar(1) == '&')
2652
TextWindow
.AdvanceChar(2);
2660
if (
TextWindow
.PeekChar(1) == '|')
2662
TextWindow
.AdvanceChar(2);
2681
info.Text =
TextWindow
.GetText(true);
2725
TextWindow
.AdvanceChar();
2729
info.Text =
TextWindow
.GetText(true);
2744
var pos =
TextWindow
.Position;
2759
TextWindow
.Reset(pos);
2776
char ch =
TextWindow
.PeekChar();
2780
if (
TextWindow
.PeekChar(1) == '/')
2784
var text =
TextWindow
.GetText(false);
2830
Debug.Assert(this.LocationIs(XmlDocCommentLocation.End) ||
TextWindow
.PeekChar() == SlidingTextWindow.InvalidCharacter);
2839
this.AddError(
TextWindow
.LexemeStartPosition,
TextWindow
.Width, ErrorCode.ERR_OpenEndedComment);
2875
switch (ch =
TextWindow
.PeekChar())
2892
if (!
TextWindow
.IsReallyAtEnd())
2918
info.StringValue = info.Text =
TextWindow
.GetText(intern: false);
2925
Debug.Assert(
TextWindow
.PeekChar() == '<');
2927
if (
TextWindow
.PeekChar(1) == '!')
2929
if (
TextWindow
.PeekChar(2) == '-'
2930
&&
TextWindow
.PeekChar(3) == '-')
2932
TextWindow
.AdvanceChar(4);
2935
else if (
TextWindow
.PeekChar(2) == '['
2936
&&
TextWindow
.PeekChar(3) == 'C'
2937
&&
TextWindow
.PeekChar(4) == 'D'
2938
&&
TextWindow
.PeekChar(5) == 'A'
2939
&&
TextWindow
.PeekChar(6) == 'T'
2940
&&
TextWindow
.PeekChar(7) == 'A'
2941
&&
TextWindow
.PeekChar(8) == '[')
2943
TextWindow
.AdvanceChar(9);
2949
TextWindow
.AdvanceChar();
2953
else if (
TextWindow
.PeekChar(1) == '/')
2955
TextWindow
.AdvanceChar(2);
2958
else if (
TextWindow
.PeekChar(1) == '?')
2960
TextWindow
.AdvanceChar(2);
2965
TextWindow
.AdvanceChar();
2974
Debug.Assert(
TextWindow
.PeekChar() == '&');
2975
TextWindow
.AdvanceChar();
2981
if (IsXmlNameStartChar(ch =
TextWindow
.PeekChar()))
2983
while (IsXmlNameChar(ch =
TextWindow
.PeekChar()))
2991
TextWindow
.AdvanceChar();
3020
TextWindow
.AdvanceChar();
3021
bool isHex =
TextWindow
.PeekChar() == 'x';
3026
TextWindow
.AdvanceChar(); // x
3027
while (SyntaxFacts.IsHexDigit(ch =
TextWindow
.PeekChar()))
3029
TextWindow
.AdvanceChar();
3040
while (SyntaxFacts.IsDecDigit(ch =
TextWindow
.PeekChar()))
3042
TextWindow
.AdvanceChar();
3052
if (
TextWindow
.PeekChar() != ';')
3097
ch =
TextWindow
.PeekChar();
3100
TextWindow
.AdvanceChar();
3114
info.Text =
TextWindow
.GetText(true);
3142
if (
TextWindow
.PeekChar() == ']' &&
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3144
TextWindow
.AdvanceChar(3);
3145
info.StringValue = info.Text =
TextWindow
.GetText(false);
3152
var ch =
TextWindow
.PeekChar();
3156
if (!
TextWindow
.IsReallyAtEnd())
3161
info.StringValue = info.Text =
TextWindow
.GetText(false);
3167
info.StringValue = info.Text =
TextWindow
.GetText(false);
3171
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3174
info.StringValue = info.Text =
TextWindow
.GetText(false);
3181
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3183
info.StringValue = info.Text =
TextWindow
.GetText(false);
3195
TextWindow
.AdvanceChar();
3242
switch (ch =
TextWindow
.PeekChar())
3249
TextWindow
.AdvanceChar();
3254
if (
TextWindow
.PeekChar(1) == '>')
3256
TextWindow
.AdvanceChar(2);
3264
TextWindow
.AdvanceChar();
3269
TextWindow
.AdvanceChar();
3274
TextWindow
.AdvanceChar();
3279
TextWindow
.AdvanceChar();
3289
if (!
TextWindow
.IsReallyAtEnd())
3298
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3321
TextWindow
.AdvanceChar();
3323
info.StringValue = info.Text =
TextWindow
.GetText(false);
3335
int start =
TextWindow
.Position;
3339
char ch =
TextWindow
.PeekChar();
3351
TextWindow
.AdvanceChar();
3359
info.Text =
TextWindow
.GetText(start,
TextWindow
.Position - start, intern: true);
3416
switch (ch =
TextWindow
.PeekChar())
3421
TextWindow
.AdvanceChar();
3431
TextWindow
.AdvanceChar();
3444
TextWindow
.AdvanceChar();
3454
if (!
TextWindow
.IsReallyAtEnd())
3481
var ch =
TextWindow
.PeekChar();
3487
info.StringValue = info.Text =
TextWindow
.GetText(false);
3496
info.StringValue = info.Text =
TextWindow
.GetText(false);
3506
info.StringValue = info.Text =
TextWindow
.GetText(false);
3510
if (!
TextWindow
.IsReallyAtEnd())
3515
info.StringValue = info.Text =
TextWindow
.GetText(false);
3519
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3522
info.StringValue = info.Text =
TextWindow
.GetText(false);
3534
TextWindow
.AdvanceChar();
3573
switch (
TextWindow
.PeekChar())
3580
if (!
TextWindow
.IsReallyAtEnd())
3588
info.Text = info.StringValue =
TextWindow
.NextChar().ToString();
3633
int beforeConsumed =
TextWindow
.Position;
3634
char consumedChar =
TextWindow
.NextChar();
3660
info.Text =
TextWindow
.GetText(intern: false);
3665
if (!
TextWindow
.IsReallyAtEnd())
3675
TextWindow
.Reset(beforeConsumed);
3680
TextWindow
.Reset(beforeConsumed);
3683
TextWindow
.Reset(beforeConsumed);
3709
Debug.Assert(
TextWindow
.Position > beforeConsumed, "First character or entity has been consumed.");
3739
if (
TextWindow
.PeekChar() == '.')
3824
string actualText =
TextWindow
.GetText(intern: false);
3837
TextWindow
.Reset(beforeConsumed);
3870
if (
TextWindow
.PeekChar() == '@')
3872
TextWindow
.NextChar();
3873
info.Text =
TextWindow
.GetText(intern: true);
3883
else if (
TextWindow
.PeekChar() == '&')
3892
char bad =
TextWindow
.NextChar();
3893
info.Text =
TextWindow
.GetText(intern: false);
3921
char peekCh =
TextWindow
.PeekChar();
3926
TextWindow
.AdvanceChar();
3932
int pos =
TextWindow
.Position;
3942
TextWindow
.Reset(pos);
4039
switch (ch =
TextWindow
.PeekChar())
4042
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4044
TextWindow
.AdvanceChar(3);
4057
if (!
TextWindow
.IsReallyAtEnd())
4083
var ch =
TextWindow
.PeekChar();
4087
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4089
info.StringValue = info.Text =
TextWindow
.GetText(false);
4097
info.StringValue = info.Text =
TextWindow
.GetText(false);
4101
if (!
TextWindow
.IsReallyAtEnd())
4106
info.StringValue = info.Text =
TextWindow
.GetText(false);
4110
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4113
info.StringValue = info.Text =
TextWindow
.GetText(false);
4125
TextWindow
.AdvanceChar();
4161
switch (ch =
TextWindow
.PeekChar())
4164
if (
TextWindow
.PeekChar(1) == '-')
4166
if (
TextWindow
.PeekChar(2) == '>')
4168
TextWindow
.AdvanceChar(3);
4174
TextWindow
.AdvanceChar(2);
4188
if (!
TextWindow
.IsReallyAtEnd())
4213
var ch =
TextWindow
.PeekChar();
4217
if (
TextWindow
.PeekChar(1) == '-')
4219
info.StringValue = info.Text =
TextWindow
.GetText(false);
4227
info.StringValue = info.Text =
TextWindow
.GetText(false);
4231
if (!
TextWindow
.IsReallyAtEnd())
4236
info.StringValue = info.Text =
TextWindow
.GetText(false);
4240
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4243
info.StringValue = info.Text =
TextWindow
.GetText(false);
4255
TextWindow
.AdvanceChar();
4292
switch (ch =
TextWindow
.PeekChar())
4295
if (
TextWindow
.PeekChar(1) == '>')
4297
TextWindow
.AdvanceChar(2);
4310
if (!
TextWindow
.IsReallyAtEnd())
4337
var ch =
TextWindow
.PeekChar();
4341
if (
TextWindow
.PeekChar(1) == '>')
4343
info.StringValue = info.Text =
TextWindow
.GetText(false);
4351
info.StringValue = info.Text =
TextWindow
.GetText(false);
4355
if (!
TextWindow
.IsReallyAtEnd())
4360
info.StringValue = info.Text =
TextWindow
.GetText(false);
4364
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4367
info.StringValue = info.Text =
TextWindow
.GetText(false);
4379
TextWindow
.AdvanceChar();
4391
var start =
TextWindow
.Position;
4400
if (
TextWindow
.PeekChar() == '/'
4401
&&
TextWindow
.PeekChar(1) == '*'
4402
&&
TextWindow
.PeekChar(2) == '*'
4403
&&
TextWindow
.PeekChar(3) != '*')
4405
TextWindow
.AdvanceChar(3);
4406
var text =
TextWindow
.GetText(true);
4421
char ch =
TextWindow
.PeekChar();
4428
TextWindow
.AdvanceChar();
4432
if (this.StyleIs(XmlDocCommentStyle.SingleLine) &&
TextWindow
.PeekChar(1) == '/' &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
4434
TextWindow
.AdvanceChar(3);
4435
var text =
TextWindow
.GetText(true);
4446
while (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) != '/')
4448
TextWindow
.AdvanceChar();
4451
var text =
TextWindow
.GetText(true);
4461
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4463
TextWindow
.AdvanceChar(2);
4490
TextWindow
.Reset(start);
4497
var text =
TextWindow
.GetText(true);
4509
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4511
TextWindow
.AdvanceChar(2);
4512
var text =
TextWindow
.GetText(true);
4525
char ch =
TextWindow
.PeekChar();
4547
char ch =
TextWindow
.PeekChar();
4566
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4592
if (
TextWindow
.PeekChar() == '\\')
4594
var ch2 =
TextWindow
.PeekChar(1);
4613
return
TextWindow
.PeekChar();
4619
int position =
TextWindow
.Position;
4625
TextWindow
.Reset(position);
4631
var ch =
TextWindow
.PeekChar();
4635
var ch2 =
TextWindow
.PeekChar(1);
4644
TextWindow
.AdvanceChar();
4658
int start =
TextWindow
.Position;
4659
char character =
TextWindow
.PeekChar();
4661
TextWindow
.AdvanceChar();
4663
character =
TextWindow
.PeekChar();
4668
TextWindow
.AdvanceChar();
4669
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4680
character =
TextWindow
.PeekChar();
4692
TextWindow
.AdvanceChar();
4713
TextWindow
.AdvanceChar();
4714
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4725
char ch2 =
TextWindow
.PeekChar();
4740
TextWindow
.AdvanceChar();
4764
Debug.Assert(
TextWindow
.PeekChar() == '&');
4767
TextWindow
.AdvanceChar();
4771
switch (
TextWindow
.PeekChar())
4774
if (
TextWindow
.AdvanceIfMatches("lt;"))
4781
if (
TextWindow
.AdvanceIfMatches("gt;"))
4788
if (
TextWindow
.AdvanceIfMatches("amp;"))
4793
else if (
TextWindow
.AdvanceIfMatches("apos;"))
4800
if (
TextWindow
.AdvanceIfMatches("quot;"))
4808
TextWindow
.AdvanceChar(); //#
4812
if (
TextWindow
.AdvanceIfMatches("x"))
4815
while (SyntaxFacts.IsHexDigit(digit =
TextWindow
.PeekChar()))
4817
TextWindow
.AdvanceChar();
4833
while (SyntaxFacts.IsDecDigit(digit =
TextWindow
.PeekChar()))
4835
TextWindow
.AdvanceChar();
4849
if (
TextWindow
.AdvanceIfMatches(";"))
4864
return new SyntaxDiagnosticInfo(start -
TextWindow
.LexemeStartPosition,
4865
TextWindow
.Position - start,
Parser\Lexer_RawStringLiteral.cs (45)
19
var start =
TextWindow
.Position;
20
while (
TextWindow
.PeekChar() == ch)
21
TextWindow
.AdvanceChar();
23
return
TextWindow
.Position - start;
45
var ch =
TextWindow
.PeekChar();
50
TextWindow
.AdvanceChar();
55
=> currentChar == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd();
68
if (SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()))
90
var afterStartDelimiter =
TextWindow
.LexemeStartPosition + startingQuoteCount;
91
var valueLength =
TextWindow
.Position - afterStartDelimiter;
93
info.StringValue =
TextWindow
.GetText(
123
info.Text =
TextWindow
.GetText(intern: true);
132
var currentChar =
TextWindow
.PeekChar();
137
this.AddError(
TextWindow
.Position, width:
TextWindow
.GetNewLineWidth(), ErrorCode.ERR_UnterminatedRawString);
142
this.AddError(
TextWindow
.Position, width: 0, ErrorCode.ERR_UnterminatedRawString);
149
TextWindow
.AdvanceChar();
153
var beforeEndDelimiter =
TextWindow
.Position;
166
position:
TextWindow
.Position - excessQuoteCount,
172
var afterStartDelimiter =
TextWindow
.LexemeStartPosition + startingQuoteCount;
175
info.StringValue =
TextWindow
.GetText(
196
var afterStartDelimiter =
TextWindow
.Position;
197
Debug.Assert(SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()));
211
position:
TextWindow
.Position - startingQuoteCount,
222
var tokenEnd =
TextWindow
.Position;
223
TextWindow
.Reset(afterStartDelimiter);
224
Debug.Assert(SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()));
238
info.StringValue = this.HasErrors ? "" :
TextWindow
.Intern(_builder);
242
TextWindow
.Reset(tokenEnd);
254
TextWindow
.AdvancePastNewLine();
269
position:
TextWindow
.Position - excessQuoteCount,
282
var currentChar =
TextWindow
.PeekChar();
285
this.AddError(
TextWindow
.Position, width: 0, ErrorCode.ERR_UnterminatedRawString);
299
position:
TextWindow
.Position - currentQuoteCount,
307
TextWindow
.AdvanceChar();
317
Debug.Assert(SyntaxFacts.IsNewLine(
TextWindow
.PeekChar()));
319
var newLineWidth =
TextWindow
.GetNewLineWidth();
324
_builder.Append(
TextWindow
.PeekChar());
326
TextWindow
.AdvanceChar();
329
var lineStartPosition =
TextWindow
.Position;
341
var isBlankLine = SyntaxFacts.IsNewLine(
TextWindow
.PeekChar());
352
width:
TextWindow
.Position - lineStartPosition,
360
width:
TextWindow
.Position - lineStartPosition,
380
var currentChar =
TextWindow
.PeekChar();
386
TextWindow
.AdvanceChar();
Parser\Lexer_StringLiteral.cs (119)
16
var quoteCharacter =
TextWindow
.PeekChar();
19
if (
TextWindow
.PeekChar() == '"' &&
20
TextWindow
.PeekChar(1) == '"' &&
21
TextWindow
.PeekChar(2) == '"')
35
TextWindow
.AdvanceChar();
40
char ch =
TextWindow
.PeekChar();
54
TextWindow
.AdvanceChar();
58
(ch == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd()))
63
Debug.Assert(
TextWindow
.Width > 0);
69
TextWindow
.AdvanceChar();
76
info.Text =
TextWindow
.GetText(intern: true);
85
info.StringValue =
TextWindow
.Intern(_builder);
105
info.Text =
TextWindow
.GetText(intern: true);
109
info.StringValue =
TextWindow
.Intern(_builder);
120
if (
TextWindow
.PeekChar() is ('u' or 'U') &&
TextWindow
.PeekChar(1) == '8')
122
TextWindow
.AdvanceChar(2);
131
var start =
TextWindow
.Position;
133
char ch =
TextWindow
.NextChar();
136
ch =
TextWindow
.NextChar();
157
this.AddError(start,
TextWindow
.Position - start, info.Code, info.Arguments);
179
TextWindow
.Reset(start);
185
this.AddError(start,
TextWindow
.Position - start, ErrorCode.ERR_IllegalEscape);
194
Debug.Assert(
TextWindow
.PeekChar() == '@');
197
var start =
TextWindow
.Position;
198
while (
TextWindow
.PeekChar() == '@')
200
TextWindow
.AdvanceChar();
203
if (
TextWindow
.Position - start >= 2)
205
this.AddError(start, width:
TextWindow
.Position - start, ErrorCode.ERR_IllegalAtSequence);
208
Debug.Assert(
TextWindow
.PeekChar() == '"');
209
TextWindow
.AdvanceChar();
213
var ch =
TextWindow
.PeekChar();
216
TextWindow
.AdvanceChar();
217
if (
TextWindow
.PeekChar() == '"')
220
TextWindow
.AdvanceChar();
229
if (ch == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
237
TextWindow
.AdvanceChar();
250
info.Text =
TextWindow
.GetText(intern: false);
293
info.Text =
TextWindow
.GetText(intern: false);
361
char ch = _lexer.
TextWindow
.PeekChar();
364
(ch == SlidingTextWindow.InvalidCharacter && _lexer.
TextWindow
.IsReallyAtEnd());
381
var start = _lexer.
TextWindow
.Position;
383
Debug.Assert(_lexer.
TextWindow
.Position != start);
385
openQuoteRange = start.._lexer.
TextWindow
.Position;
391
closeQuoteRange = _lexer.
TextWindow
.Position.._lexer.
TextWindow
.Position;
414
var window = _lexer.
TextWindow
;
510
var closeQuotePosition = _lexer.
TextWindow
.Position;
524
closeQuoteRange = closeQuotePosition.._lexer.
TextWindow
.Position;
531
if (_lexer.
TextWindow
.PeekChar() != '"')
538
IsAtEnd(allowNewline: true) ? _lexer.
TextWindow
.Position - 1 : _lexer.
TextWindow
.Position,
544
_lexer.
TextWindow
.AdvanceChar(); // "
554
if (_lexer.
TextWindow
.PeekChar() != '"')
561
IsAtEnd(allowNewline: true) ? _lexer.
TextWindow
.Position - 1 : _lexer.
TextWindow
.Position,
579
position: _lexer.
TextWindow
.Position - excessQuoteCount,
596
_lexer.
TextWindow
.Position - 1, width: 1, ErrorCode.ERR_UnterminatedRawString));
598
else if (_lexer.
TextWindow
.PeekChar() == '"')
607
position: _lexer.
TextWindow
.Position - closeQuoteCount,
613
_lexer.
TextWindow
.AdvancePastNewLine();
626
position: _lexer.
TextWindow
.Position - excessQuoteCount,
658
switch (_lexer.
TextWindow
.PeekChar())
678
var escapeStart = _lexer.
TextWindow
.Position;
682
TrySetError(_lexer.MakeError(escapeStart, _lexer.
TextWindow
.Position - escapeStart, ErrorCode.ERR_EscapedCurly, ch));
687
_lexer.
TextWindow
.AdvanceChar();
694
_lexer.
TextWindow
.AdvanceChar();
705
var beforeQuotesPosition = _lexer.
TextWindow
.Position;
713
_lexer.
TextWindow
.Position - closeQuoteCount, closeQuoteCount, ErrorCode.ERR_RawStringMustContainContent));
714
_lexer.
TextWindow
.Reset(beforeQuotesPosition);
728
var startPosition = _lexer.
TextWindow
.Position;
729
if (SyntaxFacts.IsNewLine(_lexer.
TextWindow
.PeekChar()))
731
_lexer.
TextWindow
.AdvancePastNewLine();
735
_lexer.
TextWindow
.Reset(startPosition);
771
if (_lexer.
TextWindow
.PeekChar(1) != '"')
777
_lexer.
TextWindow
.AdvanceChar(2); // ""
783
var beforeQuotePosition = _lexer.
TextWindow
.Position;
790
_lexer.
TextWindow
.Reset(beforeQuotePosition);
803
var pos = _lexer.
TextWindow
.Position;
804
_lexer.
TextWindow
.AdvanceChar(); // }
807
if (_lexer.
TextWindow
.PeekChar() == '}')
809
_lexer.
TextWindow
.AdvanceChar(); // }
829
position: _lexer.
TextWindow
.Position - closeBraceCount,
851
if (_lexer.
TextWindow
.PeekChar(1) == '{')
853
_lexer.
TextWindow
.AdvanceChar(2); // {{
857
int openBracePosition = _lexer.
TextWindow
.Position;
858
_lexer.
TextWindow
.AdvanceChar();
860
int closeBracePosition = _lexer.
TextWindow
.Position;
861
if (_lexer.
TextWindow
.PeekChar() == '}')
863
_lexer.
TextWindow
.AdvanceChar();
873
new Range(closeBracePosition, _lexer.
TextWindow
.Position)));
886
var beforeOpenBracesPosition = _lexer.
TextWindow
.Position;
894
var afterOpenBracePosition = _lexer.
TextWindow
.Position;
908
var beforeCloseBracePosition = _lexer.
TextWindow
.Position;
931
_lexer.
TextWindow
.Reset(beforeCloseBracePosition + startingDollarSignCount);
937
beforeCloseBracePosition.._lexer.
TextWindow
.Position));
953
Debug.Assert(_lexer.
TextWindow
.PeekChar() == ':');
954
_lexer.
TextWindow
.AdvanceChar();
957
char ch = _lexer.
TextWindow
.PeekChar();
961
var pos = _lexer.
TextWindow
.Position;
970
if (kind is InterpolatedStringKind.Verbatim && _lexer.
TextWindow
.PeekChar(1) == '"')
972
_lexer.
TextWindow
.AdvanceChar(2); // ""
982
_lexer.
TextWindow
.Position, 1, ErrorCode.ERR_UnexpectedCharacter, ch));
983
_lexer.
TextWindow
.AdvanceChar();
995
_lexer.
TextWindow
.AdvanceChar();
1008
char ch = _lexer.
TextWindow
.PeekChar();
1022
TrySetError(_lexer.MakeError(_lexer.
TextWindow
.Position, 1, ErrorCode.ERR_SyntaxError, endingChar.ToString()));
1023
_lexer.
TextWindow
.AdvanceChar();
1040
colonRange = new Range(_lexer.
TextWindow
.Position, _lexer.
TextWindow
.Position + 1);
1054
TrySetError(_lexer.MakeError(_lexer.
TextWindow
.Position, 1, ErrorCode.ERR_SyntaxError, endingChar.ToString()));
1080
if (_lexer.
TextWindow
.PeekChar(1) == '*')
1092
switch (_lexer.
TextWindow
.PeekChar(1))
1101
_lexer.
TextWindow
.AdvanceChar();
1118
_lexer.
TextWindow
.AdvanceChar();
1139
Debug.Assert(start == _lexer.
TextWindow
.PeekChar());
1140
_lexer.
TextWindow
.AdvanceChar();
1142
if (_lexer.
TextWindow
.PeekChar() == end)
1144
_lexer.
TextWindow
.AdvanceChar();
Parser\QuickScanner.cs (13)
196
int i =
TextWindow
.Offset;
197
int n =
TextWindow
.CharacterWindowCount;
203
var charWindow =
TextWindow
.CharacterWindow;
231
TextWindow
.AdvanceChar(i -
TextWindow
.Offset);
238
TextWindow
.CharacterWindow,
239
TextWindow
.LexemeRelativeStart,
240
i -
TextWindow
.LexemeRelativeStart,
248
TextWindow
.Reset(
TextWindow
.LexemeStartPosition);
256
var quickWidth = lexer.
TextWindow
.Width;
258
lexer.
TextWindow
.Reset(lexer.
TextWindow
.LexemeStartPosition);
Parser\SyntaxParser.cs (1)
141
var size = Math.Min(CachedTokenArraySize, this.lexer.
TextWindow
.Text.Length / 2);
Syntax\SyntaxTokenParser.cs (5)
54
var startingPosition = _lexer.
TextWindow
.Position;
68
var startingPosition = _lexer.
TextWindow
.Position;
83
var startingPosition = _lexer.
TextWindow
.Position;
96
if (position < _lexer.
TextWindow
.Position)
99
_lexer.
TextWindow
.Reset(position);