{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
module BNFC.Backend.CPP where
import BNFC.Prelude
import Control.Monad.Except
import Control.Monad.State
#if !MIN_VERSION_base(4,13,0)
import Control.Applicative ((<*>))
#endif
import Options.Applicative
import BNFC.CF
import BNFC.Options.GlobalOptions
import BNFC.Options.Target
import BNFC.Backend.CommonInterface.Backend
instance Backend 'TargetCpp where
type BackendOptions 'TargetCpp = CppBackendOptions
type BackendState 'TargetCpp = CppBackendState
parseOpts :: Parser CppBackendOptions
parseOpts :: Parser CppBackendOptions
parseOpts = Parser CppBackendOptions
forall a. HasCallStack => a
undefined
initState :: LBNF -> GlobalOptions -> BackendOptions 'TargetCpp -> Except String (BackendState 'TargetCpp)
initState :: LBNF
-> GlobalOptions
-> BackendOptions 'TargetCpp
-> Except String (BackendState 'TargetCpp)
initState = LBNF
-> GlobalOptions
-> BackendOptions 'TargetCpp
-> Except String (BackendState 'TargetCpp)
forall a. HasCallStack => a
undefined
abstractSyntax :: LBNF -> State (BackendState 'TargetCpp) Result
abstractSyntax :: LBNF -> State (BackendState 'TargetCpp) Result
abstractSyntax = LBNF -> State (BackendState 'TargetCpp) Result
forall a. HasCallStack => a
undefined
printer :: LBNF -> State (BackendState 'TargetCpp) Result
printer :: LBNF -> State (BackendState 'TargetCpp) Result
printer = LBNF -> State (BackendState 'TargetCpp) Result
forall a. HasCallStack => a
undefined
lexer :: LBNF -> State (BackendState 'TargetCpp) Result
lexer :: LBNF -> State (BackendState 'TargetCpp) Result
lexer = LBNF -> State (BackendState 'TargetCpp) Result
forall a. HasCallStack => a
undefined
parser :: LBNF -> State (BackendState 'TargetCpp) Result
parser :: LBNF -> State (BackendState 'TargetCpp) Result
parser = LBNF -> State (BackendState 'TargetCpp) Result
forall a. HasCallStack => a
undefined
parserTest :: LBNF -> State (BackendState 'TargetCpp) Result
parserTest :: LBNF -> State (BackendState 'TargetCpp) Result
parserTest = LBNF -> State (BackendState 'TargetCpp) Result
forall a. HasCallStack => a
undefined
makefile :: LBNF -> State (BackendState 'TargetCpp) Result
makefile :: LBNF -> State (BackendState 'TargetCpp) Result
makefile = LBNF -> State (BackendState 'TargetCpp) Result
forall a. HasCallStack => a
undefined
data CppBackendOptions = CppOpts
{ CppBackendOptions -> Bool
lineNumbers :: Bool
, CppBackendOptions -> Maybe String
nameSpace :: Maybe String
}
cppOptionsParser :: Parser CppBackendOptions
cppOptionsParser :: Parser CppBackendOptions
cppOptionsParser = Bool -> Maybe String -> CppBackendOptions
CppOpts (Bool -> Maybe String -> CppBackendOptions)
-> Parser Bool -> Parser (Maybe String -> CppBackendOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Bool
oLineNumbers Parser (Maybe String -> CppBackendOptions)
-> Parser (Maybe String) -> Parser CppBackendOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe String)
oNameSpace
where
oLineNumbers :: Parser Bool
oLineNumbers =
Mod FlagFields Bool -> Parser Bool
switch
( Char -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'l'
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"line-numbers"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Add and set line_number field for all syntax classes" )
oNameSpace :: Parser (Maybe String)
oNameSpace =
Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Parser String -> Parser (Maybe String))
-> Parser String -> Parser (Maybe String)
forall a b. (a -> b) -> a -> b
$
Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( Char -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'p'
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"name-space"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Prepend NAMESPACE to the package/module name"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"NAMESPACE")
data CppBackendState