From 0d20548e3846cb80acca07fad2a1dc3cfe024528 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Fri, 8 Dec 2023 06:27:15 +0100 Subject: chore: drop tree-grepper Regresses in that we only support Haskell for now, as Elm, Nix or Bash are not available as tree-sitter-* Haskell packages. --- app/Comment/Language.hs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 app/Comment/Language.hs (limited to 'app/Comment') diff --git a/app/Comment/Language.hs b/app/Comment/Language.hs new file mode 100644 index 0000000..009c6e6 --- /dev/null +++ b/app/Comment/Language.hs @@ -0,0 +1,39 @@ +module Comment.Language + ( Language (..), + fromExtension, + parser, + lineStart, + block, + nodeTypes, + ) +where + +import Control.Exception (throw) +import Data.Binary (Binary) +import Data.Text qualified as T +import Exception qualified as E +import Foreign.Ptr (Ptr) +import GHC.Generics (Generic) +import TreeSitter.Haskell qualified as S +import TreeSitter.Language qualified as S + +data Language + = Haskell + deriving (Eq, Show, Generic, Binary) + +fromExtension :: String -> Language +fromExtension ".hs" = Haskell +fromExtension ext = throw $ E.UnknownFileExtension ext + +-- TODO add languages elm, shell, nix +parser :: Language -> Ptr S.Language +parser Haskell = S.tree_sitter_haskell + +lineStart :: Language -> T.Text +lineStart Haskell = "--" + +block :: Language -> Maybe ([T.Text], T.Text) +block Haskell = Just (["{-"], "-}") + +nodeTypes :: Language -> [String] +nodeTypes Haskell = ["comment"] -- cgit v1.2.3