diff --git a/CHANGELOG.md b/CHANGELOG.md index 2626cd7..ea3bd11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#1609](https://github.com/ianlewis/todos/issues/1609)). - Support was added for [Dart](https://dart.dev/) ([#1612](https://github.com/ianlewis/todos/issues/1612)). +- Support was added for [OCaml](https://ocaml.org/) + ([#1610](https://github.com/ianlewis/todos/issues/1610)). ## [0.10.0] - 2024-10-31 diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md index 13f21be..0f60ffb 100644 --- a/SUPPORTED_LANGUAGES.md +++ b/SUPPORTED_LANGUAGES.md @@ -35,6 +35,7 @@ | MATLAB | `.matlab`, `.m` | `%`, `%{ }%` | | Makefile | `.mak`, `.d`, `.make`, `.makefile`, `.mk`, `.mkfile` | `#` | | Markdown | `.md`, `.livemd`, `.markdown`, `.mdown`, `.mdwn`, `.mkd`, `.mkdn`, `.mkdown`, `.ronn`, `.scd`, `.workbook` | `` | +| OCaml | `.ml`, `.eliom`, `.eliomi`, `.ml4`, `.mli`, `.mll`, `.mly` | `(* *)` | | Objective-C | `.m`, `.h` | `//`, `/* */` | | PHP | `.php`, `.aw`, `.ctp`, `.fcgi`, `.inc`, `.php3`, `.php4`, `.php5`, `.phps`, `.phpt` | `#`, `//`, `/* */` | | Pascal | `.pas`, `.dfm`, `.dpr`, `.inc`, `.lpr`, `.pascal`, `.pp` | `//`, `(* *)`, `{ }` | diff --git a/internal/scanner/languages.go b/internal/scanner/languages.go index 3c0f9b3..77301cb 100644 --- a/internal/scanner/languages.go +++ b/internal/scanner/languages.go @@ -427,6 +427,17 @@ var LanguagesConfig = map[string]*Config{ MultilineComments: cBlockComments, Strings: cStrings, }, + "OCaml": { + // TODO(#1627): Support OCaml nested comments. + MultilineComments: []MultilineCommentConfig{ + { + Start: []rune("(*"), + End: []rune("*)"), + }, + }, + // TODO(#1627): Support OCaml quoted string literals. + Strings: cStrings, + }, "Pascal": { LineComments: cLineComments, // Delphi comments MultilineComments: []MultilineCommentConfig{ diff --git a/internal/scanner/scanner_test.go b/internal/scanner/scanner_test.go index be9a7fe..2a547d6 100644 --- a/internal/scanner/scanner_test.go +++ b/internal/scanner/scanner_test.go @@ -2080,6 +2080,62 @@ This is more text. }, }, + // OCaml + { + name: "comments.ml", + src: `(* single line comment *) + +(* multiple line comment, commenting out part of a program, and containing a +nested comment: +let f = function + | 'A'..'Z' -> "Uppercase" +*)`, + config: "OCaml", + comments: []struct { + text string + line int + }{ + { + text: "(* single line comment *)", + line: 1, + }, + { + text: `(* multiple line comment, commenting out part of a program, and containing a +nested comment: +let f = function + | 'A'..'Z' -> "Uppercase" +*)`, + line: 3, + }, + }, + }, + + // TODO(#1627): Support OCaml nested comments. + // { + // name: "nested_comments.ml", + // src: `(* multiple line comment, commenting out part of a program, and containing a + // nested comment: + // let f = function + // | 'A'..'Z' -> "Uppercase" + // (* Add other cases later... *) + // *)`, + // config: "OCaml", + // comments: []struct { + // text string + // line int + // }{ + // { + // text: `(* multiple line comment, commenting out part of a program, and containing a + // nested comment: + // let f = function + // | 'A'..'Z' -> "Uppercase" + // (* Add other cases later... *) + // *)`, + // line: 1, + // }, + // }, + // }, + // Python { name: "raw_string.py", @@ -3153,6 +3209,19 @@ var loaderTestCases = []struct { expectedConfig: "Go", }, + // OCaml + { + name: "oca.ml", + src: []byte(`(* this is a comment *) + +print_endline "hello world" + +let () = print_endline "hello world" +`), + scanCharset: "UTF-8", + expectedConfig: "OCaml", + }, + // XML { name: "block_comments.xml",