Bjolang's raw strings are strings

Bjolang reads """...""" as a raw string: three or more quotes open it, the
same number close it, and nothing in it is an escape. The grammar has a
string.quoted.triple.bjolang scope for it, so quotes inside one stay inside,
and one over several lines is a string on every line. tests/demo.bjo checks
both, and passes.

🤖 Generated with [ECA](https://eca.dev) (anthropic/claude-opus-5-5)

Co-Authored-By: eca-agent <git@eca.dev>
This commit is contained in:
Linus Björnstam 2026-10-01 09:32:18 +02:00
parent c499691376
commit 6bb44bc05f
2 changed files with 30 additions and 0 deletions

View file

@ -26,6 +26,9 @@
{ {
"include": "#interpolated-string" "include": "#interpolated-string"
}, },
{
"include": "#raw-string"
},
{ {
"include": "#string" "include": "#string"
}, },
@ -107,6 +110,22 @@
} }
] ]
}, },
"raw-string": {
"comment": "\"\"\"...\"\"\": three or more quotes open it, the same number close it, and nothing in it is an escape.",
"begin": "(\"{3,})",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.bjolang"
}
},
"end": "(?<!\")\\1(?!\")",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.bjolang"
}
},
"name": "string.quoted.triple.bjolang"
},
"string": { "string": {
"begin": "\"", "begin": "\"",
"beginCaptures": { "beginCaptures": {

View file

@ -106,6 +106,17 @@
[(scope "\"" ["source.cs" "string.quoted.double.cs" "punctuation.definition.string.begin.cs"]) [(scope "\"" ["source.cs" "string.quoted.double.cs" "punctuation.definition.string.begin.cs"])
(scope "//" ["source.cs" "comment.line.double-slash.cs" "punctuation.definition.comment.cs"])]) (scope "//" ["source.cs" "comment.line.double-slash.cs" "punctuation.definition.comment.cs"])])
["tm-string" "tm-comment"]) ["tm-string" "tm-comment"])
(def raw-line (vec-ref (tokenize bjo "(f \"\"\"a \"b\" c\"\"\" x)") 0))
(expect "a raw string holds quotes, and closes with as many as opened it"
(texts raw-line) ["(" "f " "\"\"\"" "a \"b\" c" "\"\"\"" " x" ")"])
(expect "and all of it is the string"
(vec-map innermost (vec-slice raw-line 2 3))
["punctuation.definition.string.begin.bjolang" "string.quoted.triple.bjolang"
"punctuation.definition.string.end.bjolang"])
(expect "a raw string goes on to the next line"
(innermost (vec-ref (vec-ref (tokenize bjo "(g \"\"\"\n one \"\" two\n \"\"\")") 1) 0))
"string.quoted.triple.bjolang")
(expect "embedded code is not coloured by what it is embedded in" (expect "embedded code is not coloured by what it is embedded in"
(string-join (token-classes (scope "x" ["source.bjolang" "string.interpolated.bjolang" (string-join (token-classes (scope "x" ["source.bjolang" "string.interpolated.bjolang"
"meta.embedded.line.bjolang" "source.bjolang"])) "meta.embedded.line.bjolang" "source.bjolang"]))