{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
module BNFC.Backend.Java 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 'TargetJava where
type BackendOptions 'TargetJava = JavaBackendOptions
type BackendState 'TargetJava = JavaBackendState
parseOpts :: Parser JavaBackendOptions
parseOpts :: Parser JavaBackendOptions
parseOpts = Parser JavaBackendOptions
forall a. HasCallStack => a
undefined
initState :: LBNF -> GlobalOptions -> BackendOptions 'TargetJava -> Except String (BackendState 'TargetJava)
initState :: LBNF
-> GlobalOptions
-> BackendOptions 'TargetJava
-> Except String (BackendState 'TargetJava)
initState = LBNF
-> GlobalOptions
-> BackendOptions 'TargetJava
-> Except String (BackendState 'TargetJava)
forall a. HasCallStack => a
undefined
abstractSyntax :: LBNF -> State (BackendState 'TargetJava) Result
abstractSyntax :: LBNF -> State (BackendState 'TargetJava) Result
abstractSyntax = LBNF -> State (BackendState 'TargetJava) Result
forall a. HasCallStack => a
undefined
printer :: LBNF -> State (BackendState 'TargetJava) Result
printer :: LBNF -> State (BackendState 'TargetJava) Result
printer = LBNF -> State (BackendState 'TargetJava) Result
forall a. HasCallStack => a
undefined
lexer :: LBNF -> State (BackendState 'TargetJava) Result
lexer :: LBNF -> State (BackendState 'TargetJava) Result
lexer = LBNF -> State (BackendState 'TargetJava) Result
forall a. HasCallStack => a
undefined
parser :: LBNF -> State (BackendState 'TargetJava) Result
parser :: LBNF -> State (BackendState 'TargetJava) Result
parser = LBNF -> State (BackendState 'TargetJava) Result
forall a. HasCallStack => a
undefined
parserTest :: LBNF -> State (BackendState 'TargetJava) Result
parserTest :: LBNF -> State (BackendState 'TargetJava) Result
parserTest = LBNF -> State (BackendState 'TargetJava) Result
forall a. HasCallStack => a
undefined
makefile :: LBNF -> State (BackendState 'TargetJava) Result
makefile :: LBNF -> State (BackendState 'TargetJava) Result
makefile = LBNF -> State (BackendState 'TargetJava) Result
forall a. HasCallStack => a
undefined
data JavaBackendOptions = JavaOpts
{ JavaBackendOptions -> Bool
lineNumbers :: Bool
, JavaBackendOptions -> Maybe String
nameSpace :: Maybe String
, JavaBackendOptions -> Bool
jlex :: Bool
, JavaBackendOptions -> Bool
jflex :: Bool
, JavaBackendOptions -> Bool
antlr4 :: Bool
}
javaOptionsParser :: Parser JavaBackendOptions
javaOptionsParser :: Parser JavaBackendOptions
javaOptionsParser = Bool -> Maybe String -> Bool -> Bool -> Bool -> JavaBackendOptions
JavaOpts
(Bool
-> Maybe String -> Bool -> Bool -> Bool -> JavaBackendOptions)
-> Parser Bool
-> Parser
(Maybe String -> Bool -> Bool -> Bool -> JavaBackendOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Bool
oLineNumbers
Parser (Maybe String -> Bool -> Bool -> Bool -> JavaBackendOptions)
-> Parser (Maybe String)
-> Parser (Bool -> Bool -> Bool -> JavaBackendOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe String)
oNameSpace
Parser (Bool -> Bool -> Bool -> JavaBackendOptions)
-> Parser Bool -> Parser (Bool -> Bool -> JavaBackendOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
oJLex
Parser (Bool -> Bool -> JavaBackendOptions)
-> Parser Bool -> Parser (Bool -> JavaBackendOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
oJFlex
Parser (Bool -> JavaBackendOptions)
-> Parser Bool -> Parser JavaBackendOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Bool
oAntlr4
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")
oJLex :: Parser Bool
oJLex =
Mod FlagFields Bool -> Parser Bool
switch
( String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"jlex"
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
"Lex with JLex, parse with CUP (default)" )
oJFlex :: Parser Bool
oJFlex =
Mod FlagFields Bool -> Parser Bool
switch
( String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"jflex"
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
"Lex with JFlex, parse with CUP" )
oAntlr4 :: Parser Bool
oAntlr4 =
Mod FlagFields Bool -> Parser Bool
switch
( String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"antlr4"
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
"Lex and parse with antlr4" )
data JavaBackendState