LexFSharp does not ensure the per-line stability of quoted string literals within the span of multi-line strings, such as the XML attributes in this example:
"""<?xml version="1.0" encoding="utf-8"?>
<root>
<pre xml:space="preserve">
</pre>
</root>
"""
After the first newline, the lexer loses track of the enclosing string's style, transitioning to the default state as soon as a double quote is encountered:
Visual Styles
(Example) Diagnostic Output
~/git/lexilla/lexilla/test/examples/fsharp/quoted.fsx:3: has different per-line styles
This patch refactors string lexing to preserve line state of multi-line strings, both verbatim and interpolated:
0001-gh-353-fsharp-refactor-multi-line-strings.patch.txt
Significant changes include:
-
removal of the FSharpString structure; its properties are now saved in the upper bits of the line state integer
-
removal of the CanEmbedQuotes helper function; its content has been inlined at the call site
-
treating quoted identifiers (delimited by ``) as a separate case from strings; this was always more logical as quoted identifiers cannot span lines:
Microsoft (R) F# Interactive version 15.2.201.0 for F# 10.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> let ``name with " "s
let ``name with " "s
----^^^^^^^^^^^^^^^^
stdin(1,5): error FS3563: This is not a valid identifier
- ;;
> let ``better name with " "s`` = ()
- ;;
val ``better name with " "s`` : unit = ()
Since the affected code paths include format specifier handling, new examples have been added to the suite of interpolated strings, where any regressions in single-line string lexing are most likely to be noticed:
0002-gh-353-fsharp-test-multi-line-strings.patch.txt
LexFSharp does not ensure the per-line stability of quoted string literals within the span of multi-line strings, such as the XML attributes in this example:
After the first newline, the lexer loses track of the enclosing string's style, transitioning to the default state as soon as a double quote is encountered:
Visual Styles
(Example) Diagnostic Output
This patch refactors string lexing to preserve line state of multi-line strings, both verbatim and interpolated:
0001-gh-353-fsharp-refactor-multi-line-strings.patch.txt
Significant changes include:
removal of the
FSharpStringstructure; its properties are now saved in the upper bits of the line state integerremoval of the
CanEmbedQuoteshelper function; its content has been inlined at the call sitetreating quoted identifiers (delimited by
``) as a separate case from strings; this was always more logical as quoted identifiers cannot span lines:Since the affected code paths include format specifier handling, new examples have been added to the suite of interpolated strings, where any regressions in single-line string lexing are most likely to be noticed:
0002-gh-353-fsharp-test-multi-line-strings.patch.txt