diff options
author | Freya Murphy <freya@freyacat.org> | 2024-03-01 19:51:32 -0500 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-03-01 19:51:32 -0500 |
commit | 4124346ba13bc6c07c3722a55e323b40cefbd6c4 (patch) | |
tree | cb87a11b759bce793c9a35e30e97deffc11aecf7 /matrix-bin | |
parent | remove unwraps, fix utf8 (diff) | |
download | matrix-4124346ba13bc6c07c3722a55e323b40cefbd6c4.tar.gz matrix-4124346ba13bc6c07c3722a55e323b40cefbd6c4.tar.bz2 matrix-4124346ba13bc6c07c3722a55e323b40cefbd6c4.zip |
comments
Diffstat (limited to 'matrix-bin')
-rw-r--r-- | matrix-bin/src/helper.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/matrix-bin/src/helper.rs b/matrix-bin/src/helper.rs index df40946..a452218 100644 --- a/matrix-bin/src/helper.rs +++ b/matrix-bin/src/helper.rs @@ -27,7 +27,7 @@ impl Validator for MatrixHelper { loop { use TokenData as T; - let token = match lexer.next_token() { + let token = match lexer.next_token_cmt() { Ok(t) if t.data == T::Eof => break, Ok(t) => t, Err(err) => return Ok(ValidationResult::Invalid(Some(format!("{err}")))) @@ -64,6 +64,15 @@ impl Validator for MatrixHelper { Some(T::Try) => {}, _ => return unmatched!(token, T::Try) }, + T::Comment => { + let str = token.str.as_str(); + let l = str.len(); + if l >= 2 && &str[0..2] == "/*" { + if &str[l-2..l] != "*/" { + return Ok(ValidationResult::Incomplete) + } + } + } _ => {} }; } @@ -160,7 +169,7 @@ impl Highlighter for MatrixHelper { let mut buf = String::new(); let mut last = 0; loop { - let token = match lexer.next_token() { + let token = match lexer.next_token_cmt() { Ok(t) if t.data == T::Eof => break, Ok(t) => t, Err(_) => break @@ -216,6 +225,7 @@ impl Highlighter for MatrixHelper { T::Try | T::Catch => "\x1b[38;2;203;166;247m", + T::Comment => "\x1b[38;2;108;112;134m", _ => { buf += &token.str; continue; |