angle brackets
This commit is contained in:
parent
049132b6ee
commit
43e40b61e3
3 changed files with 30 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "logparse"
|
name = "logparse"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
description = "parse arbitrary messages containing rust-like debug output to syntax highlight them"
|
description = "parse arbitrary messages containing rust-like debug output to syntax highlight them"
|
||||||
authors = ["Jana Dönszelmann <cratesio@donsz.nl>"]
|
authors = ["Jana Dönszelmann <cratesio@donsz.nl>"]
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,8 @@ impl<'a> Token<'a> {
|
||||||
Path::parse().map(Self::Path),
|
Path::parse().map(Self::Path),
|
||||||
AnyString::parse().map(Self::String),
|
AnyString::parse().map(Self::String),
|
||||||
delimited,
|
delimited,
|
||||||
Atom::parse(alt((Separator::parse().value(""), ")", "]", "}"))).map(Self::Atom),
|
Atom::parse(alt((Separator::parse().value(""), ")", "]", "}", ">")))
|
||||||
|
.map(Self::Atom),
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -313,13 +314,14 @@ impl<'a> Delimited<'a> {
|
||||||
"delimited",
|
"delimited",
|
||||||
(
|
(
|
||||||
opt((
|
opt((
|
||||||
Atom::parse(alt(("(", "[", "{", Separator::parse().value("")))),
|
Atom::parse(alt(("(", "[", "{", "<", Separator::parse().value("")))),
|
||||||
Space::parse(),
|
Space::parse(),
|
||||||
)),
|
)),
|
||||||
alt((
|
alt((
|
||||||
literal('(').map(|_| literal(')').value(Delimiter::Paren)),
|
literal('(').map(|_| literal(')').value(Delimiter::Paren)),
|
||||||
literal('[').map(|_| literal(']').value(Delimiter::Bracket)),
|
literal('[').map(|_| literal(']').value(Delimiter::Bracket)),
|
||||||
literal('{').map(|_| literal('}').value(Delimiter::Brace)),
|
literal('{').map(|_| literal('}').value(Delimiter::Brace)),
|
||||||
|
literal('<').map(|_| literal('>').value(Delimiter::Angle)),
|
||||||
))
|
))
|
||||||
.flat_map(|end| Segments::parse(end)),
|
.flat_map(|end| Segments::parse(end)),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,17 @@ mod private {
|
||||||
|
|
||||||
match prefix {
|
match prefix {
|
||||||
Some((Atom::Text(text), space)) => {
|
Some((Atom::Text(text), space)) => {
|
||||||
cx.push(text, SpanKind::Constructor);
|
cx.push(
|
||||||
|
text,
|
||||||
|
match delimiter {
|
||||||
|
Delimiter::Bracket => SpanKind::Constructor,
|
||||||
|
Delimiter::Paren if space.0.is_empty() => SpanKind::Constructor,
|
||||||
|
Delimiter::Paren => SpanKind::Text,
|
||||||
|
Delimiter::Brace => SpanKind::Text,
|
||||||
|
Delimiter::Angle if space.0.is_empty() => SpanKind::Constructor,
|
||||||
|
Delimiter::Angle => SpanKind::Text,
|
||||||
|
},
|
||||||
|
);
|
||||||
space.into_spans(cx);
|
space.into_spans(cx);
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
|
|
@ -741,7 +751,13 @@ mod tests {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"<u32",
|
"<",
|
||||||
|
Delimiter(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"u32",
|
||||||
Text,
|
Text,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
|
|
@ -761,9 +777,15 @@ mod tests {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"Trait>",
|
"Trait",
|
||||||
Text,
|
Text,
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
">",
|
||||||
|
Delimiter(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
" ",
|
" ",
|
||||||
Space(
|
Space(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue