Skip to content

[WIP] Implement dedented string syntax#291

Draft
lihaoyi wants to merge 2 commits intoscala:mainfrom
lihaoyi:main
Draft

[WIP] Implement dedented string syntax#291
lihaoyi wants to merge 2 commits intoscala:mainfrom
lihaoyi:main

Conversation

@lihaoyi
Copy link
Copy Markdown

@lihaoyi lihaoyi commented Aug 29, 2025

SIP discussion https://github.com/scala/improvement-proposals/pulls

For now just hard-codes supports for ''', '''', ''''', ''''''`. TextMate Grammars do not allow "dynamic" lexing as far as I can tell, so we can't say "match closing delimiter with the same length as the opening delimiter", but in practice most delimiters will be short so just enumerating a number of the should be enough 99.9% of the time

@RedCMD
Copy link
Copy Markdown

RedCMD commented Aug 30, 2025

TextMate does support that
use (capture groups) and backreferences \\1

"begin": "\"\"\"",
"end": "\\0(?!\")",
"beginCaptures": { "0": { "name": "punctuation.definition.string.begin.scala" } },
"endCaptures": { "0": { "name": "punctuation.definition.string.end.scala" } },
"name": "string.quoted.triple.scala",
"patterns": [
	{
		"match": "\\\\\\\\|\\\\u[0-9A-Fa-f]{4}",
		"name": "constant.character.escape.scala"
	}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants