Skip to content

Commit 0d4af2a

Browse files
authored
Merge pull request #850 from laurynas-biveinis/fix-lisp-comment-style
fix(tokenizer): recognize ';' line comments for lisp/clojure/scheme/racket
2 parents a29fe3b + e5056b2 commit 0d4af2a

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

rust/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/crates/cpd-tokenizer/src/generic.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ fn comment_style(format: &str) -> CommentStyle {
4040

4141
"lua" => CommentStyle::Lua,
4242

43-
"ini" | "properties" | "asm6502" | "nasm" => CommentStyle::Semicolon,
43+
"ini" | "properties" | "asm6502" | "nasm" | "lisp" | "clojure" | "scheme" | "racket" => {
44+
CommentStyle::Semicolon
45+
}
4446

4547
"vb" | "vbs" | "basic" | "vbnet" | "visual-basic" => CommentStyle::VisualBasic,
4648

@@ -400,6 +402,15 @@ mod tests {
400402
assert!(has_comment, "Python # comments must be Comment kind");
401403
}
402404

405+
#[test]
406+
fn lisp_family_semicolon_comment_marked_as_comment() {
407+
for format in ["lisp", "clojure", "scheme", "racket"] {
408+
let tokens = tokenize_generic(";; a comment\n(def x 1)\n", format);
409+
let has_comment = tokens.iter().any(|t| t.kind == TokenKind::Comment);
410+
assert!(has_comment, "{format} ; comments must be Comment kind");
411+
}
412+
}
413+
403414
#[test]
404415
fn go_c_style_comment_recognized() {
405416
let tokens = tokenize_generic("// hello\nfunc main() {}\n", "go");

0 commit comments

Comments
 (0)