{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} module BNFC.Backend.Haskell where import BNFC.CF import BNFC.Prelude import BNFC.Options.GlobalOptions import BNFC.Options.Target import BNFC.Backend.CommonInterface.Backend import BNFC.Backend.Haskell.AbstractSyntax import BNFC.Backend.Haskell.GADT.AbstractSyntax import BNFC.Backend.Haskell.InitState import BNFC.Backend.Haskell.Lexer import BNFC.Backend.Haskell.Makefile import BNFC.Backend.Haskell.Options import BNFC.Backend.Haskell.Parser import BNFC.Backend.Haskell.Test import BNFC.Backend.Haskell.Printer import BNFC.Backend.Haskell.State import Control.Monad.Except import Control.Monad.State import Options.Applicative instance Backend 'TargetHaskell where type BackendOptions 'TargetHaskell = HaskellBackendOptions type BackendState 'TargetHaskell = HaskellBackendState parseOpts :: Parser HaskellBackendOptions parseOpts :: Parser HaskellBackendOptions parseOpts = Parser HaskellBackendOptions haskellOptionsParser initState :: LBNF -> GlobalOptions -> BackendOptions 'TargetHaskell -> Except String (BackendState 'TargetHaskell) initState :: LBNF -> GlobalOptions -> BackendOptions 'TargetHaskell -> Except String (BackendState 'TargetHaskell) initState = LBNF -> GlobalOptions -> HaskellBackendOptions -> Except String HaskellBackendState LBNF -> GlobalOptions -> BackendOptions 'TargetHaskell -> Except String (BackendState 'TargetHaskell) haskellInitState abstractSyntax :: LBNF -> State (BackendState 'TargetHaskell) Result abstractSyntax :: LBNF -> State (BackendState 'TargetHaskell) Result abstractSyntax LBNF lbnf = do HaskellBackendState st <- StateT HaskellBackendState Identity HaskellBackendState forall s (m :: * -> *). MonadState s m => m s get if HaskellBackendOptions -> Bool gadt (HaskellBackendOptions -> Bool) -> HaskellBackendOptions -> Bool forall a b. (a -> b) -> a -> b $ HaskellBackendState -> HaskellBackendOptions haskellOpts HaskellBackendState st then LBNF -> State HaskellBackendState Result haskellAbstractSyntaxGADT LBNF lbnf else LBNF -> State HaskellBackendState Result haskellAbstractSyntax LBNF lbnf printer :: LBNF -> State (BackendState 'TargetHaskell) Result printer :: LBNF -> State (BackendState 'TargetHaskell) Result printer = LBNF -> State (BackendState 'TargetHaskell) Result LBNF -> State HaskellBackendState Result haskellPrinter lexer :: LBNF -> State (BackendState 'TargetHaskell) Result lexer :: LBNF -> State (BackendState 'TargetHaskell) Result lexer = LBNF -> State (BackendState 'TargetHaskell) Result LBNF -> State HaskellBackendState Result haskellLexer parser :: LBNF -> State (BackendState 'TargetHaskell) Result parser :: LBNF -> State (BackendState 'TargetHaskell) Result parser = LBNF -> State (BackendState 'TargetHaskell) Result LBNF -> State HaskellBackendState Result haskellParser parserTest :: LBNF -> State (BackendState 'TargetHaskell) Result parserTest :: LBNF -> State (BackendState 'TargetHaskell) Result parserTest = LBNF -> State (BackendState 'TargetHaskell) Result LBNF -> State HaskellBackendState Result haskellParserTest makefile :: LBNF -> State (BackendState 'TargetHaskell) Result makefile :: LBNF -> State (BackendState 'TargetHaskell) Result makefile = LBNF -> State (BackendState 'TargetHaskell) Result LBNF -> State HaskellBackendState Result haskellmakefile