Skip to content

Commit

Permalink
Pop string nesting before error in nested quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
abonie committed Nov 3, 2022
1 parent 4ffb1cc commit 67ed33a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Compiler/lex.fsl
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,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.String, m))
Expand Down Expand Up @@ -635,7 +637,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.String, m))
Expand Down

0 comments on commit 67ed33a

Please sign in to comment.