angle brackets
This commit is contained in:
parent
049132b6ee
commit
43e40b61e3
3 changed files with 30 additions and 6 deletions
|
|
@ -264,7 +264,8 @@ impl<'a> Token<'a> {
|
|||
Path::parse().map(Self::Path),
|
||||
AnyString::parse().map(Self::String),
|
||||
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",
|
||||
(
|
||||
opt((
|
||||
Atom::parse(alt(("(", "[", "{", Separator::parse().value("")))),
|
||||
Atom::parse(alt(("(", "[", "{", "<", Separator::parse().value("")))),
|
||||
Space::parse(),
|
||||
)),
|
||||
alt((
|
||||
literal('(').map(|_| literal(')').value(Delimiter::Paren)),
|
||||
literal('[').map(|_| literal(']').value(Delimiter::Bracket)),
|
||||
literal('{').map(|_| literal('}').value(Delimiter::Brace)),
|
||||
literal('<').map(|_| literal('>').value(Delimiter::Angle)),
|
||||
))
|
||||
.flat_map(|end| Segments::parse(end)),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -225,7 +225,17 @@ mod private {
|
|||
|
||||
match prefix {
|
||||
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);
|
||||
}
|
||||
None => {}
|
||||
|
|
@ -741,7 +751,13 @@ mod tests {
|
|||
),
|
||||
),
|
||||
(
|
||||
"<u32",
|
||||
"<",
|
||||
Delimiter(
|
||||
0,
|
||||
),
|
||||
),
|
||||
(
|
||||
"u32",
|
||||
Text,
|
||||
),
|
||||
(
|
||||
|
|
@ -761,9 +777,15 @@ mod tests {
|
|||
),
|
||||
),
|
||||
(
|
||||
"Trait>",
|
||||
"Trait",
|
||||
Text,
|
||||
),
|
||||
(
|
||||
">",
|
||||
Delimiter(
|
||||
0,
|
||||
),
|
||||
),
|
||||
(
|
||||
" ",
|
||||
Space(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue