mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-13 13:28:27 +02:00
Rust multi-line strings
Quoting Rust documentation > Line-breaks are allowed in string literals. A line-break is either a newline > (U+000A) or a pair of carriage return and newline (U+000D, U+000A). https://doc.rust-lang.org/reference/tokens.html#string-literals
This commit is contained in:
parent
ab61726cdb
commit
552ad244cf
@ -28,8 +28,8 @@ var Rust = internal.Register(MustNewLexer(
|
||||
{`/\*\*(\n|[^/*])`, LiteralStringDoc, Push("doccomment")},
|
||||
{`/\*!`, LiteralStringDoc, Push("doccomment")},
|
||||
{`/\*`, CommentMultiline, Push("comment")},
|
||||
{`r#*"(?:\\.|[^\\\r\n;])*"#*`, LiteralString, nil},
|
||||
{`"(?:\\.|[^\\\r\n"])*"`, LiteralString, nil},
|
||||
{`r#*"(?:\\.|[^\\;])*"#*`, LiteralString, nil},
|
||||
{`"(?:\\.|[^\\"])*"`, LiteralString, nil},
|
||||
{`\$([a-zA-Z_]\w*|\(,?|\),?|,?)`, CommentPreproc, nil},
|
||||
{Words(``, `\b`, `as`, `async`, `await`, `const`, `crate`, `else`, `extern`, `for`, `if`, `impl`, `in`, `loop`, `match`, `move`, `mut`, `pub`, `ref`, `return`, `static`, `super`, `trait`, `unsafe`, `use`, `where`, `while`), Keyword, nil},
|
||||
{Words(``, `\b`, `abstract`, `become`, `box`, `do`, `final`, `macro`, `override`, `priv`, `try`, `typeof`, `unsized`, `virtual`, `yield`), KeywordReserved, nil},
|
||||
|
6
lexers/testdata/rust.actual
vendored
6
lexers/testdata/rust.actual
vendored
@ -14,4 +14,10 @@ fn main() {
|
||||
|
||||
let r#type = "valid";
|
||||
let i: i128 = 1117;
|
||||
|
||||
let s = "March
|
||||
April";
|
||||
let s = r"March
|
||||
April";
|
||||
|
||||
}
|
||||
|
20
lexers/testdata/rust.expected
vendored
20
lexers/testdata/rust.expected
vendored
@ -86,7 +86,25 @@
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralNumberInteger","value":"1117"},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n"},
|
||||
{"type":"TextWhitespace","value":"\n\n "},
|
||||
{"type":"KeywordDeclaration","value":"let"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"s"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralString","value":"\"March\nApril\""},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n "},
|
||||
{"type":"KeywordDeclaration","value":"let"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Name","value":"s"},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"Operator","value":"="},
|
||||
{"type":"TextWhitespace","value":" "},
|
||||
{"type":"LiteralString","value":"r\"March\nApril\""},
|
||||
{"type":"Punctuation","value":";"},
|
||||
{"type":"TextWhitespace","value":"\n\n"},
|
||||
{"type":"Punctuation","value":"}"},
|
||||
{"type":"TextWhitespace","value":"\n"}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user