{-# LANGUAGE Safe #-}
module Text.Parsec.Language
( haskellDef, haskell
, mondrianDef, mondrian
, emptyDef
, haskellStyle
, javaStyle
, LanguageDef
, GenLanguageDef
) where
import Text.Parsec
import Text.Parsec.Token
haskellStyle :: LanguageDef st
haskellStyle :: forall st. LanguageDef st
haskellStyle = LanguageDef Any
forall st. LanguageDef st
emptyDef
{ commentStart :: String
commentStart = String
"{-"
, commentEnd :: String
commentEnd = String
"-}"
, commentLine :: String
commentLine = String
"--"
, nestedComments :: Bool
nestedComments = Bool
True
, identStart :: ParsecT String st Identity Char
identStart = ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter
, identLetter :: ParsecT String st Identity Char
identLetter = ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum ParsecT String st Identity Char
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
"_'"
, opStart :: ParsecT String st Identity Char
opStart = GenLanguageDef String st Identity
-> ParsecT String st Identity Char
forall s u (m :: * -> *).
GenLanguageDef s u m -> ParsecT s u m Char
opLetter GenLanguageDef String st Identity
forall st. LanguageDef st
haskellStyle
, opLetter :: ParsecT String st Identity Char
opLetter = String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
":!#$%&*+./<=>?@\\^|-~"
, reservedOpNames :: [String]
reservedOpNames= []
, reservedNames :: [String]
reservedNames = []
, caseSensitive :: Bool
caseSensitive = Bool
True
}
javaStyle :: LanguageDef st
javaStyle :: forall st. LanguageDef st
javaStyle = LanguageDef st
forall st. LanguageDef st
emptyDef
{ commentStart :: String
commentStart = String
"/*"
, commentEnd :: String
commentEnd = String
"*/"
, commentLine :: String
commentLine = String
"//"
, nestedComments :: Bool
nestedComments = Bool
True
, identStart :: ParsecT String st Identity Char
identStart = ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter
, identLetter :: ParsecT String st Identity Char
identLetter = ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum ParsecT String st Identity Char
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
"_'"
, reservedNames :: [String]
reservedNames = []
, reservedOpNames :: [String]
reservedOpNames= []
, caseSensitive :: Bool
caseSensitive = Bool
False
}
emptyDef :: LanguageDef st
emptyDef :: forall st. LanguageDef st
emptyDef = LanguageDef :: forall s u (m :: * -> *).
String
-> String
-> String
-> Bool
-> ParsecT s u m Char
-> ParsecT s u m Char
-> ParsecT s u m Char
-> ParsecT s u m Char
-> [String]
-> [String]
-> Bool
-> GenLanguageDef s u m
LanguageDef
{ commentStart :: String
commentStart = String
""
, commentEnd :: String
commentEnd = String
""
, commentLine :: String
commentLine = String
""
, nestedComments :: Bool
nestedComments = Bool
True
, identStart :: ParsecT String st Identity Char
identStart = ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
letter ParsecT String st Identity Char
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'_'
, identLetter :: ParsecT String st Identity Char
identLetter = ParsecT String st Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum ParsecT String st Identity Char
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
"_'"
, opStart :: ParsecT String st Identity Char
opStart = GenLanguageDef String st Identity
-> ParsecT String st Identity Char
forall s u (m :: * -> *).
GenLanguageDef s u m -> ParsecT s u m Char
opLetter GenLanguageDef String st Identity
forall st. LanguageDef st
emptyDef
, opLetter :: ParsecT String st Identity Char
opLetter = String -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
oneOf String
":!#$%&*+./<=>?@\\^|-~"
, reservedOpNames :: [String]
reservedOpNames= []
, reservedNames :: [String]
reservedNames = []
, caseSensitive :: Bool
caseSensitive = Bool
True
}
haskell :: TokenParser st
haskell :: forall st. TokenParser st
haskell = GenLanguageDef String st Identity
-> GenTokenParser String st Identity
forall s (m :: * -> *) u.
Stream s m Char =>
GenLanguageDef s u m -> GenTokenParser s u m
makeTokenParser GenLanguageDef String st Identity
forall st. LanguageDef st
haskellDef
haskellDef :: LanguageDef st
haskellDef :: forall st. LanguageDef st
haskellDef = LanguageDef st
forall st. LanguageDef st
haskell98Def
{ identLetter :: ParsecT String st Identity Char
identLetter = LanguageDef st -> ParsecT String st Identity Char
forall s u (m :: * -> *).
GenLanguageDef s u m -> ParsecT s u m Char
identLetter LanguageDef st
forall st. LanguageDef st
haskell98Def ParsecT String st Identity Char
-> ParsecT String st Identity Char
-> ParsecT String st Identity Char
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Char -> ParsecT String st Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'#'
, reservedNames :: [String]
reservedNames = LanguageDef Any -> [String]
forall s u (m :: * -> *). GenLanguageDef s u m -> [String]
reservedNames LanguageDef Any
forall st. LanguageDef st
haskell98Def [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++
[String
"foreign",String
"import",String
"export",String
"primitive"
,String
"_ccall_",String
"_casm_"
,String
"forall"
]
}
haskell98Def :: LanguageDef st
haskell98Def :: forall st. LanguageDef st
haskell98Def = LanguageDef st
forall st. LanguageDef st
haskellStyle
{ reservedOpNames :: [String]
reservedOpNames= [String
"::",String
"..",String
"=",String
"\\",String
"|",String
"<-",String
"->",String
"@",String
"~",String
"=>"]
, reservedNames :: [String]
reservedNames = [String
"let",String
"in",String
"case",String
"of",String
"if",String
"then",String
"else",
String
"data",String
"type",
String
"class",String
"default",String
"deriving",String
"do",String
"import",
String
"infix",String
"infixl",String
"infixr",String
"instance",String
"module",
String
"newtype",String
"where",
String
"primitive"
]
}
mondrian :: TokenParser st
mondrian :: forall st. TokenParser st
mondrian = GenLanguageDef String st Identity
-> GenTokenParser String st Identity
forall s (m :: * -> *) u.
Stream s m Char =>
GenLanguageDef s u m -> GenTokenParser s u m
makeTokenParser GenLanguageDef String st Identity
forall st. LanguageDef st
mondrianDef
mondrianDef :: LanguageDef st
mondrianDef :: forall st. LanguageDef st
mondrianDef = LanguageDef st
forall st. LanguageDef st
javaStyle
{ reservedNames :: [String]
reservedNames = [ String
"case", String
"class", String
"default", String
"extends"
, String
"import", String
"in", String
"let", String
"new", String
"of", String
"package"
]
, caseSensitive :: Bool
caseSensitive = Bool
True
}