@@ -120,7 +120,7 @@ let checkExprGreaterColonOp (lexbuf:UnicodeLexing.Lexbuf) =
120120let unexpectedChar lexbuf =
121121 LEX_FAILURE (FSComp.SR.lexUnexpectedChar(lexeme lexbuf))
122122
123- let startString args (lexbuf: UnicodeLexing.Lexbuf) altStartForStringPartOrEnd =
123+ let startString args (lexbuf: UnicodeLexing.Lexbuf) =
124124 let buf = ByteBuffer.Create StringCapacity
125125 let m = lexbuf.LexemeRange
126126 let startp = lexbuf.StartPos
@@ -158,9 +158,9 @@ let startString args (lexbuf: UnicodeLexing.Lexbuf) altStartForStringPartOrEnd =
158158 INTERP_STRING_BEGIN_END (s, synStringKind, cont)
159159 else
160160 if isPart then
161- INTERP_STRING_PART (s, altStartForStringPartOrEnd, cont)
161+ INTERP_STRING_PART (s, cont)
162162 else
163- INTERP_STRING_END (s, altStartForStringPartOrEnd, cont)
163+ INTERP_STRING_END (s, cont)
164164 else
165165 let s = Lexhelp.stringBufferAsString buf
166166 let synStringKind =
@@ -587,20 +587,20 @@ rule token (args: LexArgs) (skip: bool) = parse
587587 else mlOnly m args skip lexbuf }
588588
589589 | '"'
590- { let buf, fin, m = startString args lexbuf None
590+ { let buf, fin, m = startString args lexbuf
591591
592592 // Single quote in triple quote ok, others disallowed
593593 match args.stringNest with
594- | (_, LexerStringStyle.ExtendedInterpolated, _, _, _ ) :: _
595- | (_, LexerStringStyle.TripleQuote, _, _, _ ) :: _ -> ()
594+ | (_, LexerStringStyle.ExtendedInterpolated, _, _) :: _
595+ | (_, LexerStringStyle.TripleQuote, _, _) :: _ -> ()
596596 | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
597597 | [] -> ()
598598
599599 if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.SingleQuote, LexerStringKind.String, args.interpolationDelimiterLength, m))
600600 else singleQuoteString (buf, fin, m, LexerStringKind.String, args) skip lexbuf }
601601
602602 | '$' '"' '"' '"'
603- { let buf, fin, m = startString args lexbuf None
603+ { let buf, fin, m = startString args lexbuf
604604
605605 // Single quote in triple quote ok, others disallowed
606606 match args.stringNest with
@@ -612,7 +612,7 @@ rule token (args: LexArgs) (skip: bool) = parse
612612 else tripleQuoteString (buf, fin, m, LexerStringKind.InterpolatedStringFirst, args) skip lexbuf }
613613
614614 | ('$'+) '"' '"' '"'
615- { let buf, fin, m = startString args lexbuf None
615+ { let buf, fin, m = startString args lexbuf
616616
617617 if lexbuf.SupportsFeature LanguageFeature.ExtendedStringInterpolation then
618618 // Single quote in triple quote ok, others disallowed
@@ -635,11 +635,11 @@ rule token (args: LexArgs) (skip: bool) = parse
635635 }
636636
637637 | '$' '"'
638- { let buf,fin,m = startString args lexbuf None
638+ { let buf,fin,m = startString args lexbuf
639639
640640 // Single quote in triple quote ok, others disallowed
641641 match args.stringNest with
642- | (_, style, _, _, _ ) :: _ when style = LexerStringStyle.ExtendedInterpolated || style = LexerStringStyle.TripleQuote -> ()
642+ | (_, style, _, _) :: _ when style = LexerStringStyle.ExtendedInterpolated || style = LexerStringStyle.TripleQuote -> ()
643643 | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
644644 | _ -> ()
645645
@@ -649,7 +649,7 @@ rule token (args: LexArgs) (skip: bool) = parse
649649 singleQuoteString (buf, fin, m, LexerStringKind.InterpolatedStringFirst, args) skip lexbuf }
650650
651651 | '"' '"' '"'
652- { let buf, fin, m = startString args lexbuf None
652+ { let buf, fin, m = startString args lexbuf
653653
654654 args.interpolationDelimiterLength <- 0
655655
@@ -664,12 +664,12 @@ rule token (args: LexArgs) (skip: bool) = parse
664664 tripleQuoteString (buf, fin, m, LexerStringKind.String, args) skip lexbuf }
665665
666666 | '@' '"'
667- { let buf, fin, m = startString args lexbuf None
667+ { let buf, fin, m = startString args lexbuf
668668
669669 // Single quote in triple quote ok, others disallowed
670670 match args.stringNest with
671- | (_, LexerStringStyle.ExtendedInterpolated, _, _, _ ) :: _
672- | (_, LexerStringStyle.TripleQuote, _, _, _ ) :: _ -> ()
671+ | (_, LexerStringStyle.ExtendedInterpolated, _, _) :: _
672+ | (_, LexerStringStyle.TripleQuote, _, _) :: _ -> ()
673673 | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
674674 | _ -> ()
675675
@@ -679,11 +679,11 @@ rule token (args: LexArgs) (skip: bool) = parse
679679 verbatimString (buf, fin, m, LexerStringKind.String, args) skip lexbuf }
680680
681681 | ("$@" | "@$") '"'
682- { let buf, fin, m = startString args lexbuf None
682+ { let buf, fin, m = startString args lexbuf
683683
684684 // Single quote in triple quote ok, others disallowed
685685 match args.stringNest with
686- | (_, style, _, _, _ ) :: _ when style = LexerStringStyle.ExtendedInterpolated || style = LexerStringStyle.TripleQuote -> ()
686+ | (_, style, _, _) :: _ when style = LexerStringStyle.ExtendedInterpolated || style = LexerStringStyle.TripleQuote -> ()
687687 | _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
688688 | _ -> ()
689689
@@ -888,33 +888,48 @@ rule token (args: LexArgs) (skip: bool) = parse
888888 {
889889 match args.stringNest with
890890 | [] -> ()
891- | (counter, style, d, _, m) :: rest ->
891+ | (counter, style, d, m) :: rest ->
892892 // Note, we do not update the 'm', any incomplete-interpolation error
893893 // will be reported w.r.t. the first '{'
894- args.stringNest <- (counter + 1, style, d, None, m) :: rest
894+ args.stringNest <- (counter + 1, style, d, m) :: rest
895895 // To continue token-by-token lexing may involve picking up the new args.stringNes
896896 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
897897 LBRACE cont
898898 }
899899
900900 | "|" { BAR }
901901
902+ | "}" +
903+ {
904+ match args.stringNest with
905+ | (1, style, _, _r) :: rest ->
906+ args.stringNest <- rest
907+ let buf, fin, m = startString args lexbuf
908+ if not skip then
909+ STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, style, LexerStringKind.InterpolatedStringPart, args.interpolationDelimiterLength, m))
910+ else
911+ match style with
912+ | LexerStringStyle.Verbatim -> verbatimString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
913+ | LexerStringStyle.SingleQuote -> singleQuoteString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
914+ | LexerStringStyle.TripleQuote -> tripleQuoteString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
915+ | LexerStringStyle.ExtendedInterpolated -> extendedInterpolatedString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
916+ | (counter, style, d, m) :: rest ->
917+ // Note, we do not update the 'm', any incomplete-interpolation error
918+ // will be reported w.r.t. the first '{'
919+ args.stringNest <- (counter - 1, style, d, m) :: rest
920+ let cont = LexCont.Token(args.ifdefStack, args.stringNest)
921+ RBRACE cont
922+ | _ ->
923+ let cont = LexCont.Token(args.ifdefStack, args.stringNest)
924+ RBRACE cont
925+ }
926+
902927 | "}"
903928 {
904- // We encounter a '}' in the expression token stream. First check if we're in an interpolated string expression
905- // and continue the string if necessary
906929 match args.stringNest with
907- | (1, LexerStringStyle.ExtendedInterpolated, delimLength, altR, r) :: rest when delimLength > 1 ->
908- // On the first "}" of multiple "}", keep the range of the starting "}" for later processing in startString
909- let altStart =
910- match altR with
911- | None -> Some lexbuf.LexemeRange
912- | _ -> altR
913- args.stringNest <- (1, LexerStringStyle.ExtendedInterpolated, delimLength - 1, altStart, r) :: rest
914- token args skip lexbuf
915- | (1, style, _, altR, _r) :: rest ->
930+ | (1, style, _, _r) :: rest ->
916931 args.stringNest <- rest
917- let buf, fin, m = startString args lexbuf altR
932+ let buf, fin, m = startString args lexbuf
918933 if not skip then
919934 STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, style, LexerStringKind.InterpolatedStringPart, args.interpolationDelimiterLength, m))
920935 else
@@ -923,10 +938,10 @@ rule token (args: LexArgs) (skip: bool) = parse
923938 | LexerStringStyle.SingleQuote -> singleQuoteString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
924939 | LexerStringStyle.TripleQuote -> tripleQuoteString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
925940 | LexerStringStyle.ExtendedInterpolated -> extendedInterpolatedString (buf, fin, m, LexerStringKind.InterpolatedStringPart, args) skip lexbuf
926- | (counter, style, d, altR, m) :: rest ->
941+ | (counter, style, d, m) :: rest ->
927942 // Note, we do not update the 'm', any incomplete-interpolation error
928943 // will be reported w.r.t. the first '{'
929- args.stringNest <- (counter - 1, style, d, altR, m) :: rest
944+ args.stringNest <- (counter - 1, style, d, m) :: rest
930945 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
931946 RBRACE cont
932947
@@ -1264,7 +1279,7 @@ and singleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse
12641279 if kind.IsInterpolated then
12651280 // get a new range for where the fill starts
12661281 let m2 = lexbuf.LexemeRange
1267- args.stringNest <- (1, LexerStringStyle.SingleQuote, args.interpolationDelimiterLength, None, m2) :: args.stringNest
1282+ args.stringNest <- (1, LexerStringStyle.SingleQuote, args.interpolationDelimiterLength, m2) :: args.stringNest
12681283 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
12691284 fin.Finish buf kind LexerStringFinisherContext.InterpolatedPart cont
12701285 else
@@ -1380,7 +1395,7 @@ and verbatimString (sargs: LexerStringArgs) (skip: bool) = parse
13801395 if kind.IsInterpolated then
13811396 // get a new range for where the fill starts
13821397 let m2 = lexbuf.LexemeRange
1383- args.stringNest <- (1, LexerStringStyle.Verbatim, args.interpolationDelimiterLength, None, m2) :: args.stringNest
1398+ args.stringNest <- (1, LexerStringStyle.Verbatim, args.interpolationDelimiterLength, m2) :: args.stringNest
13841399 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
13851400 fin.Finish buf kind (LexerStringFinisherContext.InterpolatedPart ||| LexerStringFinisherContext.Verbatim) cont
13861401 else
@@ -1499,7 +1514,7 @@ and tripleQuoteString (sargs: LexerStringArgs) (skip: bool) = parse
14991514 if kind.IsInterpolated then
15001515 // get a new range for where the fill starts
15011516 let m2 = lexbuf.LexemeRange
1502- args.stringNest <- (1, LexerStringStyle.TripleQuote, args.interpolationDelimiterLength, None, m2) :: args.stringNest
1517+ args.stringNest <- (1, LexerStringStyle.TripleQuote, args.interpolationDelimiterLength, m2) :: args.stringNest
15031518 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
15041519 fin.Finish buf kind (LexerStringFinisherContext.InterpolatedPart ||| LexerStringFinisherContext.TripleQuote) cont
15051520 else
@@ -1604,7 +1619,7 @@ and extendedInterpolatedString (sargs: LexerStringArgs) (skip: bool) = parse
16041619 let maxBraces = 2 * args.interpolationDelimiterLength - 1
16051620 if numBraces > maxBraces then
16061621 let m2 = lexbuf.LexemeRange
1607- args.stringNest <- (1, LexerStringStyle.ExtendedInterpolated, args.interpolationDelimiterLength, None, m2) :: args.stringNest
1622+ args.stringNest <- (1, LexerStringStyle.ExtendedInterpolated, args.interpolationDelimiterLength, m2) :: args.stringNest
16081623 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
16091624 fail args lexbuf
16101625 (FSComp.SR.lexTooManyLBracesInTripleQuote())
@@ -1625,7 +1640,7 @@ and extendedInterpolatedString (sargs: LexerStringArgs) (skip: bool) = parse
16251640 String.replicate extraBraces "{" |> addUnicodeString buf
16261641 // get a new range for where the fill starts
16271642 let m2 = lexbuf.LexemeRange
1628- args.stringNest <- (1, LexerStringStyle.ExtendedInterpolated, args.interpolationDelimiterLength, None, m2) :: args.stringNest
1643+ args.stringNest <- (1, LexerStringStyle.ExtendedInterpolated, args.interpolationDelimiterLength, m2) :: args.stringNest
16291644 let cont = LexCont.Token(args.ifdefStack, args.stringNest)
16301645 fin.Finish buf kind (LexerStringFinisherContext.InterpolatedPart ||| LexerStringFinisherContext.TripleQuote) cont
16311646 }
0 commit comments