module BNFC.Backend.Agda.Test where

import BNFC.CF
import BNFC.Options.GlobalOptions
import BNFC.Prelude

import BNFC.Backend.Agda.Options
import BNFC.Backend.Agda.State
import BNFC.Backend.CommonInterface.Backend

import BNFC.Backend.Haskell.Options (TokenText (..))
import BNFC.Backend.Haskell.Test (cf2test)
import BNFC.Backend.Haskell.Utilities.Utils

import Control.Monad.State

import System.FilePath ( takeBaseName )

agdaParserTest :: LBNF -> State AgdaBackendState Result
agdaParserTest :: LBNF -> State AgdaBackendState Result
agdaParserTest LBNF
lbnf = do
  AgdaBackendState
st <- StateT AgdaBackendState Identity AgdaBackendState
forall s (m :: * -> *). MonadState s m => m s
get
  let
    cfName :: String
cfName      = String -> String
takeBaseName (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ GlobalOptions -> String
optInput (GlobalOptions -> String) -> GlobalOptions -> String
forall a b. (a -> b) -> a -> b
$ AgdaBackendState -> GlobalOptions
globalOpt AgdaBackendState
st
    inDirectory :: Bool
inDirectory = AgdaBackendOptions -> Bool
inDir (AgdaBackendOptions -> Bool) -> AgdaBackendOptions -> Bool
forall a b. (a -> b) -> a -> b
$ AgdaBackendState -> AgdaBackendOptions
agdaOpts AgdaBackendState
st
    nSpace :: Maybe String
nSpace      = AgdaBackendOptions -> Maybe String
nameSpace (AgdaBackendOptions -> Maybe String)
-> AgdaBackendOptions -> Maybe String
forall a b. (a -> b) -> a -> b
$ AgdaBackendState -> AgdaBackendOptions
agdaOpts AgdaBackendState
st
    test :: String
test        = LBNF -> String -> TokenText -> Bool -> Maybe String -> String
cf2test LBNF
lbnf String
cfName TokenText
TextToken Bool
inDirectory Maybe String
nSpace
  Result -> State AgdaBackendState Result
forall (m :: * -> *) a. Monad m => a -> m a
return [(Bool -> Maybe String -> String -> String -> String -> String
mkFilePath Bool
inDirectory Maybe String
nSpace String
cfName String
"Test" String
"hs", String
test)]