diff --git a/cli/repl.rs b/cli/repl.rs index b2ea32670f..b5f89ec51f 100644 --- a/cli/repl.rs +++ b/cli/repl.rs @@ -222,11 +222,15 @@ impl LineHighlighter { (?P(?:/\*[\s\S]*?\*/|//[^\n]*)) | (?P(?:"([^"\\]|\\.)*"|'([^'\\]|\\.)*'|`([^`\\]|\\.)*`)) | (?P/(?:(?:\\/|[^\n/]))*?/[gimsuy]*) | - (?P\d+(?:\.\d+)*(?:e[+-]?\d+)*n?) | + (?P\b\d+(?:\.\d+)?(?:e[+-]?\d+)*n?\b) | + (?P\b(?:Infinity|NaN)\b) | + (?P\b0x[a-fA-F0-9]+\b) | + (?P\b0o[0-7]+\b) | + (?P\b0b[01]+\b) | (?P\b(?:true|false)\b) | (?P\b(?:null)\b) | (?P\b(?:undefined)\b) | - (?P\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\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() }