Scala: Support metavars as elements in interpolated strings#403
Merged
maciejpirog merged 1 commit intomainfrom Aug 27, 2025
Merged
Scala: Support metavars as elements in interpolated strings#403maciejpirog merged 1 commit intomainfrom
maciejpirog merged 1 commit intomainfrom
Conversation
1ffd6f0 to
aec7fd2
Compare
dimitris-m
reviewed
Aug 27, 2025
Comment on lines
+2312
to
+2315
| match s.[0], Domain.DLS.get Flag_parsing.sgrep_mode with | ||
| | '$', true -> xs += EncapsExpr (Name (Id x, [])) | ||
| | '$', false -> xs += EncapsDollarIdent (String.sub s 1 (String.length s - 1), t) | ||
| | _ -> xs += EncapsDollarIdent x |
Collaborator
There was a problem hiding this comment.
It would probably be more efficient to check Char.equal s.[0] '$' and only in that case read from DLS.
dimitris-m
reviewed
Aug 27, 2025
| @@ -0,0 +1,4 @@ | |||
|
|
|||
| //ERROR: match | |||
| println(s"this $x value comes $x") | |||
Collaborator
There was a problem hiding this comment.
weird text, maybe:
println(s"this $x value is $x")
dimitris-m
approved these changes
Aug 27, 2025
Collaborator
dimitris-m
left a comment
There was a problem hiding this comment.
lgtm, left some minor comments.
aec7fd2 to
1bad967
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.
Closes #106
In this PR:
$inside an interpolated string when it is followed by a metavar identifiersgrepmode (i.e., when parsing patterns) the parser distinguishes between variables and metavariables by checking if the identifier starts with$. In non-sgrepmode (i.e., when parsing targets), the parser treats all identifiers as variables.