Open
Conversation
6409eb9 to
c81a357
Compare
|
Scheduled for backport to |
f862b74 to
3b23a0e
Compare
Raw strings are taken verbatim: no escape processing, no #{} interpolation.
3b23a0e to
9a7d939
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a raw string literal syntax that suppresses both escape processing and
#{}interpolation. Content is taken verbatim from source.The syntax is inspired by OCaml's quoted string literals (
{id|...|id}),This PR implements the changes required to support the feature requested in #4957.
Syntax
{|...|}— basic form, terminates at the first|}{id|...|id}— delimited form, whereidis any sequence of lowercase letters and underscores; terminates only at|id}with the matching idThis allows embedding
|}inside a raw string by choosing a non-empty id:Implementation
The lexer matches
{[a-z_]*|as the opening delimiter, extracts the id, and delegates toread_raw_string. That function scans until it finds|[a-z_]*}with a matching id, treating any non-matching|..}sequences as literal content.A new
RAW_STRINGtoken carries the raw content string. The pipeline adds:`Raw_string of (string * string)variant inparsed_astterm_preprocessor(noexpand_stringprocessing)`Raw_string (_, s) -> `String sinterm_reducerparsed_jsonwith bothidseparator and string content.