{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE QuasiQuotes       #-}

{-|
Module      : Headroom.FileSupport.Go
Description : Support for /Go/ source code files
Copyright   : (c) 2019-2021 Vaclav Svejcar
License     : BSD-3-Clause
Maintainer  : vaclav.svejcar@gmail.com
Stability   : experimental
Portability : POSIX

Basic support for /Go language/ source code files. This implementation doesn't
extract any variables or template data.
-}

module Headroom.FileSupport.Go
  ( fileSupport
  )
where

import           Headroom.Data.Regex                 ( isMatch
                                                     , re
                                                     )
import           Headroom.FileSupport.Types          ( FileSupport(..)
                                                     , SyntaxAnalysis(..)
                                                     , defaultFileSupport
                                                     )
import           Headroom.FileType.Types             ( FileType(Go) )


------------------------------  PUBLIC FUNCTIONS  ------------------------------

-- | Implementation of 'FileSupport' for /C/.
fileSupport :: FileSupport
fileSupport :: FileSupport
fileSupport = FileType -> SyntaxAnalysis -> FileSupport
defaultFileSupport FileType
Go SyntaxAnalysis
syntaxAnalysis


------------------------------  PRIVATE FUNCTIONS  -----------------------------

syntaxAnalysis :: SyntaxAnalysis
syntaxAnalysis :: SyntaxAnalysis
syntaxAnalysis = SyntaxAnalysis :: (Text -> Bool) -> (Text -> Bool) -> SyntaxAnalysis
SyntaxAnalysis { saIsCommentStart :: Text -> Bool
saIsCommentStart = Regex -> Text -> Bool
isMatch [re|^\/\*|^\/\/|]
                                , saIsCommentEnd :: Text -> Bool
saIsCommentEnd   = Regex -> Text -> Bool
isMatch [re|\*\/$|^\/\/|]
                                }