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 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 -- -- @supersedes add-support-for-all-tree-grepper-supported-files 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"]