mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-29 09:23:46 +00:00
add support for slashes
This commit is contained in:
parent
093f8e297d
commit
f51aef42bb
2 changed files with 32 additions and 1 deletions
|
@ -39,6 +39,7 @@ pub enum Token {
|
||||||
LessThan,
|
LessThan,
|
||||||
Comma,
|
Comma,
|
||||||
Backslash,
|
Backslash,
|
||||||
|
Slash,
|
||||||
Brace,
|
Brace,
|
||||||
Bracket,
|
Bracket,
|
||||||
Paren,
|
Paren,
|
||||||
|
@ -315,6 +316,13 @@ fn highlight_inner<'a>(
|
||||||
Token::Backslash,
|
Token::Backslash,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
'/' => {
|
||||||
|
state.advance_mut(1);
|
||||||
|
tokens.push(Loc::at(
|
||||||
|
Region::between(start, state.pos()),
|
||||||
|
Token::Slash,
|
||||||
|
));
|
||||||
|
}
|
||||||
'{' | '}' => {
|
'{' | '}' => {
|
||||||
state.advance_mut(1);
|
state.advance_mut(1);
|
||||||
tokens.push(Loc::at(Region::between(start, state.pos()), Token::Brace));
|
tokens.push(Loc::at(Region::between(start, state.pos()), Token::Brace));
|
||||||
|
@ -631,4 +639,27 @@ mod tests {
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_highlight_slash() {
|
||||||
|
let text = "first / second";
|
||||||
|
let tokens = highlight(text);
|
||||||
|
assert_eq!(
|
||||||
|
tokens,
|
||||||
|
vec![
|
||||||
|
Loc::at(
|
||||||
|
Region::between(Position::new(0), Position::new(5)),
|
||||||
|
Token::LowerIdent
|
||||||
|
),
|
||||||
|
Loc::at(
|
||||||
|
Region::between(Position::new(6), Position::new(7)),
|
||||||
|
Token::Slash
|
||||||
|
),
|
||||||
|
Loc::at(
|
||||||
|
Region::between(Position::new(8), Position::new(14)),
|
||||||
|
Token::LowerIdent
|
||||||
|
),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ pub fn highlight_roc_code(code: &str) -> String {
|
||||||
Token::Colon => {
|
Token::Colon => {
|
||||||
buf = push_html_span(buf, current_text, "colon");
|
buf = push_html_span(buf, current_text, "colon");
|
||||||
}
|
}
|
||||||
Token::GreaterThan | Token::Minus | Token::LessThan | Token::Plus | Token::Equals => {
|
Token::Slash | Token::GreaterThan | Token::Minus | Token::LessThan | Token::Plus | Token::Equals => {
|
||||||
buf = push_html_span(buf, current_text, "op");
|
buf = push_html_span(buf, current_text, "op");
|
||||||
}
|
}
|
||||||
Token::Paren => {
|
Token::Paren => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue