1 write to TextWindow
Microsoft.CodeAnalysis.CSharp (1)
Parser\AbstractLexer.cs (1)
21
this.
TextWindow
= new SlidingTextWindow(text);
664 references to TextWindow
Microsoft.CodeAnalysis.CSharp (664)
Parser\AbstractLexer.cs (4)
26
this.
TextWindow
.Dispose();
31
TextWindow
.Start();
134
return position >=
TextWindow
.LexemeStartPosition ? position -
TextWindow
.LexemeStartPosition : position;
Parser\Blender.cs (1)
72
_newPosition = lexer.
TextWindow
.Position;
Parser\Blender.Reader.cs (1)
168
if (_lexer.
TextWindow
.Position != _newPosition)
Parser\DirectiveParser.cs (1)
37
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 (472)
164
this.
TextWindow
.Reset(position);
306
this.LexSyntaxTrivia(afterFirstToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
325
this.LexSyntaxTrivia(afterFirstToken:
TextWindow
.Position > 0, isTrailing: false, triviaList: ref _leadingTriviaCache);
445
int startingPosition =
TextWindow
.Position;
448
character =
TextWindow
.PeekChar();
457
TextWindow
.AdvanceChar();
458
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.SlashEqualsToken : SyntaxKind.SlashToken;
464
TextWindow
.AdvanceChar();
465
if (
TextWindow
.TryAdvance('.'))
467
if (
TextWindow
.PeekChar() == '.')
485
TextWindow
.AdvanceChar();
490
TextWindow
.AdvanceChar();
491
info.Kind =
TextWindow
.TryAdvance(':') ? SyntaxKind.ColonColonToken : SyntaxKind.ColonToken;
495
TextWindow
.AdvanceChar();
500
TextWindow
.AdvanceChar();
505
TextWindow
.AdvanceChar();
506
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.ExclamationEqualsToken : SyntaxKind.ExclamationToken;
510
TextWindow
.AdvanceChar();
512
TextWindow
.TryAdvance('=') ? SyntaxKind.EqualsEqualsToken :
513
TextWindow
.TryAdvance('>') ? SyntaxKind.EqualsGreaterThanToken : SyntaxKind.EqualsToken;
517
TextWindow
.AdvanceChar();
518
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.AsteriskEqualsToken : SyntaxKind.AsteriskToken;
522
TextWindow
.AdvanceChar();
527
TextWindow
.AdvanceChar();
532
TextWindow
.AdvanceChar();
537
TextWindow
.AdvanceChar();
542
TextWindow
.AdvanceChar();
547
TextWindow
.AdvanceChar();
552
TextWindow
.AdvanceChar();
553
info.Kind =
TextWindow
.TryAdvance('?')
554
?
TextWindow
.TryAdvance('=') ? SyntaxKind.QuestionQuestionEqualsToken : SyntaxKind.QuestionQuestionToken
559
TextWindow
.AdvanceChar();
561
TextWindow
.TryAdvance('=') ? SyntaxKind.PlusEqualsToken :
562
TextWindow
.TryAdvance('+') ? SyntaxKind.PlusPlusToken : SyntaxKind.PlusToken;
566
TextWindow
.AdvanceChar();
568
TextWindow
.TryAdvance('=') ? SyntaxKind.MinusEqualsToken :
569
TextWindow
.TryAdvance('-') ? SyntaxKind.MinusMinusToken :
570
TextWindow
.TryAdvance('>') ? SyntaxKind.MinusGreaterThanToken : SyntaxKind.MinusToken;
574
TextWindow
.AdvanceChar();
575
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.PercentEqualsToken : SyntaxKind.PercentToken;
579
TextWindow
.AdvanceChar();
581
TextWindow
.TryAdvance('=') ? SyntaxKind.AmpersandEqualsToken :
582
TextWindow
.TryAdvance('&') ? SyntaxKind.AmpersandAmpersandToken : SyntaxKind.AmpersandToken;
586
TextWindow
.AdvanceChar();
587
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.CaretEqualsToken : SyntaxKind.CaretToken;
591
TextWindow
.AdvanceChar();
593
TextWindow
.TryAdvance('=') ? SyntaxKind.BarEqualsToken :
594
TextWindow
.TryAdvance('|') ? SyntaxKind.BarBarToken : SyntaxKind.BarToken;
598
TextWindow
.AdvanceChar();
600
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanEqualsToken :
601
TextWindow
.TryAdvance('<')
602
?
TextWindow
.TryAdvance('=') ? SyntaxKind.LessThanLessThanEqualsToken : SyntaxKind.LessThanLessThanToken
607
TextWindow
.AdvanceChar();
608
info.Kind =
TextWindow
.TryAdvance('=') ? SyntaxKind.GreaterThanEqualsToken : SyntaxKind.GreaterThanToken;
615
Debug.Assert(
TextWindow
.PeekChar() == '@');
617
if (
TextWindow
.PeekChar(1) == ':')
622
this.AddError(
TextWindow
.Position + 1, width: 1, ErrorCode.ERR_ExpectedVerbatimLiteral);
625
info.Text =
TextWindow
.GetText(false);
630
info.Text =
TextWindow
.GetText(intern: true);
671
if (!
TextWindow
.IsReallyAtEnd())
702
TextWindow
.AdvanceChar();
707
if (char.IsHighSurrogate(character) && char.IsLowSurrogate(
TextWindow
.PeekChar()))
708
TextWindow
.AdvanceChar();
716
info.Text =
TextWindow
.GetText(intern: true);
720
int end =
TextWindow
.Text.Length;
721
info.Text =
TextWindow
.Text.ToString(TextSpan.FromBounds(startingPosition, end));
722
TextWindow
.Reset(end);
739
Debug.Assert(
TextWindow
.PeekChar() == '@');
742
while (
TextWindow
.PeekChar(index) == '@')
747
if (
TextWindow
.PeekChar(index) == '"')
753
else if (
TextWindow
.PeekChar(index) == '$')
765
Debug.Assert(
TextWindow
.PeekChar() == '$');
767
if (
TextWindow
.PeekChar(1) is '$' or '@' or '"')
792
int start =
TextWindow
.Position;
793
while (
TextWindow
.PeekChar() is >= '0' and <= '9')
795
TextWindow
.AdvanceChar();
798
return start <
TextWindow
.Position;
804
if (
TextWindow
.PeekChar() == '_')
819
char ch =
TextWindow
.PeekChar();
836
TextWindow
.AdvanceChar();
847
int start =
TextWindow
.Position;
862
ch =
TextWindow
.PeekChar();
865
ch =
TextWindow
.PeekChar(1);
868
TextWindow
.AdvanceChar(2);
874
TextWindow
.AdvanceChar(2);
885
if (
TextWindow
.PeekChar() is 'L' or 'l')
887
TextWindow
.AdvanceChar();
889
if (
TextWindow
.PeekChar() is 'u' or 'U')
891
TextWindow
.AdvanceChar();
895
else if (
TextWindow
.PeekChar() is 'u' or 'U')
897
TextWindow
.AdvanceChar();
899
if (
TextWindow
.PeekChar() is 'L' or 'l')
901
TextWindow
.AdvanceChar();
910
if (this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar() == '#')
913
TextWindow
.AdvanceChar();
914
info.StringValue = info.Text =
TextWindow
.GetText(intern: true);
920
if ((ch =
TextWindow
.PeekChar()) == '.')
922
var ch2 =
TextWindow
.PeekChar(1);
927
TextWindow
.AdvanceChar();
934
TextWindow
.Reset(start);
939
if ((ch =
TextWindow
.PeekChar()) is 'E' or 'e')
942
TextWindow
.AdvanceChar();
944
if ((ch =
TextWindow
.PeekChar()) is '-' or '+')
947
TextWindow
.AdvanceChar();
950
if (!(((ch =
TextWindow
.PeekChar()) >= '0' && ch <= '9') || ch == '_'))
963
ch =
TextWindow
.PeekChar();
968
TextWindow
.AdvanceChar();
973
TextWindow
.AdvanceChar();
978
TextWindow
.AdvanceChar();
988
TextWindow
.AdvanceChar();
993
TextWindow
.AdvanceChar();
998
TextWindow
.AdvanceChar();
1003
TextWindow
.AdvanceChar();
1005
if (
TextWindow
.PeekChar() is 'u' or 'U')
1007
TextWindow
.AdvanceChar();
1014
TextWindow
.AdvanceChar();
1015
if (
TextWindow
.PeekChar() is 'L' or 'l')
1017
TextWindow
.AdvanceChar();
1025
this.AddError(MakeError(start,
TextWindow
.Position - start, ErrorCode.ERR_InvalidNumber));
1037
info.Text =
TextWindow
.GetText(true);
1039
var valueText =
TextWindow
.Intern(_builder);
1050
info.DecimalValue = this.GetValueDecimal(valueText, start,
TextWindow
.Position);
1330
var currentOffset =
TextWindow
.Offset;
1331
var characterWindow =
TextWindow
.CharacterWindow;
1332
var characterWindowCount =
TextWindow
.CharacterWindowCount;
1395
TextWindow
.AdvanceChar(length);
1396
info.Text = info.StringValue =
TextWindow
.Intern(characterWindow, startOffset, length);
1428
int start =
TextWindow
.Position;
1431
while (
TextWindow
.PeekChar() == '@')
1433
TextWindow
.AdvanceChar();
1436
var atCount =
TextWindow
.Position - start;
1444
char ch =
TextWindow
.PeekChar();
1467
if (!
TextWindow
.IsReallyAtEnd())
1487
(char.ToLower(
TextWindow
.PeekChar(1)) == 'x'))
1521
if (_identLen == 0 && this.ModeIs(LexerMode.DebuggerSyntax) &&
TextWindow
.PeekChar(1) == '>')
1524
TextWindow
.AdvanceChar(2);
1551
TextWindow
.AdvanceChar();
1575
TextWindow
.AdvanceChar();
1586
var width =
TextWindow
.Width; // exact size of input characters
1589
info.Text =
TextWindow
.GetInternedText();
1598
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1606
var valueText =
TextWindow
.Intern(_identBuffer, objectAddressOffset, _identLen - objectAddressOffset);
1627
TextWindow
.Reset(start);
1643
int start =
TextWindow
.Position;
1662
int beforeConsumed =
TextWindow
.Position;
1666
if (
TextWindow
.PeekChar() == '&')
1671
TextWindow
.Reset(beforeConsumed);
1677
consumedChar =
TextWindow
.NextChar();
1697
if (!isEscaped && (
TextWindow
.Position == beforeConsumed + 1) &&
1698
TextWindow
.PeekChar() is 'u' or 'U')
1704
TextWindow
.Reset(beforeConsumed);
1726
TextWindow
.Reset(beforeConsumed);
1744
TextWindow
.Reset(beforeConsumed);
1747
if (!
TextWindow
.IsReallyAtEnd())
1752
TextWindow
.Reset(beforeConsumed);
1774
TextWindow
.Reset(beforeConsumed);
1795
var width =
TextWindow
.Width; // exact size of input characters
1800
info.StringValue =
TextWindow
.GetInternedText();
1805
info.StringValue =
TextWindow
.Intern(_identBuffer, 0, _identLen);
1806
info.Text =
TextWindow
.GetText(intern: false);
1815
TextWindow
.Reset(start);
1884
char ch =
TextWindow
.PeekChar();
1912
if ((ch =
TextWindow
.PeekChar(1)) == '/')
1914
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
1934
if (!this.SuppressDocumentationCommentParse &&
TextWindow
.PeekChar(2) == '*' &&
1935
TextWindow
.PeekChar(3) != '*' &&
TextWindow
.PeekChar(3) != '/')
1956
if ((ch =
TextWindow
.PeekChar(1)) == '*')
1959
this.AddError(
TextWindow
.Position, width: 1, ErrorCode.ERR_UnexpectedCharacter, '@');
2019
var text =
TextWindow
.GetText(false);
2033
var text =
TextWindow
.GetText(false);
2044
var position =
TextWindow
.Position;
2045
var text =
TextWindow
.Text;
2078
this.AddError(
TextWindow
.Position, s_conflictMarkerLength,
2081
var startCh = this.
TextWindow
.PeekChar();
2107
var ch = this.
TextWindow
.PeekChar();
2126
this.
TextWindow
.AdvanceChar();
2129
if (this.
TextWindow
.Width > 0)
2131
this.AddTrivia(SyntaxFactory.DisabledText(
TextWindow
.GetText(false)), ref triviaList);
2145
while (SyntaxFacts.IsNewLine(this.
TextWindow
.PeekChar()))
2147
this.
TextWindow
.AdvanceChar();
2150
if (this.
TextWindow
.Width > 0)
2152
this.AddTrivia(SyntaxFactory.EndOfLine(
TextWindow
.GetText(false)), ref triviaList);
2160
var ch = this.
TextWindow
.PeekChar();
2166
this.
TextWindow
.AdvanceChar();
2169
this.AddTrivia(SyntaxFactory.ConflictMarker(
TextWindow
.GetText(false)), ref triviaList);
2190
Debug.Assert(
TextWindow
.PeekChar() == delimiter &&
TextWindow
.PeekChar(1) == '*');
2191
TextWindow
.AdvanceChar(2);
2196
if ((ch =
TextWindow
.PeekChar()) == SlidingTextWindow.InvalidCharacter &&
TextWindow
.IsReallyAtEnd())
2201
else if (ch == '*' &&
TextWindow
.PeekChar(1) == delimiter)
2203
TextWindow
.AdvanceChar(2);
2209
TextWindow
.AdvanceChar();
2217
while (!SyntaxFacts.IsNewLine(ch =
TextWindow
.PeekChar()) &&
2218
(ch != SlidingTextWindow.InvalidCharacter || !
TextWindow
.IsReallyAtEnd()))
2220
TextWindow
.AdvanceChar();
2231
switch (ch =
TextWindow
.PeekChar())
2234
TextWindow
.AdvanceChar();
2235
return
TextWindow
.TryAdvance('\n') ? SyntaxFactory.CarriageReturnLineFeed : SyntaxFactory.CarriageReturn;
2237
TextWindow
.AdvanceChar();
2242
TextWindow
.AdvanceChar();
2260
char ch =
TextWindow
.PeekChar();
2272
TextWindow
.AdvanceChar();
2289
if (
TextWindow
.Width == 1 && onlySpaces)
2295
var width =
TextWindow
.Width;
2300
TextWindow
.CharacterWindow,
2301
TextWindow
.LexemeRelativeStart,
2305
TextWindow
);
2309
return CreateWhitespaceTrivia(
TextWindow
);
2370
if (SyntaxFacts.IsWhitespace(
TextWindow
.PeekChar()))
2395
int lastLineStart =
TextWindow
.Position;
2401
char ch =
TextWindow
.PeekChar();
2405
if (!
TextWindow
.IsReallyAtEnd())
2411
return
TextWindow
.Width > 0 ? SyntaxFactory.DisabledText(
TextWindow
.GetText(false)) : null;
2415
if (lastLineStart <
TextWindow
.Position && !allWhitespace)
2420
TextWindow
.Reset(lastLineStart); // reset so directive parser can consume the starting whitespace on this line
2421
return
TextWindow
.Width > 0 ? SyntaxFactory.DisabledText(
TextWindow
.GetText(false)) : null;
2425
lastLineStart =
TextWindow
.Position;
2436
TextWindow
.AdvanceChar();
2468
var ch = this.
TextWindow
.PeekChar();
2474
else if (ch is SlidingTextWindow.InvalidCharacter && this.
TextWindow
.IsReallyAtEnd())
2482
this.
TextWindow
.AdvanceChar();
2509
switch (character =
TextWindow
.PeekChar())
2512
if (!
TextWindow
.IsReallyAtEnd())
2527
TextWindow
.AdvanceChar();
2532
TextWindow
.AdvanceChar();
2537
TextWindow
.AdvanceChar();
2542
TextWindow
.AdvanceChar();
2547
TextWindow
.AdvanceChar();
2552
TextWindow
.AdvanceChar();
2553
if (
TextWindow
.PeekChar() == '=')
2555
TextWindow
.AdvanceChar();
2566
TextWindow
.AdvanceChar();
2567
if (
TextWindow
.PeekChar() == '=')
2569
TextWindow
.AdvanceChar();
2580
if (
TextWindow
.PeekChar(1) == '&')
2582
TextWindow
.AdvanceChar(2);
2590
if (
TextWindow
.PeekChar(1) == '|')
2592
TextWindow
.AdvanceChar(2);
2611
info.Text =
TextWindow
.GetText(true);
2655
TextWindow
.AdvanceChar();
2659
info.Text =
TextWindow
.GetText(true);
2674
var pos =
TextWindow
.Position;
2689
TextWindow
.Reset(pos);
2706
char ch =
TextWindow
.PeekChar();
2710
if (
TextWindow
.PeekChar(1) == '/')
2714
var text =
TextWindow
.GetText(false);
2760
Debug.Assert(this.LocationIs(XmlDocCommentLocation.End) ||
TextWindow
.PeekChar() == SlidingTextWindow.InvalidCharacter);
2769
this.AddError(
TextWindow
.LexemeStartPosition,
TextWindow
.Width, ErrorCode.ERR_OpenEndedComment);
2805
switch (ch =
TextWindow
.PeekChar())
2822
if (!
TextWindow
.IsReallyAtEnd())
2848
info.StringValue = info.Text =
TextWindow
.GetText(intern: false);
2855
Debug.Assert(
TextWindow
.PeekChar() == '<');
2857
if (
TextWindow
.PeekChar(1) == '!')
2859
if (
TextWindow
.PeekChar(2) == '-'
2860
&&
TextWindow
.PeekChar(3) == '-')
2862
TextWindow
.AdvanceChar(4);
2865
else if (
TextWindow
.PeekChar(2) == '['
2866
&&
TextWindow
.PeekChar(3) == 'C'
2867
&&
TextWindow
.PeekChar(4) == 'D'
2868
&&
TextWindow
.PeekChar(5) == 'A'
2869
&&
TextWindow
.PeekChar(6) == 'T'
2870
&&
TextWindow
.PeekChar(7) == 'A'
2871
&&
TextWindow
.PeekChar(8) == '[')
2873
TextWindow
.AdvanceChar(9);
2879
TextWindow
.AdvanceChar();
2883
else if (
TextWindow
.PeekChar(1) == '/')
2885
TextWindow
.AdvanceChar(2);
2888
else if (
TextWindow
.PeekChar(1) == '?')
2890
TextWindow
.AdvanceChar(2);
2895
TextWindow
.AdvanceChar();
2904
Debug.Assert(
TextWindow
.PeekChar() == '&');
2905
TextWindow
.AdvanceChar();
2911
if (IsXmlNameStartChar(ch =
TextWindow
.PeekChar()))
2913
while (IsXmlNameChar(ch =
TextWindow
.PeekChar()))
2921
TextWindow
.AdvanceChar();
2950
TextWindow
.AdvanceChar();
2951
bool isHex =
TextWindow
.PeekChar() == 'x';
2956
TextWindow
.AdvanceChar(); // x
2957
while (SyntaxFacts.IsHexDigit(ch =
TextWindow
.PeekChar()))
2959
TextWindow
.AdvanceChar();
2970
while (SyntaxFacts.IsDecDigit(ch =
TextWindow
.PeekChar()))
2972
TextWindow
.AdvanceChar();
2982
if (
TextWindow
.PeekChar() != ';')
3027
ch =
TextWindow
.PeekChar();
3030
TextWindow
.AdvanceChar();
3044
info.Text =
TextWindow
.GetText(true);
3072
if (
TextWindow
.PeekChar() == ']' &&
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3074
TextWindow
.AdvanceChar(3);
3075
info.StringValue = info.Text =
TextWindow
.GetText(false);
3082
var ch =
TextWindow
.PeekChar();
3086
if (!
TextWindow
.IsReallyAtEnd())
3091
info.StringValue = info.Text =
TextWindow
.GetText(false);
3097
info.StringValue = info.Text =
TextWindow
.GetText(false);
3101
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3104
info.StringValue = info.Text =
TextWindow
.GetText(false);
3111
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3113
info.StringValue = info.Text =
TextWindow
.GetText(false);
3125
TextWindow
.AdvanceChar();
3172
switch (ch =
TextWindow
.PeekChar())
3179
TextWindow
.AdvanceChar();
3184
if (
TextWindow
.PeekChar(1) == '>')
3186
TextWindow
.AdvanceChar(2);
3194
TextWindow
.AdvanceChar();
3199
TextWindow
.AdvanceChar();
3204
TextWindow
.AdvanceChar();
3209
TextWindow
.AdvanceChar();
3219
if (!
TextWindow
.IsReallyAtEnd())
3228
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3251
TextWindow
.AdvanceChar();
3253
info.StringValue = info.Text =
TextWindow
.GetText(false);
3265
int start =
TextWindow
.Position;
3269
char ch =
TextWindow
.PeekChar();
3281
TextWindow
.AdvanceChar();
3289
info.Text =
TextWindow
.GetText(start,
TextWindow
.Position - start, intern: true);
3346
switch (ch =
TextWindow
.PeekChar())
3351
TextWindow
.AdvanceChar();
3361
TextWindow
.AdvanceChar();
3374
TextWindow
.AdvanceChar();
3384
if (!
TextWindow
.IsReallyAtEnd())
3411
var ch =
TextWindow
.PeekChar();
3417
info.StringValue = info.Text =
TextWindow
.GetText(false);
3426
info.StringValue = info.Text =
TextWindow
.GetText(false);
3436
info.StringValue = info.Text =
TextWindow
.GetText(false);
3440
if (!
TextWindow
.IsReallyAtEnd())
3445
info.StringValue = info.Text =
TextWindow
.GetText(false);
3449
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
3452
info.StringValue = info.Text =
TextWindow
.GetText(false);
3464
TextWindow
.AdvanceChar();
3503
switch (
TextWindow
.PeekChar())
3510
if (!
TextWindow
.IsReallyAtEnd())
3518
info.Text = info.StringValue =
TextWindow
.NextChar().ToString();
3563
int beforeConsumed =
TextWindow
.Position;
3564
char consumedChar =
TextWindow
.NextChar();
3590
info.Text =
TextWindow
.GetText(intern: false);
3595
if (!
TextWindow
.IsReallyAtEnd())
3605
TextWindow
.Reset(beforeConsumed);
3610
TextWindow
.Reset(beforeConsumed);
3613
TextWindow
.Reset(beforeConsumed);
3639
Debug.Assert(
TextWindow
.Position > beforeConsumed, "First character or entity has been consumed.");
3669
if (
TextWindow
.PeekChar() == '.')
3754
string actualText =
TextWindow
.GetText(intern: false);
3767
TextWindow
.Reset(beforeConsumed);
3800
if (
TextWindow
.PeekChar() == '@')
3802
TextWindow
.NextChar();
3803
info.Text =
TextWindow
.GetText(intern: true);
3813
else if (
TextWindow
.PeekChar() == '&')
3822
char bad =
TextWindow
.NextChar();
3823
info.Text =
TextWindow
.GetText(intern: false);
3851
char peekCh =
TextWindow
.PeekChar();
3856
TextWindow
.AdvanceChar();
3862
int pos =
TextWindow
.Position;
3872
TextWindow
.Reset(pos);
3969
switch (ch =
TextWindow
.PeekChar())
3972
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
3974
TextWindow
.AdvanceChar(3);
3987
if (!
TextWindow
.IsReallyAtEnd())
4013
var ch =
TextWindow
.PeekChar();
4017
if (
TextWindow
.PeekChar(1) == ']' &&
TextWindow
.PeekChar(2) == '>')
4019
info.StringValue = info.Text =
TextWindow
.GetText(false);
4027
info.StringValue = info.Text =
TextWindow
.GetText(false);
4031
if (!
TextWindow
.IsReallyAtEnd())
4036
info.StringValue = info.Text =
TextWindow
.GetText(false);
4040
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4043
info.StringValue = info.Text =
TextWindow
.GetText(false);
4055
TextWindow
.AdvanceChar();
4091
switch (ch =
TextWindow
.PeekChar())
4094
if (
TextWindow
.PeekChar(1) == '-')
4096
if (
TextWindow
.PeekChar(2) == '>')
4098
TextWindow
.AdvanceChar(3);
4104
TextWindow
.AdvanceChar(2);
4118
if (!
TextWindow
.IsReallyAtEnd())
4143
var ch =
TextWindow
.PeekChar();
4147
if (
TextWindow
.PeekChar(1) == '-')
4149
info.StringValue = info.Text =
TextWindow
.GetText(false);
4157
info.StringValue = info.Text =
TextWindow
.GetText(false);
4161
if (!
TextWindow
.IsReallyAtEnd())
4166
info.StringValue = info.Text =
TextWindow
.GetText(false);
4170
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4173
info.StringValue = info.Text =
TextWindow
.GetText(false);
4185
TextWindow
.AdvanceChar();
4222
switch (ch =
TextWindow
.PeekChar())
4225
if (
TextWindow
.PeekChar(1) == '>')
4227
TextWindow
.AdvanceChar(2);
4240
if (!
TextWindow
.IsReallyAtEnd())
4267
var ch =
TextWindow
.PeekChar();
4271
if (
TextWindow
.PeekChar(1) == '>')
4273
info.StringValue = info.Text =
TextWindow
.GetText(false);
4281
info.StringValue = info.Text =
TextWindow
.GetText(false);
4285
if (!
TextWindow
.IsReallyAtEnd())
4290
info.StringValue = info.Text =
TextWindow
.GetText(false);
4294
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4297
info.StringValue = info.Text =
TextWindow
.GetText(false);
4309
TextWindow
.AdvanceChar();
4321
var start =
TextWindow
.Position;
4330
if (
TextWindow
.PeekChar() == '/'
4331
&&
TextWindow
.PeekChar(1) == '*'
4332
&&
TextWindow
.PeekChar(2) == '*'
4333
&&
TextWindow
.PeekChar(3) != '*')
4335
TextWindow
.AdvanceChar(3);
4336
var text =
TextWindow
.GetText(true);
4351
char ch =
TextWindow
.PeekChar();
4358
TextWindow
.AdvanceChar();
4362
if (this.StyleIs(XmlDocCommentStyle.SingleLine) &&
TextWindow
.PeekChar(1) == '/' &&
TextWindow
.PeekChar(2) == '/' &&
TextWindow
.PeekChar(3) != '/')
4364
TextWindow
.AdvanceChar(3);
4365
var text =
TextWindow
.GetText(true);
4376
while (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) != '/')
4378
TextWindow
.AdvanceChar();
4381
var text =
TextWindow
.GetText(true);
4391
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4393
TextWindow
.AdvanceChar(2);
4420
TextWindow
.Reset(start);
4427
var text =
TextWindow
.GetText(true);
4439
if (
TextWindow
.PeekChar() == '*' &&
TextWindow
.PeekChar(1) == '/')
4441
TextWindow
.AdvanceChar(2);
4442
var text =
TextWindow
.GetText(true);
4455
char ch =
TextWindow
.PeekChar();
4477
char ch =
TextWindow
.PeekChar();
4496
if (this.StyleIs(XmlDocCommentStyle.Delimited) &&
TextWindow
.PeekChar(1) == '/')
4522
if (
TextWindow
.PeekChar() == '\\')
4524
var ch2 =
TextWindow
.PeekChar(1);
4543
return
TextWindow
.PeekChar();
4549
int position =
TextWindow
.Position;
4555
TextWindow
.Reset(position);
4561
var ch =
TextWindow
.PeekChar();
4565
var ch2 =
TextWindow
.PeekChar(1);
4574
TextWindow
.AdvanceChar();
4588
int start =
TextWindow
.Position;
4589
char character =
TextWindow
.PeekChar();
4591
TextWindow
.AdvanceChar();
4593
character =
TextWindow
.PeekChar();
4598
TextWindow
.AdvanceChar();
4599
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4610
character =
TextWindow
.PeekChar();
4622
TextWindow
.AdvanceChar();
4643
TextWindow
.AdvanceChar();
4644
if (!SyntaxFacts.IsHexDigit(
TextWindow
.PeekChar()))
4655
char ch2 =
TextWindow
.PeekChar();
4670
TextWindow
.AdvanceChar();
4694
Debug.Assert(
TextWindow
.PeekChar() == '&');
4697
TextWindow
.AdvanceChar();
4701
switch (
TextWindow
.PeekChar())
4704
if (
TextWindow
.AdvanceIfMatches("lt;"))
4711
if (
TextWindow
.AdvanceIfMatches("gt;"))
4718
if (
TextWindow
.AdvanceIfMatches("amp;"))
4723
else if (
TextWindow
.AdvanceIfMatches("apos;"))
4730
if (
TextWindow
.AdvanceIfMatches("quot;"))
4738
TextWindow
.AdvanceChar(); //#
4742
if (
TextWindow
.AdvanceIfMatches("x"))
4745
while (SyntaxFacts.IsHexDigit(digit =
TextWindow
.PeekChar()))
4747
TextWindow
.AdvanceChar();
4763
while (SyntaxFacts.IsDecDigit(digit =
TextWindow
.PeekChar()))
4765
TextWindow
.AdvanceChar();
4779
if (
TextWindow
.AdvanceIfMatches(";"))
4794
return new SyntaxDiagnosticInfo(start -
TextWindow
.LexemeStartPosition,
4795
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)
199
int i =
TextWindow
.Offset;
200
int n =
TextWindow
.CharacterWindowCount;
206
var charWindow =
TextWindow
.CharacterWindow;
234
TextWindow
.AdvanceChar(i -
TextWindow
.Offset);
241
TextWindow
.CharacterWindow,
242
TextWindow
.LexemeRelativeStart,
243
i -
TextWindow
.LexemeRelativeStart,
251
TextWindow
.Reset(
TextWindow
.LexemeStartPosition);
259
var quickWidth = lexer.
TextWindow
.Width;
261
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);