@@ -905,6 +905,11 @@ extension Lexer.Cursor {
905905 case UInt8 ( ascii: " \\ " ) : _ = self . advance ( ) ; return Lexer . Result ( . backslash)
906906
907907 case UInt8 ( ascii: " # " ) :
908+ // Try lex shebang.
909+ if self . isAtStartOfFile, self . peek ( at: 1 ) == UInt8 ( ascii: " ! " ) {
910+ self . advanceToEndOfLine ( )
911+ return Lexer . Result ( . shebang)
912+ }
908913 // Try lex a raw string literal.
909914 if let delimiterLength = self . advanceIfOpeningRawStringDelimiter ( ) {
910915 return Lexer . Result ( . rawStringPoundDelimiter, stateTransition: . push( newState: . afterRawStringDelimiter( delimiterLength: delimiterLength) ) )
@@ -1171,12 +1176,6 @@ extension Lexer.Cursor {
11711176 default :
11721177 break
11731178 }
1174- case UInt8 ( ascii: " # " ) :
1175- guard start. isAtStartOfFile, self . advance ( if: { $0 == " ! " } ) else {
1176- break
1177- }
1178- self . advanceToEndOfLine ( )
1179- continue
11801179 case UInt8 ( ascii: " < " ) , UInt8 ( ascii: " > " ) :
11811180 if self . tryLexConflictMarker ( start: start) {
11821181 error = LexingDiagnostic ( . sourceConflictMarker, position: start)
@@ -1189,6 +1188,7 @@ extension Lexer.Cursor {
11891188 UInt8 ( ascii: " } " ) , UInt8 ( ascii: " ] " ) , UInt8 ( ascii: " ) " ) ,
11901189 UInt8 ( ascii: " @ " ) , UInt8 ( ascii: " , " ) , UInt8 ( ascii: " ; " ) ,
11911190 UInt8 ( ascii: " : " ) , UInt8 ( ascii: " \\ " ) , UInt8 ( ascii: " $ " ) ,
1191+ UInt8 ( ascii: " # " ) ,
11921192
11931193 // Start of integer/hex/float literals.
11941194 UInt8 ( ascii: " 0 " ) , UInt8 ( ascii: " 1 " ) , UInt8 ( ascii: " 2 " ) ,
0 commit comments