Skip to content

Commit

Permalink
Cover more cases of incomplete interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
abonie committed Nov 3, 2022
1 parent 67ed33a commit 6468fe5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Compiler/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,9 @@ rule token args skip = parse

// Single quote in triple quote ok, others disallowed
match args.stringNest with
| _ :: _ -> errorR(Error(FSComp.SR.lexTripleQuoteInTripleQuote(), m))
| _ :: rest ->
args.stringNest <- rest
errorR(Error(FSComp.SR.lexTripleQuoteInTripleQuote(), m))
| [] -> ()

if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.TripleQuote, LexerStringKind.InterpolatedStringFirst, m))
Expand All @@ -626,7 +628,9 @@ rule token args skip = parse
// Single quote in triple quote ok, others disallowed
match args.stringNest with
| (_, LexerStringStyle.TripleQuote, _) :: _ -> ()
| _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
| _ :: rest ->
args.stringNest <- rest
errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
| _ -> ()

if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.SingleQuote, LexerStringKind.InterpolatedStringFirst, m))
Expand All @@ -651,7 +655,9 @@ rule token args skip = parse
// Single quote in triple quote ok, others disallowed
match args.stringNest with
| (_, LexerStringStyle.TripleQuote, _) :: _ -> ()
| _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
| _ :: rest ->
args.stringNest <- rest
errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
| _ -> ()

if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.Verbatim, LexerStringKind.String, m))
Expand All @@ -663,7 +669,9 @@ rule token args skip = parse
// Single quote in triple quote ok, others disallowed
match args.stringNest with
| (_, LexerStringStyle.TripleQuote, _) :: _ -> ()
| _ :: _ -> errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
| _ :: rest ->
args.stringNest <- rest
errorR(Error(FSComp.SR.lexSingleQuoteInSingleQuote(), m))
| _ -> ()

if not skip then STRING_TEXT (LexCont.String(args.ifdefStack, args.stringNest, LexerStringStyle.Verbatim, LexerStringKind.InterpolatedStringFirst, m))
Expand Down

0 comments on commit 6468fe5

Please sign in to comment.