mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 15:49:44 -05:00
parent
6dd7633261
commit
e7cfd90b0f
1 changed files with 16 additions and 2 deletions
18
cli/repl.rs
18
cli/repl.rs
|
@ -222,11 +222,15 @@ impl LineHighlighter {
|
|||
(?P<comment>(?:/\*[\s\S]*?\*/|//[^\n]*)) |
|
||||
(?P<string>(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`)) |
|
||||
(?P<regexp>/(?:(?:\\/|[^\n/]))*?/[gimsuy]*) |
|
||||
(?P<number>\d+(?:\.\d+)*(?:e[+-]?\d+)*n?) |
|
||||
(?P<number>\b\d+(?:\.\d+)?(?:e[+-]?\d+)*n?\b) |
|
||||
(?P<infinity>\b(?:Infinity|NaN)\b) |
|
||||
(?P<hexnumber>\b0x[a-fA-F0-9]+\b) |
|
||||
(?P<octalnumber>\b0o[0-7]+\b) |
|
||||
(?P<binarynumber>\b0b[01]+\b) |
|
||||
(?P<boolean>\b(?:true|false)\b) |
|
||||
(?P<null>\b(?:null)\b) |
|
||||
(?P<undefined>\b(?:undefined)\b) |
|
||||
(?P<keyword>\b(?:await|async|var|let|for|if|else|in|of|class|const|function|yield|return|with|case|break|switch|import|export|new|while|do|throw|catch)\b) |
|
||||
(?P<keyword>\b(?:await|async|var|let|for|if|else|in|of|class|const|function|yield|return|with|case|break|switch|import|export|new|while|do|throw|catch|this)\b) |
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -256,6 +260,16 @@ impl Highlighter for LineHighlighter {
|
|||
format!("{}", colors::gray(cap.as_str()))
|
||||
} else if let Some(cap) = caps.name("keyword") {
|
||||
format!("{}", colors::cyan(cap.as_str()))
|
||||
} else if let Some(cap) = caps.name("infinity") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
} else if let Some(cap) = caps.name("classes") {
|
||||
format!("{}", colors::green_bold(cap.as_str()))
|
||||
} else if let Some(cap) = caps.name("hexnumber") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
} else if let Some(cap) = caps.name("octalnumber") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
} else if let Some(cap) = caps.name("binarynumber") {
|
||||
format!("{}", colors::yellow(cap.as_str()))
|
||||
} else {
|
||||
caps[0].to_string()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue