Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve lexer error recovery with interpolated strings. #54875

Merged
merged 49 commits into from
Jul 25, 2021
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
90a4f3b
Improve lexing recovery in string literals.
CyrusNajmabadi Jul 16, 2021
944eff3
add tests
CyrusNajmabadi Jul 16, 2021
4a25d56
Improved recovery for comments in strings.
CyrusNajmabadi Jul 16, 2021
1ea60b1
Add tests
CyrusNajmabadi Jul 16, 2021
b1874f7
Update tests
CyrusNajmabadi Jul 16, 2021
804dc44
Improve recovery
CyrusNajmabadi Jul 16, 2021
f19a2fc
Remove hardcoded error codes.
CyrusNajmabadi Jul 16, 2021
a8c2379
Doc
CyrusNajmabadi Jul 16, 2021
649f71b
Before changes
CyrusNajmabadi Jul 16, 2021
d985d20
Collapse to one error message
CyrusNajmabadi Jul 16, 2021
a0d79d5
Simplify
CyrusNajmabadi Jul 16, 2021
1a26596
Fixup
CyrusNajmabadi Jul 16, 2021
f789b07
Temp
CyrusNajmabadi Jul 16, 2021
0ab8e6d
Feature fallout
CyrusNajmabadi Jul 16, 2021
c1cc28c
Merge remote-tracking branch 'upstream/main' into lexingRecovery
CyrusNajmabadi Jul 20, 2021
7bb1203
Spelling
CyrusNajmabadi Jul 20, 2021
db131e6
Update error code
CyrusNajmabadi Jul 20, 2021
4d9b049
spelling
CyrusNajmabadi Jul 20, 2021
929bb68
nrt
CyrusNajmabadi Jul 20, 2021
8e1dbdc
Be consistent with brace placement
CyrusNajmabadi Jul 20, 2021
17888b0
Use ??=
CyrusNajmabadi Jul 20, 2021
e213d0c
Use discards
CyrusNajmabadi Jul 20, 2021
0e7a783
use pattern matching
CyrusNajmabadi Jul 20, 2021
6663af9
improve error test
CyrusNajmabadi Jul 20, 2021
50782d0
Pattern matching
CyrusNajmabadi Jul 20, 2021
1ef5ae1
Named parameters for clarity
CyrusNajmabadi Jul 20, 2021
31c520f
no need for 'this._'
CyrusNajmabadi Jul 20, 2021
54edb98
Fix spelling
CyrusNajmabadi Jul 20, 2021
3ce7485
Fix tests
CyrusNajmabadi Jul 20, 2021
b58beed
Update test
CyrusNajmabadi Jul 20, 2021
2cf9b05
Rename error code
CyrusNajmabadi Jul 21, 2021
e6eca49
update resource
CyrusNajmabadi Jul 21, 2021
50075eb
Add braces
CyrusNajmabadi Jul 22, 2021
3397aec
add named args
CyrusNajmabadi Jul 22, 2021
a4b6282
Update comment
CyrusNajmabadi Jul 22, 2021
8894311
Update tests
CyrusNajmabadi Jul 22, 2021
d2b4a31
Update tests
CyrusNajmabadi Jul 22, 2021
90e87ca
NRTenable
CyrusNajmabadi Jul 22, 2021
59e158d
Tweak how we do errors.
CyrusNajmabadi Jul 22, 2021
7429a21
nrt
CyrusNajmabadi Jul 22, 2021
7388648
Always pick the earliest error
CyrusNajmabadi Jul 22, 2021
e8364d0
Change code
CyrusNajmabadi Jul 22, 2021
2a9e289
Merge remote-tracking branch 'upstream/main' into lexingRecovery
CyrusNajmabadi Jul 22, 2021
7e3d7fb
Go back to old behavior
CyrusNajmabadi Jul 22, 2021
04886a5
Update tests
CyrusNajmabadi Jul 22, 2021
136a6fc
Merge remote-tracking branch 'upstream/main' into lexingRecovery
CyrusNajmabadi Jul 25, 2021
27be66d
Fix test
CyrusNajmabadi Jul 25, 2021
a0e35ea
Adjust test baseline for `CSharpAddMissingUsingsOnPaste.VerifyDisable…
jcouv Jul 25, 2021
534a42a
Merge remote-tracking branch 'upstream/devjcouvintegration-test' into…
CyrusNajmabadi Jul 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6794,4 +6794,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_SimpleProgramIsEmpty" xml:space="preserve">
<value>At least one top-level statement must be non-empty.</value>
</data>
</root>
<data name="ERR_NewlinesAreNotAllowedInsideANonVerbatimInterpolatedString" xml:space="preserve">
<value>Newlines are not allowed inside a non-verbatim interpolated string</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,7 @@ internal enum ErrorCode
ERR_FileScopedAndNormalNamespace = 8955,
ERR_FileScopedNamespaceNotBeforeAllMembers = 8956,
ERR_NoImplicitConvTargetTypedConditional = 8957,
ERR_NewlinesAreNotAllowedInsideANonVerbatimInterpolatedString = 8959,

#endregion

Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/CSharp/Portable/Parser/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,9 @@ private void ScanSyntaxToken(ref TokenInfo info)
case '@':
if (TextWindow.PeekChar(1) == '"')
{
this.ScanVerbatimStringLiteral(ref info);
var errorCode = this.ScanVerbatimStringLiteral(ref info, allowNewlines: true);
if (errorCode is ErrorCode code)
this.AddError(code);
}
else if (TextWindow.PeekChar(1) == '$' && TextWindow.PeekChar(2) == '"')
{
Expand Down
333 changes: 174 additions & 159 deletions src/Compilers/CSharp/Portable/Parser/Lexer_StringLiteral.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.