File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed
Tests/SwiftParserTest/translated Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -2058,6 +2058,7 @@ extension Lexer.Cursor {
20582058extension Lexer . Cursor {
20592059 mutating func tryLexEditorPlaceholder( sourceBufferStart: Lexer . Cursor ) -> Lexer . Result {
20602060 assert ( self . is ( at: " < " ) && self . is ( offset: 1 , at: " # " ) )
2061+ let start = self
20612062 var ptr = self
20622063 let leftAngleConsumed = ptr. advance ( matching: " < " )
20632064 let poundConsumed = ptr. advance ( matching: " # " )
@@ -2072,7 +2073,10 @@ extension Lexer.Cursor {
20722073 let closingAngleConsumed = ptr. advance ( matching: " > " )
20732074 assert ( closingAngleConsumed)
20742075 self = ptr
2075- return Lexer . Result ( . identifier)
2076+ return Lexer . Result (
2077+ . identifier,
2078+ error: LexingDiagnostic ( . invalidIdentifierStartCharacter, position: start)
2079+ )
20762080 default :
20772081 break
20782082 }
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public extension TokenError {
3838
3939/// Please order the cases in this enum alphabetically by case name.
4040public enum StaticTokenError : String , DiagnosticMessage {
41+ case editorPlaceholder = " editor placeholder in source file "
4142 case expectedBinaryExponentInHexFloatLiteral = " hexadecimal floating point literal must end with an exponent "
4243 case expectedClosingBraceInUnicodeEscape = #"expected '}' in \u{...} escape sequence"#
4344 case expectedDigitInFloatLiteral = " expected a digit in floating point exponent "
@@ -132,6 +133,7 @@ public extension SwiftSyntax.TokenDiagnostic {
132133 }
133134
134135 switch self . kind {
136+ case . editorPlaceholder: return StaticTokenError . editorPlaceholder
135137 case . expectedBinaryExponentInHexFloatLiteral: return StaticTokenError . expectedBinaryExponentInHexFloatLiteral
136138 case . expectedClosingBraceInUnicodeEscape: return StaticTokenError . expectedClosingBraceInUnicodeEscape
137139 case . expectedDigitInFloatLiteral: return StaticTokenError . expectedDigitInFloatLiteral
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ public struct TokenDiagnostic: Hashable {
2222 public enum Kind {
2323 // Please order these alphabetically
2424
25+ case editorPlaceholder
2526 case expectedBinaryExponentInHexFloatLiteral
2627 case expectedClosingBraceInUnicodeEscape
2728 case expectedDigitInFloatLiteral
@@ -94,6 +95,7 @@ public struct TokenDiagnostic: Hashable {
9495
9596 public var severity : Severity {
9697 switch kind {
98+ case . editorPlaceholder: return . error
9799 case . expectedBinaryExponentInHexFloatLiteral: return . error
98100 case . expectedClosingBraceInUnicodeEscape: return . error
99101 case . expectedDigitInFloatLiteral: return . error
Original file line number Diff line number Diff line change @@ -83,10 +83,10 @@ final class IdentifiersTests: XCTestCase {
8383 AssertParse (
8484 """
8585 // Placeholders are recognized as identifiers but with error.
86- func <#some name#>() {}
86+ func 1️⃣ <#some name#>() {}
8787 """ ,
8888 diagnostics: [
89- // TODO: (good first issue) Old parser expected error on line 2: editor placeholder in source file
89+ DiagnosticSpec ( message : " editor placeholder in source file " )
9090 ]
9191 )
9292 }
You can’t perform that action at this time.
0 commit comments