Skip to content

Make printed Screenplay round-trip for numerics and quoted strings - #41

Merged
woksin merged 5 commits into
mainfrom
fix/printer-round-trip
Jul 28, 2026
Merged

Make printed Screenplay round-trip for numerics and quoted strings#41
woksin merged 5 commits into
mainfrom
fix/printer-round-trip

Conversation

@woksin

@woksin woksin commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Changed

Fixed

woksin added 5 commits July 29, 2026 01:41
Introduce a shared StringLiteral helper holding the escape rules and the
regular expression fragment for a literal body, and teach every parser that
reads a quoted operand to resolve the escapes: descriptions, validation
messages, screen labels and titles, seed group ids, specification errors,
capture translations and separators, policy roles and claims, condition
operands and tags.

Only \", \\, \n, \r and \t are recognized. Any other backslash sequence is
kept verbatim so regular expression operands such as matches "^\d+$" keep
their meaning.

The line scanners that track string state - SplitTopLevel and the comment
stripper - skip the character after a backslash so an escaped quote no longer
ends the string.
Printing a tree could produce text that does not compile back, breaking the
inverse guarantee the printer documents.

Non-double numeric literals fell through to a bare ToString(), so a decimal
or float printed with the current culture's decimal separator - 5,5 on a
comma-decimal machine, which then fails to parse. Route every IFormattable
value through the invariant culture.

String literals were interpolated between quotes with no escaping, so any
value holding a " terminated the literal early. Every emission site now goes
through StringLiteral.Quote: descriptions, validation messages, screen labels
and titles, seed group ids, specification errors, capture translations and
separators, policy roles and claims, and tags.
Cover the two defects the existing invoicing round trip cannot catch: it has
no quote in any value and runs under the invariant culture.

The numeric spec prints decimal, float, int and long literals with
CurrentCulture set to nb-NO and asserts both the invariant output and a clean
print, compile, reprint cycle. The quoted-text specs cover description,
validation message, screen label and tag, and a regular expression operand
proves an unknown escape survives verbatim.
Give StringLiteral a real production with the recognized escapes, note that
any other backslash sequence is kept verbatim, and state on the printing page
that strings are escaped and numbers are culture-invariant.
@woksin woksin added the patch Bug fixes, docs, refactoring label Jul 28, 2026
@woksin
woksin merged commit 01ecf43 into main Jul 28, 2026
1 check passed
@woksin
woksin deleted the fix/printer-round-trip branch July 28, 2026 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Bug fixes, docs, refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant