{-# LANGUAGE CPP #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveTraversable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Language.C.Types.Parse
(
TypeNames
, CParserContext(..)
, CIdentifier
, unCIdentifier
, cIdentifierFromString
, cCParserContext
, CParser
, runCParser
, quickCParser
, quickCParser_
, identifier_no_lex
, DeclarationSpecifier(..)
, declaration_specifiers
, StorageClassSpecifier(..)
, storage_class_specifier
, TypeSpecifier(..)
, type_specifier
, TypeQualifier(..)
, type_qualifier
, FunctionSpecifier(..)
, function_specifier
, Declarator(..)
, declarator
, DirectDeclarator(..)
, direct_declarator
, ArrayOrProto(..)
, array_or_proto
, ArrayType(..)
, array_type
, Pointer(..)
, pointer
, ParameterDeclaration(..)
, DeclaratorOrAbstractDeclarator(..)
, parameter_declaration
, parameter_list
, AbstractDeclarator(..)
, abstract_declarator
, DirectAbstractDeclarator(..)
, direct_abstract_declarator
, cIdentStart
, cIdentLetter
, cReservedWords
, isTypeName
) where
import Control.Applicative
import Control.Monad (msum, void, MonadPlus, unless, when)
import Control.Monad.Reader (MonadReader, runReaderT, ReaderT, asks, ask)
import Data.List (intersperse)
import Data.Functor.Identity (Identity)
import qualified Data.HashSet as HashSet
import Data.Hashable (Hashable)
import Data.Monoid ((<>))
import Data.String (IsString(..))
import Data.Typeable (Typeable)
import qualified Text.Parsec as Parsec
import Text.Parser.Char
import Text.Parser.Combinators
import Text.Parser.LookAhead
import Text.Parser.Token
import qualified Text.Parser.Token.Highlight as Highlight
import Prettyprinter (Pretty(..), (<+>), Doc, hsep)
import qualified Prettyprinter as PP
#if __GLASGOW_HASKELL__ < 710
import Data.Foldable (Foldable)
import Data.Traversable (Traversable)
#endif
type TypeNames = HashSet.HashSet CIdentifier
data CParserContext i = CParserContext
{ forall i. CParserContext i -> String
cpcIdentName :: String
, forall i. CParserContext i -> TypeNames
cpcTypeNames :: TypeNames
, forall i.
CParserContext i -> forall (m :: * -> *). CParser i m => m i
cpcParseIdent :: forall m. CParser i m => m i
, forall i. CParserContext i -> i -> String
cpcIdentToString :: i -> String
, forall i. CParserContext i -> Bool
cpcEnableCpp :: Bool
}
newtype CIdentifier = CIdentifier {CIdentifier -> String
unCIdentifier :: String}
deriving (Typeable, CIdentifier -> CIdentifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CIdentifier -> CIdentifier -> Bool
$c/= :: CIdentifier -> CIdentifier -> Bool
== :: CIdentifier -> CIdentifier -> Bool
$c== :: CIdentifier -> CIdentifier -> Bool
Eq, Eq CIdentifier
CIdentifier -> CIdentifier -> Bool
CIdentifier -> CIdentifier -> Ordering
CIdentifier -> CIdentifier -> CIdentifier
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CIdentifier -> CIdentifier -> CIdentifier
$cmin :: CIdentifier -> CIdentifier -> CIdentifier
max :: CIdentifier -> CIdentifier -> CIdentifier
$cmax :: CIdentifier -> CIdentifier -> CIdentifier
>= :: CIdentifier -> CIdentifier -> Bool
$c>= :: CIdentifier -> CIdentifier -> Bool
> :: CIdentifier -> CIdentifier -> Bool
$c> :: CIdentifier -> CIdentifier -> Bool
<= :: CIdentifier -> CIdentifier -> Bool
$c<= :: CIdentifier -> CIdentifier -> Bool
< :: CIdentifier -> CIdentifier -> Bool
$c< :: CIdentifier -> CIdentifier -> Bool
compare :: CIdentifier -> CIdentifier -> Ordering
$ccompare :: CIdentifier -> CIdentifier -> Ordering
Ord, Int -> CIdentifier -> String -> String
[CIdentifier] -> String -> String
CIdentifier -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [CIdentifier] -> String -> String
$cshowList :: [CIdentifier] -> String -> String
show :: CIdentifier -> String
$cshow :: CIdentifier -> String
showsPrec :: Int -> CIdentifier -> String -> String
$cshowsPrec :: Int -> CIdentifier -> String -> String
Show, Eq CIdentifier
Int -> CIdentifier -> Int
CIdentifier -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: CIdentifier -> Int
$chash :: CIdentifier -> Int
hashWithSalt :: Int -> CIdentifier -> Int
$chashWithSalt :: Int -> CIdentifier -> Int
Hashable)
cIdentifierFromString :: Bool -> String -> Either String CIdentifier
cIdentifierFromString :: Bool -> String -> Either String CIdentifier
cIdentifierFromString Bool
useCpp String
s =
case forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
Parsec.parse (forall (m :: * -> *) s.
(TokenParsing m, Monad m, IsString s) =>
Bool -> IdentifierStyle m -> m s
identNoLex Bool
useCpp forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (m :: * -> *). Parsing m => m ()
eof) String
"cIdentifierFromString" String
s of
Left ParseError
err -> forall a b. a -> Either a b
Left forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show ParseError
err
Right String
x -> forall a b. b -> Either a b
Right forall a b. (a -> b) -> a -> b
$ String -> CIdentifier
CIdentifier String
x
instance IsString CIdentifier where
fromString :: String -> CIdentifier
fromString String
s =
case Bool -> String -> Either String CIdentifier
cIdentifierFromString Bool
True String
s of
Left String
err -> forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"CIdentifier fromString: invalid string " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
s forall a. [a] -> [a] -> [a]
++ String
"\n" forall a. [a] -> [a] -> [a]
++ String
err
Right CIdentifier
x -> CIdentifier
x
cCParserContext :: Bool -> TypeNames -> CParserContext CIdentifier
cCParserContext :: Bool -> TypeNames -> CParserContext CIdentifier
cCParserContext Bool
useCpp TypeNames
typeNames = CParserContext
{ cpcTypeNames :: TypeNames
cpcTypeNames = TypeNames
typeNames
, cpcParseIdent :: forall (m :: * -> *). CParser CIdentifier m => m CIdentifier
cpcParseIdent = forall i (m :: * -> *). CParser i m => m CIdentifier
cidentifier_no_lex
, cpcIdentToString :: CIdentifier -> String
cpcIdentToString = CIdentifier -> String
unCIdentifier
, cpcIdentName :: String
cpcIdentName = String
"C identifier"
, cpcEnableCpp :: Bool
cpcEnableCpp = Bool
useCpp
}
type CParser i m =
( Monad m
, Functor m
, Applicative m
, MonadPlus m
, Parsing m
, CharParsing m
, TokenParsing m
, LookAheadParsing m
, MonadReader (CParserContext i) m
#if (MIN_VERSION_base(4,13,0))
, MonadFail m
#endif
, Hashable i
)
runCParser
:: Parsec.Stream s Identity Char
=> CParserContext i
-> String
-> s
-> (ReaderT (CParserContext i) (Parsec.Parsec s ()) a)
-> Either Parsec.ParseError a
runCParser :: forall s i a.
Stream s Identity Char =>
CParserContext i
-> String
-> s
-> ReaderT (CParserContext i) (Parsec s ()) a
-> Either ParseError a
runCParser CParserContext i
typeNames String
fn s
s ReaderT (CParserContext i) (Parsec s ()) a
p = forall s t a.
Stream s Identity t =>
Parsec s () a -> String -> s -> Either ParseError a
Parsec.parse (forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT ReaderT (CParserContext i) (Parsec s ()) a
p CParserContext i
typeNames) String
fn s
s
quickCParser
:: CParserContext i
-> String
-> (ReaderT (CParserContext i) (Parsec.Parsec String ()) a)
-> a
quickCParser :: forall i a.
CParserContext i
-> String
-> ReaderT (CParserContext i) (ParsecT String () Identity) a
-> a
quickCParser CParserContext i
typeNames String
s ReaderT (CParserContext i) (ParsecT String () Identity) a
p = case forall s i a.
Stream s Identity Char =>
CParserContext i
-> String
-> s
-> ReaderT (CParserContext i) (Parsec s ()) a
-> Either ParseError a
runCParser CParserContext i
typeNames String
"quickCParser" String
s ReaderT (CParserContext i) (ParsecT String () Identity) a
p of
Left ParseError
err -> forall a. HasCallStack => String -> a
error forall a b. (a -> b) -> a -> b
$ String
"quickCParser: " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show ParseError
err
Right a
x -> a
x
quickCParser_
:: Bool
-> String
-> (ReaderT (CParserContext CIdentifier) (Parsec.Parsec String ()) a)
-> a
quickCParser_ :: forall a.
Bool
-> String
-> ReaderT
(CParserContext CIdentifier) (ParsecT String () Identity) a
-> a
quickCParser_ Bool
useCpp = forall i a.
CParserContext i
-> String
-> ReaderT (CParserContext i) (ParsecT String () Identity) a
-> a
quickCParser (Bool -> TypeNames -> CParserContext CIdentifier
cCParserContext Bool
useCpp forall a. HashSet a
HashSet.empty)
cReservedWords :: HashSet.HashSet String
cReservedWords :: HashSet String
cReservedWords = forall a. (Eq a, Hashable a) => [a] -> HashSet a
HashSet.fromList
[ String
"auto", String
"else", String
"long", String
"switch"
, String
"break", String
"enum", String
"register", String
"typedef"
, String
"case", String
"extern", String
"return", String
"union"
, String
"char", String
"float", String
"short", String
"unsigned"
, String
"const", String
"for", String
"signed", String
"void"
, String
"continue", String
"goto", String
"sizeof", String
"volatile"
, String
"default", String
"if", String
"static", String
"while"
, String
"do", String
"int", String
"struct", String
"double"
]
cIdentStart :: [Char]
cIdentStart :: String
cIdentStart = [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] forall a. [a] -> [a] -> [a]
++ [Char
'_']
cIdentLetter :: [Char]
cIdentLetter :: String
cIdentLetter = [Char
'a'..Char
'z'] forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] forall a. [a] -> [a] -> [a]
++ [Char
'_'] forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9']
cIdentStyle :: (TokenParsing m, Monad m) => IdentifierStyle m
cIdentStyle :: forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle = IdentifierStyle
{ _styleName :: String
_styleName = String
"C identifier"
, _styleStart :: m Char
_styleStart = forall (m :: * -> *). CharParsing m => String -> m Char
oneOf String
cIdentStart
, _styleLetter :: m Char
_styleLetter = forall (m :: * -> *). CharParsing m => String -> m Char
oneOf String
cIdentLetter
, _styleReserved :: HashSet String
_styleReserved = HashSet String
cReservedWords
, _styleHighlight :: Highlight
_styleHighlight = Highlight
Highlight.Identifier
, _styleReservedHighlight :: Highlight
_styleReservedHighlight = Highlight
Highlight.ReservedIdentifier
}
data DeclarationSpecifier
= StorageClassSpecifier StorageClassSpecifier
| TypeSpecifier TypeSpecifier
| TypeQualifier TypeQualifier
| FunctionSpecifier FunctionSpecifier
deriving (Typeable, DeclarationSpecifier -> DeclarationSpecifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeclarationSpecifier -> DeclarationSpecifier -> Bool
$c/= :: DeclarationSpecifier -> DeclarationSpecifier -> Bool
== :: DeclarationSpecifier -> DeclarationSpecifier -> Bool
$c== :: DeclarationSpecifier -> DeclarationSpecifier -> Bool
Eq, Int -> DeclarationSpecifier -> String -> String
[DeclarationSpecifier] -> String -> String
DeclarationSpecifier -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [DeclarationSpecifier] -> String -> String
$cshowList :: [DeclarationSpecifier] -> String -> String
show :: DeclarationSpecifier -> String
$cshow :: DeclarationSpecifier -> String
showsPrec :: Int -> DeclarationSpecifier -> String -> String
$cshowsPrec :: Int -> DeclarationSpecifier -> String -> String
Show)
declaration_specifiers :: CParser i m => m [DeclarationSpecifier]
declaration_specifiers :: forall i (m :: * -> *). CParser i m => m [DeclarationSpecifier]
declaration_specifiers = forall i (m :: * -> *) a. CParser i m => m a -> m [a]
many1 forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ StorageClassSpecifier -> DeclarationSpecifier
StorageClassSpecifier forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m StorageClassSpecifier
storage_class_specifier
, TypeSpecifier -> DeclarationSpecifier
TypeSpecifier forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m TypeSpecifier
type_specifier
, TypeQualifier -> DeclarationSpecifier
TypeQualifier forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m TypeQualifier
type_qualifier
, FunctionSpecifier -> DeclarationSpecifier
FunctionSpecifier forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m FunctionSpecifier
function_specifier
]
data StorageClassSpecifier
= TYPEDEF
| EXTERN
| STATIC
| AUTO
| REGISTER
deriving (Typeable, StorageClassSpecifier -> StorageClassSpecifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StorageClassSpecifier -> StorageClassSpecifier -> Bool
$c/= :: StorageClassSpecifier -> StorageClassSpecifier -> Bool
== :: StorageClassSpecifier -> StorageClassSpecifier -> Bool
$c== :: StorageClassSpecifier -> StorageClassSpecifier -> Bool
Eq, Int -> StorageClassSpecifier -> String -> String
[StorageClassSpecifier] -> String -> String
StorageClassSpecifier -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [StorageClassSpecifier] -> String -> String
$cshowList :: [StorageClassSpecifier] -> String -> String
show :: StorageClassSpecifier -> String
$cshow :: StorageClassSpecifier -> String
showsPrec :: Int -> StorageClassSpecifier -> String -> String
$cshowsPrec :: Int -> StorageClassSpecifier -> String -> String
Show)
storage_class_specifier :: CParser i m => m StorageClassSpecifier
storage_class_specifier :: forall i (m :: * -> *). CParser i m => m StorageClassSpecifier
storage_class_specifier = forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ StorageClassSpecifier
TYPEDEF forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"typedef"
, StorageClassSpecifier
EXTERN forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"extern"
, StorageClassSpecifier
STATIC forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"static"
, StorageClassSpecifier
AUTO forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"auto"
, StorageClassSpecifier
REGISTER forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"register"
]
data TypeSpecifier
= VOID
| BOOL
| CHAR
| SHORT
| INT
| LONG
| FLOAT
| DOUBLE
| SIGNED
| UNSIGNED
| Struct CIdentifier
| Enum CIdentifier
| TypeName CIdentifier
| Template CIdentifier [[TypeSpecifier]]
| TemplateConst String
| TemplatePointer TypeSpecifier
deriving (Typeable, TypeSpecifier -> TypeSpecifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypeSpecifier -> TypeSpecifier -> Bool
$c/= :: TypeSpecifier -> TypeSpecifier -> Bool
== :: TypeSpecifier -> TypeSpecifier -> Bool
$c== :: TypeSpecifier -> TypeSpecifier -> Bool
Eq, Int -> TypeSpecifier -> String -> String
[TypeSpecifier] -> String -> String
TypeSpecifier -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [TypeSpecifier] -> String -> String
$cshowList :: [TypeSpecifier] -> String -> String
show :: TypeSpecifier -> String
$cshow :: TypeSpecifier -> String
showsPrec :: Int -> TypeSpecifier -> String -> String
$cshowsPrec :: Int -> TypeSpecifier -> String -> String
Show)
type_specifier :: CParser i m => m TypeSpecifier
type_specifier :: forall i (m :: * -> *). CParser i m => m TypeSpecifier
type_specifier = forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ TypeSpecifier
VOID forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"void"
, TypeSpecifier
BOOL forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"bool"
, TypeSpecifier
CHAR forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"char"
, TypeSpecifier
SHORT forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"short"
, TypeSpecifier
INT forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"int"
, TypeSpecifier
LONG forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"long"
, TypeSpecifier
FLOAT forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"float"
, TypeSpecifier
DOUBLE forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"double"
, TypeSpecifier
SIGNED forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"signed"
, TypeSpecifier
UNSIGNED forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"unsigned"
, CIdentifier -> TypeSpecifier
Struct forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"struct" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall i (m :: * -> *). CParser i m => m CIdentifier
cidentifier)
, CIdentifier -> TypeSpecifier
Enum forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"enum" forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall i (m :: * -> *). CParser i m => m CIdentifier
cidentifier)
, forall i (m :: * -> *). CParser i m => m TypeSpecifier
template_parser
, CIdentifier -> TypeSpecifier
TypeName forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m CIdentifier
type_name
]
identifier :: CParser i m => m i
identifier :: forall i (m :: * -> *). CParser i m => m i
identifier = forall (m :: * -> *) a. TokenParsing m => m a -> m a
token forall i (m :: * -> *). CParser i m => m i
identifier_no_lex
isTypeName :: Bool -> TypeNames -> String -> Bool
isTypeName :: Bool -> TypeNames -> String -> Bool
isTypeName Bool
useCpp TypeNames
typeNames String
id_ =
case Bool -> String -> Either String CIdentifier
cIdentifierFromString Bool
useCpp String
id_ of
Left String
_err -> Bool
False
Right CIdentifier
s -> forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
HashSet.member CIdentifier
s TypeNames
typeNames
identifier_no_lex :: CParser i m => m i
identifier_no_lex :: forall i (m :: * -> *). CParser i m => m i
identifier_no_lex = forall (m :: * -> *) a. Parsing m => m a -> m a
try forall a b. (a -> b) -> a -> b
$ do
CParserContext i
ctx <- forall r (m :: * -> *). MonadReader r m => m r
ask
i
id_ <- forall i.
CParserContext i -> forall (m :: * -> *). CParser i m => m i
cpcParseIdent CParserContext i
ctx forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> forall i. CParserContext i -> String
cpcIdentName CParserContext i
ctx
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> TypeNames -> String -> Bool
isTypeName (forall i. CParserContext i -> Bool
cpcEnableCpp CParserContext i
ctx) (forall i. CParserContext i -> TypeNames
cpcTypeNames CParserContext i
ctx) (forall i. CParserContext i -> i -> String
cpcIdentToString CParserContext i
ctx i
id_)) forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected forall a b. (a -> b) -> a -> b
$ String
"type name " forall a. [a] -> [a] -> [a]
++ forall i. CParserContext i -> i -> String
cpcIdentToString CParserContext i
ctx i
id_
forall (m :: * -> *) a. Monad m => a -> m a
return i
id_
cidentifier_raw :: (TokenParsing m, Monad m) => Bool -> m CIdentifier
cidentifier_raw :: forall (m :: * -> *).
(TokenParsing m, Monad m) =>
Bool -> m CIdentifier
cidentifier_raw Bool
useCpp = forall (m :: * -> *) s.
(TokenParsing m, Monad m, IsString s) =>
Bool -> IdentifierStyle m -> m s
identNoLex Bool
useCpp forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle
cidentifier_no_lex :: CParser i m => m CIdentifier
cidentifier_no_lex :: forall i (m :: * -> *). CParser i m => m CIdentifier
cidentifier_no_lex = forall (m :: * -> *) a. Parsing m => m a -> m a
try forall a b. (a -> b) -> a -> b
$ do
CParserContext i
ctx <- forall r (m :: * -> *). MonadReader r m => m r
ask
CIdentifier
s <- forall (m :: * -> *).
(TokenParsing m, Monad m) =>
Bool -> m CIdentifier
cidentifier_raw (forall i. CParserContext i -> Bool
cpcEnableCpp CParserContext i
ctx)
TypeNames
typeNames <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks forall i. CParserContext i -> TypeNames
cpcTypeNames
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
HashSet.member CIdentifier
s TypeNames
typeNames) forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected forall a b. (a -> b) -> a -> b
$ String
"type name " forall a. [a] -> [a] -> [a]
++ CIdentifier -> String
unCIdentifier CIdentifier
s
forall (m :: * -> *) a. Monad m => a -> m a
return CIdentifier
s
cidentifier :: CParser i m => m CIdentifier
cidentifier :: forall i (m :: * -> *). CParser i m => m CIdentifier
cidentifier = forall (m :: * -> *) a. TokenParsing m => m a -> m a
token forall i (m :: * -> *). CParser i m => m CIdentifier
cidentifier_no_lex
type_name :: CParser i m => m CIdentifier
type_name :: forall i (m :: * -> *). CParser i m => m CIdentifier
type_name = forall (m :: * -> *) a. Parsing m => m a -> m a
try forall a b. (a -> b) -> a -> b
$ do
CParserContext i
ctx <- forall r (m :: * -> *). MonadReader r m => m r
ask
CIdentifier
s <- forall (m :: * -> *) s.
(TokenParsing m, Monad m, IsString s) =>
Bool -> IdentifierStyle m -> m s
ident' (forall i. CParserContext i -> Bool
cpcEnableCpp CParserContext i
ctx) forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"type name"
TypeNames
typeNames <- forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks forall i. CParserContext i -> TypeNames
cpcTypeNames
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
HashSet.member CIdentifier
s TypeNames
typeNames) forall a b. (a -> b) -> a -> b
$
forall (m :: * -> *) a. Parsing m => String -> m a
unexpected forall a b. (a -> b) -> a -> b
$ String
"identifier " forall a. [a] -> [a] -> [a]
++ CIdentifier -> String
unCIdentifier CIdentifier
s
forall (m :: * -> *) a. Monad m => a -> m a
return CIdentifier
s
templateParser :: (Monad m, CharParsing m, CParser i m) => IdentifierStyle m -> m TypeSpecifier
templateParser :: forall (m :: * -> *) i.
(Monad m, CharParsing m, CParser i m) =>
IdentifierStyle m -> m TypeSpecifier
templateParser IdentifierStyle m
s = m TypeSpecifier
parse'
where
parse' :: m TypeSpecifier
parse' = do
String
id' <- m String
cidentParserWithNamespace
String
_ <- forall (m :: * -> *). CharParsing m => String -> m String
string String
"<"
[[TypeSpecifier]]
args <- m [[TypeSpecifier]]
templateArgParser
String
_ <- forall (m :: * -> *). CharParsing m => String -> m String
string String
">"
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ CIdentifier -> [[TypeSpecifier]] -> TypeSpecifier
Template (String -> CIdentifier
CIdentifier String
id') [[TypeSpecifier]]
args
cidentParser :: m String
cidentParser = ((:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). IdentifierStyle m -> m Char
_styleStart IdentifierStyle m
s forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (m :: * -> *). IdentifierStyle m -> m Char
_styleLetter IdentifierStyle m
s) forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> forall (m :: * -> *). IdentifierStyle m -> String
_styleName IdentifierStyle m
s)
cidentParserWithNamespace :: m String
cidentParserWithNamespace =
forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [m String
cidentParser, (forall (m :: * -> *). CharParsing m => String -> m String
string String
"::"), m String
cidentParserWithNamespace]) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
m String
cidentParser
templateArgType :: m TypeSpecifier
templateArgType = forall (m :: * -> *) a. Parsing m => m a -> m a
try ((TypeSpecifier -> TypeSpecifier
TemplatePointer forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall i (m :: * -> *). CParser i m => m TypeSpecifier
type_specifier)) forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* (forall (m :: * -> *). CharParsing m => String -> m String
string String
"*")) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. Parsing m => m a -> m a
try forall i (m :: * -> *). CParser i m => m TypeSpecifier
type_specifier forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (String -> TypeSpecifier
TemplateConst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall (f :: * -> *) a. Alternative f => f a -> f [a]
some forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). CharParsing m => String -> m Char
oneOf [Char
'0'..Char
'9']))
templateArgParser' :: m [[TypeSpecifier]]
templateArgParser' = do
[TypeSpecifier]
t <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (forall (m :: * -> *) a. TokenParsing m => m a -> m a
token m TypeSpecifier
templateArgType)
String
_ <- forall (m :: * -> *). CharParsing m => String -> m String
string String
","
[[TypeSpecifier]]
tt <- m [[TypeSpecifier]]
templateArgParser
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [TypeSpecifier]
tforall a. a -> [a] -> [a]
:[[TypeSpecifier]]
tt
templateArgParser :: m [[TypeSpecifier]]
templateArgParser =
forall (m :: * -> *) a. Parsing m => m a -> m a
try (m [[TypeSpecifier]]
templateArgParser') forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (forall (m :: * -> *) a. TokenParsing m => m a -> m a
token m TypeSpecifier
templateArgType) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (m :: * -> *) a. Monad m => a -> m a
return [])
template_parser :: CParser i m => m TypeSpecifier
template_parser :: forall i (m :: * -> *). CParser i m => m TypeSpecifier
template_parser = forall (m :: * -> *) a. Parsing m => m a -> m a
try forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) i.
(Monad m, CharParsing m, CParser i m) =>
IdentifierStyle m -> m TypeSpecifier
templateParser forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"template name"
data TypeQualifier
= CONST
| RESTRICT
| VOLATILE
deriving (Typeable, TypeQualifier -> TypeQualifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TypeQualifier -> TypeQualifier -> Bool
$c/= :: TypeQualifier -> TypeQualifier -> Bool
== :: TypeQualifier -> TypeQualifier -> Bool
$c== :: TypeQualifier -> TypeQualifier -> Bool
Eq, Int -> TypeQualifier -> String -> String
[TypeQualifier] -> String -> String
TypeQualifier -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [TypeQualifier] -> String -> String
$cshowList :: [TypeQualifier] -> String -> String
show :: TypeQualifier -> String
$cshow :: TypeQualifier -> String
showsPrec :: Int -> TypeQualifier -> String -> String
$cshowsPrec :: Int -> TypeQualifier -> String -> String
Show)
type_qualifier :: CParser i m => m TypeQualifier
type_qualifier :: forall i (m :: * -> *). CParser i m => m TypeQualifier
type_qualifier = forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ TypeQualifier
CONST forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"const"
, TypeQualifier
RESTRICT forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"restrict"
, TypeQualifier
VOLATILE forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"volatile"
]
data FunctionSpecifier
= INLINE
deriving (Typeable, FunctionSpecifier -> FunctionSpecifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FunctionSpecifier -> FunctionSpecifier -> Bool
$c/= :: FunctionSpecifier -> FunctionSpecifier -> Bool
== :: FunctionSpecifier -> FunctionSpecifier -> Bool
$c== :: FunctionSpecifier -> FunctionSpecifier -> Bool
Eq, Int -> FunctionSpecifier -> String -> String
[FunctionSpecifier] -> String -> String
FunctionSpecifier -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [FunctionSpecifier] -> String -> String
$cshowList :: [FunctionSpecifier] -> String -> String
show :: FunctionSpecifier -> String
$cshow :: FunctionSpecifier -> String
showsPrec :: Int -> FunctionSpecifier -> String -> String
$cshowsPrec :: Int -> FunctionSpecifier -> String -> String
Show)
function_specifier :: CParser i m => m FunctionSpecifier
function_specifier :: forall i (m :: * -> *). CParser i m => m FunctionSpecifier
function_specifier = forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ FunctionSpecifier
INLINE forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m -> String -> m ()
reserve forall (m :: * -> *).
(TokenParsing m, Monad m) =>
IdentifierStyle m
cIdentStyle String
"inline"
]
data Declarator i = Declarator
{ forall i. Declarator i -> [Pointer]
declaratorPointers :: [Pointer]
, forall i. Declarator i -> DirectDeclarator i
declaratorDirect :: (DirectDeclarator i)
} deriving (Typeable, Declarator i -> Declarator i -> Bool
forall i. Eq i => Declarator i -> Declarator i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Declarator i -> Declarator i -> Bool
$c/= :: forall i. Eq i => Declarator i -> Declarator i -> Bool
== :: Declarator i -> Declarator i -> Bool
$c== :: forall i. Eq i => Declarator i -> Declarator i -> Bool
Eq, Int -> Declarator i -> String -> String
forall i. Show i => Int -> Declarator i -> String -> String
forall i. Show i => [Declarator i] -> String -> String
forall i. Show i => Declarator i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Declarator i] -> String -> String
$cshowList :: forall i. Show i => [Declarator i] -> String -> String
show :: Declarator i -> String
$cshow :: forall i. Show i => Declarator i -> String
showsPrec :: Int -> Declarator i -> String -> String
$cshowsPrec :: forall i. Show i => Int -> Declarator i -> String -> String
Show, forall a b. a -> Declarator b -> Declarator a
forall a b. (a -> b) -> Declarator a -> Declarator b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Declarator b -> Declarator a
$c<$ :: forall a b. a -> Declarator b -> Declarator a
fmap :: forall a b. (a -> b) -> Declarator a -> Declarator b
$cfmap :: forall a b. (a -> b) -> Declarator a -> Declarator b
Functor, forall a. Eq a => a -> Declarator a -> Bool
forall a. Num a => Declarator a -> a
forall a. Ord a => Declarator a -> a
forall m. Monoid m => Declarator m -> m
forall a. Declarator a -> Bool
forall a. Declarator a -> Int
forall a. Declarator a -> [a]
forall a. (a -> a -> a) -> Declarator a -> a
forall m a. Monoid m => (a -> m) -> Declarator a -> m
forall b a. (b -> a -> b) -> b -> Declarator a -> b
forall a b. (a -> b -> b) -> b -> Declarator a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => Declarator a -> a
$cproduct :: forall a. Num a => Declarator a -> a
sum :: forall a. Num a => Declarator a -> a
$csum :: forall a. Num a => Declarator a -> a
minimum :: forall a. Ord a => Declarator a -> a
$cminimum :: forall a. Ord a => Declarator a -> a
maximum :: forall a. Ord a => Declarator a -> a
$cmaximum :: forall a. Ord a => Declarator a -> a
elem :: forall a. Eq a => a -> Declarator a -> Bool
$celem :: forall a. Eq a => a -> Declarator a -> Bool
length :: forall a. Declarator a -> Int
$clength :: forall a. Declarator a -> Int
null :: forall a. Declarator a -> Bool
$cnull :: forall a. Declarator a -> Bool
toList :: forall a. Declarator a -> [a]
$ctoList :: forall a. Declarator a -> [a]
foldl1 :: forall a. (a -> a -> a) -> Declarator a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> Declarator a -> a
foldr1 :: forall a. (a -> a -> a) -> Declarator a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> Declarator a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> Declarator a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> Declarator a -> b
foldl :: forall b a. (b -> a -> b) -> b -> Declarator a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> Declarator a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> Declarator a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> Declarator a -> b
foldr :: forall a b. (a -> b -> b) -> b -> Declarator a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> Declarator a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> Declarator a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> Declarator a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> Declarator a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> Declarator a -> m
fold :: forall m. Monoid m => Declarator m -> m
$cfold :: forall m. Monoid m => Declarator m -> m
Foldable, Functor Declarator
Foldable Declarator
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
Declarator (m a) -> m (Declarator a)
forall (f :: * -> *) a.
Applicative f =>
Declarator (f a) -> f (Declarator a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Declarator a -> m (Declarator b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Declarator a -> f (Declarator b)
sequence :: forall (m :: * -> *) a.
Monad m =>
Declarator (m a) -> m (Declarator a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
Declarator (m a) -> m (Declarator a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Declarator a -> m (Declarator b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> Declarator a -> m (Declarator b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
Declarator (f a) -> f (Declarator a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
Declarator (f a) -> f (Declarator a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Declarator a -> f (Declarator b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Declarator a -> f (Declarator b)
Traversable)
declarator :: CParser i m => m (Declarator i)
declarator :: forall i (m :: * -> *). CParser i m => m (Declarator i)
declarator = (forall i. [Pointer] -> DirectDeclarator i -> Declarator i
Declarator forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall i (m :: * -> *). CParser i m => m Pointer
pointer forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall i (m :: * -> *). CParser i m => m (DirectDeclarator i)
direct_declarator) forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"declarator"
data DirectDeclarator i
= DeclaratorRoot i
| ArrayOrProto (DirectDeclarator i) (ArrayOrProto i)
| DeclaratorParens (Declarator i)
deriving (Typeable, DirectDeclarator i -> DirectDeclarator i -> Bool
forall i. Eq i => DirectDeclarator i -> DirectDeclarator i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DirectDeclarator i -> DirectDeclarator i -> Bool
$c/= :: forall i. Eq i => DirectDeclarator i -> DirectDeclarator i -> Bool
== :: DirectDeclarator i -> DirectDeclarator i -> Bool
$c== :: forall i. Eq i => DirectDeclarator i -> DirectDeclarator i -> Bool
Eq, Int -> DirectDeclarator i -> String -> String
forall i. Show i => Int -> DirectDeclarator i -> String -> String
forall i. Show i => [DirectDeclarator i] -> String -> String
forall i. Show i => DirectDeclarator i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [DirectDeclarator i] -> String -> String
$cshowList :: forall i. Show i => [DirectDeclarator i] -> String -> String
show :: DirectDeclarator i -> String
$cshow :: forall i. Show i => DirectDeclarator i -> String
showsPrec :: Int -> DirectDeclarator i -> String -> String
$cshowsPrec :: forall i. Show i => Int -> DirectDeclarator i -> String -> String
Show, forall a b. a -> DirectDeclarator b -> DirectDeclarator a
forall a b. (a -> b) -> DirectDeclarator a -> DirectDeclarator b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> DirectDeclarator b -> DirectDeclarator a
$c<$ :: forall a b. a -> DirectDeclarator b -> DirectDeclarator a
fmap :: forall a b. (a -> b) -> DirectDeclarator a -> DirectDeclarator b
$cfmap :: forall a b. (a -> b) -> DirectDeclarator a -> DirectDeclarator b
Functor, forall a. Eq a => a -> DirectDeclarator a -> Bool
forall a. Num a => DirectDeclarator a -> a
forall a. Ord a => DirectDeclarator a -> a
forall m. Monoid m => DirectDeclarator m -> m
forall a. DirectDeclarator a -> Bool
forall a. DirectDeclarator a -> Int
forall a. DirectDeclarator a -> [a]
forall a. (a -> a -> a) -> DirectDeclarator a -> a
forall m a. Monoid m => (a -> m) -> DirectDeclarator a -> m
forall b a. (b -> a -> b) -> b -> DirectDeclarator a -> b
forall a b. (a -> b -> b) -> b -> DirectDeclarator a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => DirectDeclarator a -> a
$cproduct :: forall a. Num a => DirectDeclarator a -> a
sum :: forall a. Num a => DirectDeclarator a -> a
$csum :: forall a. Num a => DirectDeclarator a -> a
minimum :: forall a. Ord a => DirectDeclarator a -> a
$cminimum :: forall a. Ord a => DirectDeclarator a -> a
maximum :: forall a. Ord a => DirectDeclarator a -> a
$cmaximum :: forall a. Ord a => DirectDeclarator a -> a
elem :: forall a. Eq a => a -> DirectDeclarator a -> Bool
$celem :: forall a. Eq a => a -> DirectDeclarator a -> Bool
length :: forall a. DirectDeclarator a -> Int
$clength :: forall a. DirectDeclarator a -> Int
null :: forall a. DirectDeclarator a -> Bool
$cnull :: forall a. DirectDeclarator a -> Bool
toList :: forall a. DirectDeclarator a -> [a]
$ctoList :: forall a. DirectDeclarator a -> [a]
foldl1 :: forall a. (a -> a -> a) -> DirectDeclarator a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> DirectDeclarator a -> a
foldr1 :: forall a. (a -> a -> a) -> DirectDeclarator a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> DirectDeclarator a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> DirectDeclarator a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> DirectDeclarator a -> b
foldl :: forall b a. (b -> a -> b) -> b -> DirectDeclarator a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> DirectDeclarator a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> DirectDeclarator a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> DirectDeclarator a -> b
foldr :: forall a b. (a -> b -> b) -> b -> DirectDeclarator a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> DirectDeclarator a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> DirectDeclarator a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> DirectDeclarator a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> DirectDeclarator a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> DirectDeclarator a -> m
fold :: forall m. Monoid m => DirectDeclarator m -> m
$cfold :: forall m. Monoid m => DirectDeclarator m -> m
Foldable, Functor DirectDeclarator
Foldable DirectDeclarator
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
DirectDeclarator (m a) -> m (DirectDeclarator a)
forall (f :: * -> *) a.
Applicative f =>
DirectDeclarator (f a) -> f (DirectDeclarator a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> DirectDeclarator a -> m (DirectDeclarator b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> DirectDeclarator a -> f (DirectDeclarator b)
sequence :: forall (m :: * -> *) a.
Monad m =>
DirectDeclarator (m a) -> m (DirectDeclarator a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
DirectDeclarator (m a) -> m (DirectDeclarator a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> DirectDeclarator a -> m (DirectDeclarator b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> DirectDeclarator a -> m (DirectDeclarator b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
DirectDeclarator (f a) -> f (DirectDeclarator a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
DirectDeclarator (f a) -> f (DirectDeclarator a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> DirectDeclarator a -> f (DirectDeclarator b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> DirectDeclarator a -> f (DirectDeclarator b)
Traversable)
data ArrayOrProto i
= Array (ArrayType i)
| Proto [ParameterDeclaration i]
deriving (ArrayOrProto i -> ArrayOrProto i -> Bool
forall i. Eq i => ArrayOrProto i -> ArrayOrProto i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArrayOrProto i -> ArrayOrProto i -> Bool
$c/= :: forall i. Eq i => ArrayOrProto i -> ArrayOrProto i -> Bool
== :: ArrayOrProto i -> ArrayOrProto i -> Bool
$c== :: forall i. Eq i => ArrayOrProto i -> ArrayOrProto i -> Bool
Eq, Int -> ArrayOrProto i -> String -> String
forall i. Show i => Int -> ArrayOrProto i -> String -> String
forall i. Show i => [ArrayOrProto i] -> String -> String
forall i. Show i => ArrayOrProto i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [ArrayOrProto i] -> String -> String
$cshowList :: forall i. Show i => [ArrayOrProto i] -> String -> String
show :: ArrayOrProto i -> String
$cshow :: forall i. Show i => ArrayOrProto i -> String
showsPrec :: Int -> ArrayOrProto i -> String -> String
$cshowsPrec :: forall i. Show i => Int -> ArrayOrProto i -> String -> String
Show, Typeable, forall a b. a -> ArrayOrProto b -> ArrayOrProto a
forall a b. (a -> b) -> ArrayOrProto a -> ArrayOrProto b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ArrayOrProto b -> ArrayOrProto a
$c<$ :: forall a b. a -> ArrayOrProto b -> ArrayOrProto a
fmap :: forall a b. (a -> b) -> ArrayOrProto a -> ArrayOrProto b
$cfmap :: forall a b. (a -> b) -> ArrayOrProto a -> ArrayOrProto b
Functor, forall a. Eq a => a -> ArrayOrProto a -> Bool
forall a. Num a => ArrayOrProto a -> a
forall a. Ord a => ArrayOrProto a -> a
forall m. Monoid m => ArrayOrProto m -> m
forall a. ArrayOrProto a -> Bool
forall a. ArrayOrProto a -> Int
forall a. ArrayOrProto a -> [a]
forall a. (a -> a -> a) -> ArrayOrProto a -> a
forall m a. Monoid m => (a -> m) -> ArrayOrProto a -> m
forall b a. (b -> a -> b) -> b -> ArrayOrProto a -> b
forall a b. (a -> b -> b) -> b -> ArrayOrProto a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => ArrayOrProto a -> a
$cproduct :: forall a. Num a => ArrayOrProto a -> a
sum :: forall a. Num a => ArrayOrProto a -> a
$csum :: forall a. Num a => ArrayOrProto a -> a
minimum :: forall a. Ord a => ArrayOrProto a -> a
$cminimum :: forall a. Ord a => ArrayOrProto a -> a
maximum :: forall a. Ord a => ArrayOrProto a -> a
$cmaximum :: forall a. Ord a => ArrayOrProto a -> a
elem :: forall a. Eq a => a -> ArrayOrProto a -> Bool
$celem :: forall a. Eq a => a -> ArrayOrProto a -> Bool
length :: forall a. ArrayOrProto a -> Int
$clength :: forall a. ArrayOrProto a -> Int
null :: forall a. ArrayOrProto a -> Bool
$cnull :: forall a. ArrayOrProto a -> Bool
toList :: forall a. ArrayOrProto a -> [a]
$ctoList :: forall a. ArrayOrProto a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ArrayOrProto a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> ArrayOrProto a -> a
foldr1 :: forall a. (a -> a -> a) -> ArrayOrProto a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> ArrayOrProto a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ArrayOrProto a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> ArrayOrProto a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ArrayOrProto a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> ArrayOrProto a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ArrayOrProto a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> ArrayOrProto a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ArrayOrProto a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> ArrayOrProto a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ArrayOrProto a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> ArrayOrProto a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ArrayOrProto a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> ArrayOrProto a -> m
fold :: forall m. Monoid m => ArrayOrProto m -> m
$cfold :: forall m. Monoid m => ArrayOrProto m -> m
Foldable, Functor ArrayOrProto
Foldable ArrayOrProto
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
ArrayOrProto (m a) -> m (ArrayOrProto a)
forall (f :: * -> *) a.
Applicative f =>
ArrayOrProto (f a) -> f (ArrayOrProto a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArrayOrProto a -> m (ArrayOrProto b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArrayOrProto a -> f (ArrayOrProto b)
sequence :: forall (m :: * -> *) a.
Monad m =>
ArrayOrProto (m a) -> m (ArrayOrProto a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
ArrayOrProto (m a) -> m (ArrayOrProto a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArrayOrProto a -> m (ArrayOrProto b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArrayOrProto a -> m (ArrayOrProto b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ArrayOrProto (f a) -> f (ArrayOrProto a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
ArrayOrProto (f a) -> f (ArrayOrProto a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArrayOrProto a -> f (ArrayOrProto b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArrayOrProto a -> f (ArrayOrProto b)
Traversable)
array_or_proto :: CParser i m => m (ArrayOrProto i)
array_or_proto :: forall i (m :: * -> *). CParser i m => m (ArrayOrProto i)
array_or_proto = forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ forall i. ArrayType i -> ArrayOrProto i
Array forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. TokenParsing m => m a -> m a
brackets forall i (m :: * -> *). CParser i m => m (ArrayType i)
array_type
, forall i. [ParameterDeclaration i] -> ArrayOrProto i
Proto forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. TokenParsing m => m a -> m a
parens forall i (m :: * -> *). CParser i m => m [ParameterDeclaration i]
parameter_list
]
data ArrayType i
= VariablySized
| Unsized
| SizedByInteger Integer
| SizedByIdentifier i
deriving (Typeable, ArrayType i -> ArrayType i -> Bool
forall i. Eq i => ArrayType i -> ArrayType i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ArrayType i -> ArrayType i -> Bool
$c/= :: forall i. Eq i => ArrayType i -> ArrayType i -> Bool
== :: ArrayType i -> ArrayType i -> Bool
$c== :: forall i. Eq i => ArrayType i -> ArrayType i -> Bool
Eq, Int -> ArrayType i -> String -> String
forall i. Show i => Int -> ArrayType i -> String -> String
forall i. Show i => [ArrayType i] -> String -> String
forall i. Show i => ArrayType i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [ArrayType i] -> String -> String
$cshowList :: forall i. Show i => [ArrayType i] -> String -> String
show :: ArrayType i -> String
$cshow :: forall i. Show i => ArrayType i -> String
showsPrec :: Int -> ArrayType i -> String -> String
$cshowsPrec :: forall i. Show i => Int -> ArrayType i -> String -> String
Show, forall a b. a -> ArrayType b -> ArrayType a
forall a b. (a -> b) -> ArrayType a -> ArrayType b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ArrayType b -> ArrayType a
$c<$ :: forall a b. a -> ArrayType b -> ArrayType a
fmap :: forall a b. (a -> b) -> ArrayType a -> ArrayType b
$cfmap :: forall a b. (a -> b) -> ArrayType a -> ArrayType b
Functor, forall a. Eq a => a -> ArrayType a -> Bool
forall a. Num a => ArrayType a -> a
forall a. Ord a => ArrayType a -> a
forall m. Monoid m => ArrayType m -> m
forall a. ArrayType a -> Bool
forall a. ArrayType a -> Int
forall a. ArrayType a -> [a]
forall a. (a -> a -> a) -> ArrayType a -> a
forall m a. Monoid m => (a -> m) -> ArrayType a -> m
forall b a. (b -> a -> b) -> b -> ArrayType a -> b
forall a b. (a -> b -> b) -> b -> ArrayType a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => ArrayType a -> a
$cproduct :: forall a. Num a => ArrayType a -> a
sum :: forall a. Num a => ArrayType a -> a
$csum :: forall a. Num a => ArrayType a -> a
minimum :: forall a. Ord a => ArrayType a -> a
$cminimum :: forall a. Ord a => ArrayType a -> a
maximum :: forall a. Ord a => ArrayType a -> a
$cmaximum :: forall a. Ord a => ArrayType a -> a
elem :: forall a. Eq a => a -> ArrayType a -> Bool
$celem :: forall a. Eq a => a -> ArrayType a -> Bool
length :: forall a. ArrayType a -> Int
$clength :: forall a. ArrayType a -> Int
null :: forall a. ArrayType a -> Bool
$cnull :: forall a. ArrayType a -> Bool
toList :: forall a. ArrayType a -> [a]
$ctoList :: forall a. ArrayType a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ArrayType a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> ArrayType a -> a
foldr1 :: forall a. (a -> a -> a) -> ArrayType a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> ArrayType a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ArrayType a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> ArrayType a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ArrayType a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> ArrayType a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ArrayType a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> ArrayType a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ArrayType a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> ArrayType a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ArrayType a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> ArrayType a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ArrayType a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> ArrayType a -> m
fold :: forall m. Monoid m => ArrayType m -> m
$cfold :: forall m. Monoid m => ArrayType m -> m
Foldable, Functor ArrayType
Foldable ArrayType
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
ArrayType (m a) -> m (ArrayType a)
forall (f :: * -> *) a.
Applicative f =>
ArrayType (f a) -> f (ArrayType a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArrayType a -> m (ArrayType b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArrayType a -> f (ArrayType b)
sequence :: forall (m :: * -> *) a.
Monad m =>
ArrayType (m a) -> m (ArrayType a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
ArrayType (m a) -> m (ArrayType a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArrayType a -> m (ArrayType b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ArrayType a -> m (ArrayType b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ArrayType (f a) -> f (ArrayType a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
ArrayType (f a) -> f (ArrayType a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArrayType a -> f (ArrayType b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ArrayType a -> f (ArrayType b)
Traversable)
array_type :: CParser i m => m (ArrayType i)
array_type :: forall i (m :: * -> *). CParser i m => m (ArrayType i)
array_type = forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ forall i. ArrayType i
VariablySized forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). TokenParsing m => Char -> m Char
symbolic Char
'*'
, forall i. Integer -> ArrayType i
SizedByInteger forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). TokenParsing m => m Integer
natural
, forall i. i -> ArrayType i
SizedByIdentifier forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m i
identifier
, forall (m :: * -> *) a. Monad m => a -> m a
return forall i. ArrayType i
Unsized
]
direct_declarator :: CParser i m => m (DirectDeclarator i)
direct_declarator :: forall i (m :: * -> *). CParser i m => m (DirectDeclarator i)
direct_declarator = do
DirectDeclarator i
ddecltor <- forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ forall i. i -> DirectDeclarator i
DeclaratorRoot forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m i
identifier
, forall i. Declarator i -> DirectDeclarator i
DeclaratorParens forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. TokenParsing m => m a -> m a
parens forall i (m :: * -> *). CParser i m => m (Declarator i)
declarator
]
[ArrayOrProto i]
aops <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall i (m :: * -> *). CParser i m => m (ArrayOrProto i)
array_or_proto
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl forall i.
DirectDeclarator i -> ArrayOrProto i -> DirectDeclarator i
ArrayOrProto DirectDeclarator i
ddecltor [ArrayOrProto i]
aops
data Pointer
= Pointer [TypeQualifier]
deriving (Typeable, Pointer -> Pointer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Pointer -> Pointer -> Bool
$c/= :: Pointer -> Pointer -> Bool
== :: Pointer -> Pointer -> Bool
$c== :: Pointer -> Pointer -> Bool
Eq, Int -> Pointer -> String -> String
[Pointer] -> String -> String
Pointer -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [Pointer] -> String -> String
$cshowList :: [Pointer] -> String -> String
show :: Pointer -> String
$cshow :: Pointer -> String
showsPrec :: Int -> Pointer -> String -> String
$cshowsPrec :: Int -> Pointer -> String -> String
Show)
pointer :: CParser i m => m Pointer
pointer :: forall i (m :: * -> *). CParser i m => m Pointer
pointer = do
forall (f :: * -> *) a. Functor f => f a -> f ()
void forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). TokenParsing m => Char -> m Char
symbolic Char
'*'
[TypeQualifier] -> Pointer
Pointer forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall i (m :: * -> *). CParser i m => m TypeQualifier
type_qualifier
parameter_list :: CParser i m => m [ParameterDeclaration i]
parameter_list :: forall i (m :: * -> *). CParser i m => m [ParameterDeclaration i]
parameter_list =
forall (m :: * -> *) a sep. Alternative m => m a -> m sep -> m [a]
sepBy forall i (m :: * -> *). CParser i m => m (ParameterDeclaration i)
parameter_declaration forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). TokenParsing m => Char -> m Char
symbolic Char
','
data ParameterDeclaration i = ParameterDeclaration
{ forall i. ParameterDeclaration i -> [DeclarationSpecifier]
parameterDeclarationSpecifiers :: [DeclarationSpecifier]
, forall i.
ParameterDeclaration i -> DeclaratorOrAbstractDeclarator i
parameterDeclarationDeclarator :: DeclaratorOrAbstractDeclarator i
} deriving (ParameterDeclaration i -> ParameterDeclaration i -> Bool
forall i.
Eq i =>
ParameterDeclaration i -> ParameterDeclaration i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParameterDeclaration i -> ParameterDeclaration i -> Bool
$c/= :: forall i.
Eq i =>
ParameterDeclaration i -> ParameterDeclaration i -> Bool
== :: ParameterDeclaration i -> ParameterDeclaration i -> Bool
$c== :: forall i.
Eq i =>
ParameterDeclaration i -> ParameterDeclaration i -> Bool
Eq, Int -> ParameterDeclaration i -> String -> String
forall i.
Show i =>
Int -> ParameterDeclaration i -> String -> String
forall i. Show i => [ParameterDeclaration i] -> String -> String
forall i. Show i => ParameterDeclaration i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [ParameterDeclaration i] -> String -> String
$cshowList :: forall i. Show i => [ParameterDeclaration i] -> String -> String
show :: ParameterDeclaration i -> String
$cshow :: forall i. Show i => ParameterDeclaration i -> String
showsPrec :: Int -> ParameterDeclaration i -> String -> String
$cshowsPrec :: forall i.
Show i =>
Int -> ParameterDeclaration i -> String -> String
Show, Typeable, forall a b. a -> ParameterDeclaration b -> ParameterDeclaration a
forall a b.
(a -> b) -> ParameterDeclaration a -> ParameterDeclaration b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> ParameterDeclaration b -> ParameterDeclaration a
$c<$ :: forall a b. a -> ParameterDeclaration b -> ParameterDeclaration a
fmap :: forall a b.
(a -> b) -> ParameterDeclaration a -> ParameterDeclaration b
$cfmap :: forall a b.
(a -> b) -> ParameterDeclaration a -> ParameterDeclaration b
Functor, forall a. Eq a => a -> ParameterDeclaration a -> Bool
forall a. Num a => ParameterDeclaration a -> a
forall a. Ord a => ParameterDeclaration a -> a
forall m. Monoid m => ParameterDeclaration m -> m
forall a. ParameterDeclaration a -> Bool
forall a. ParameterDeclaration a -> Int
forall a. ParameterDeclaration a -> [a]
forall a. (a -> a -> a) -> ParameterDeclaration a -> a
forall m a. Monoid m => (a -> m) -> ParameterDeclaration a -> m
forall b a. (b -> a -> b) -> b -> ParameterDeclaration a -> b
forall a b. (a -> b -> b) -> b -> ParameterDeclaration a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => ParameterDeclaration a -> a
$cproduct :: forall a. Num a => ParameterDeclaration a -> a
sum :: forall a. Num a => ParameterDeclaration a -> a
$csum :: forall a. Num a => ParameterDeclaration a -> a
minimum :: forall a. Ord a => ParameterDeclaration a -> a
$cminimum :: forall a. Ord a => ParameterDeclaration a -> a
maximum :: forall a. Ord a => ParameterDeclaration a -> a
$cmaximum :: forall a. Ord a => ParameterDeclaration a -> a
elem :: forall a. Eq a => a -> ParameterDeclaration a -> Bool
$celem :: forall a. Eq a => a -> ParameterDeclaration a -> Bool
length :: forall a. ParameterDeclaration a -> Int
$clength :: forall a. ParameterDeclaration a -> Int
null :: forall a. ParameterDeclaration a -> Bool
$cnull :: forall a. ParameterDeclaration a -> Bool
toList :: forall a. ParameterDeclaration a -> [a]
$ctoList :: forall a. ParameterDeclaration a -> [a]
foldl1 :: forall a. (a -> a -> a) -> ParameterDeclaration a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> ParameterDeclaration a -> a
foldr1 :: forall a. (a -> a -> a) -> ParameterDeclaration a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> ParameterDeclaration a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> ParameterDeclaration a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> ParameterDeclaration a -> b
foldl :: forall b a. (b -> a -> b) -> b -> ParameterDeclaration a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> ParameterDeclaration a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> ParameterDeclaration a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> ParameterDeclaration a -> b
foldr :: forall a b. (a -> b -> b) -> b -> ParameterDeclaration a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> ParameterDeclaration a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> ParameterDeclaration a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> ParameterDeclaration a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> ParameterDeclaration a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> ParameterDeclaration a -> m
fold :: forall m. Monoid m => ParameterDeclaration m -> m
$cfold :: forall m. Monoid m => ParameterDeclaration m -> m
Foldable, Functor ParameterDeclaration
Foldable ParameterDeclaration
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
ParameterDeclaration (m a) -> m (ParameterDeclaration a)
forall (f :: * -> *) a.
Applicative f =>
ParameterDeclaration (f a) -> f (ParameterDeclaration a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ParameterDeclaration a -> m (ParameterDeclaration b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ParameterDeclaration a -> f (ParameterDeclaration b)
sequence :: forall (m :: * -> *) a.
Monad m =>
ParameterDeclaration (m a) -> m (ParameterDeclaration a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
ParameterDeclaration (m a) -> m (ParameterDeclaration a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ParameterDeclaration a -> m (ParameterDeclaration b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> ParameterDeclaration a -> m (ParameterDeclaration b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
ParameterDeclaration (f a) -> f (ParameterDeclaration a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
ParameterDeclaration (f a) -> f (ParameterDeclaration a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ParameterDeclaration a -> f (ParameterDeclaration b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> ParameterDeclaration a -> f (ParameterDeclaration b)
Traversable)
data DeclaratorOrAbstractDeclarator i
= IsDeclarator (Declarator i)
| IsAbstractDeclarator (AbstractDeclarator i)
deriving (DeclaratorOrAbstractDeclarator i
-> DeclaratorOrAbstractDeclarator i -> Bool
forall i.
Eq i =>
DeclaratorOrAbstractDeclarator i
-> DeclaratorOrAbstractDeclarator i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeclaratorOrAbstractDeclarator i
-> DeclaratorOrAbstractDeclarator i -> Bool
$c/= :: forall i.
Eq i =>
DeclaratorOrAbstractDeclarator i
-> DeclaratorOrAbstractDeclarator i -> Bool
== :: DeclaratorOrAbstractDeclarator i
-> DeclaratorOrAbstractDeclarator i -> Bool
$c== :: forall i.
Eq i =>
DeclaratorOrAbstractDeclarator i
-> DeclaratorOrAbstractDeclarator i -> Bool
Eq, Int -> DeclaratorOrAbstractDeclarator i -> String -> String
forall i.
Show i =>
Int -> DeclaratorOrAbstractDeclarator i -> String -> String
forall i.
Show i =>
[DeclaratorOrAbstractDeclarator i] -> String -> String
forall i. Show i => DeclaratorOrAbstractDeclarator i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [DeclaratorOrAbstractDeclarator i] -> String -> String
$cshowList :: forall i.
Show i =>
[DeclaratorOrAbstractDeclarator i] -> String -> String
show :: DeclaratorOrAbstractDeclarator i -> String
$cshow :: forall i. Show i => DeclaratorOrAbstractDeclarator i -> String
showsPrec :: Int -> DeclaratorOrAbstractDeclarator i -> String -> String
$cshowsPrec :: forall i.
Show i =>
Int -> DeclaratorOrAbstractDeclarator i -> String -> String
Show, Typeable, forall a b.
a
-> DeclaratorOrAbstractDeclarator b
-> DeclaratorOrAbstractDeclarator a
forall a b.
(a -> b)
-> DeclaratorOrAbstractDeclarator a
-> DeclaratorOrAbstractDeclarator b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b.
a
-> DeclaratorOrAbstractDeclarator b
-> DeclaratorOrAbstractDeclarator a
$c<$ :: forall a b.
a
-> DeclaratorOrAbstractDeclarator b
-> DeclaratorOrAbstractDeclarator a
fmap :: forall a b.
(a -> b)
-> DeclaratorOrAbstractDeclarator a
-> DeclaratorOrAbstractDeclarator b
$cfmap :: forall a b.
(a -> b)
-> DeclaratorOrAbstractDeclarator a
-> DeclaratorOrAbstractDeclarator b
Functor, forall a. Eq a => a -> DeclaratorOrAbstractDeclarator a -> Bool
forall a. Num a => DeclaratorOrAbstractDeclarator a -> a
forall a. Ord a => DeclaratorOrAbstractDeclarator a -> a
forall m. Monoid m => DeclaratorOrAbstractDeclarator m -> m
forall a. DeclaratorOrAbstractDeclarator a -> Bool
forall a. DeclaratorOrAbstractDeclarator a -> Int
forall a. DeclaratorOrAbstractDeclarator a -> [a]
forall a. (a -> a -> a) -> DeclaratorOrAbstractDeclarator a -> a
forall m a.
Monoid m =>
(a -> m) -> DeclaratorOrAbstractDeclarator a -> m
forall b a.
(b -> a -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
forall a b.
(a -> b -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => DeclaratorOrAbstractDeclarator a -> a
$cproduct :: forall a. Num a => DeclaratorOrAbstractDeclarator a -> a
sum :: forall a. Num a => DeclaratorOrAbstractDeclarator a -> a
$csum :: forall a. Num a => DeclaratorOrAbstractDeclarator a -> a
minimum :: forall a. Ord a => DeclaratorOrAbstractDeclarator a -> a
$cminimum :: forall a. Ord a => DeclaratorOrAbstractDeclarator a -> a
maximum :: forall a. Ord a => DeclaratorOrAbstractDeclarator a -> a
$cmaximum :: forall a. Ord a => DeclaratorOrAbstractDeclarator a -> a
elem :: forall a. Eq a => a -> DeclaratorOrAbstractDeclarator a -> Bool
$celem :: forall a. Eq a => a -> DeclaratorOrAbstractDeclarator a -> Bool
length :: forall a. DeclaratorOrAbstractDeclarator a -> Int
$clength :: forall a. DeclaratorOrAbstractDeclarator a -> Int
null :: forall a. DeclaratorOrAbstractDeclarator a -> Bool
$cnull :: forall a. DeclaratorOrAbstractDeclarator a -> Bool
toList :: forall a. DeclaratorOrAbstractDeclarator a -> [a]
$ctoList :: forall a. DeclaratorOrAbstractDeclarator a -> [a]
foldl1 :: forall a. (a -> a -> a) -> DeclaratorOrAbstractDeclarator a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> DeclaratorOrAbstractDeclarator a -> a
foldr1 :: forall a. (a -> a -> a) -> DeclaratorOrAbstractDeclarator a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> DeclaratorOrAbstractDeclarator a -> a
foldl' :: forall b a.
(b -> a -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
$cfoldl' :: forall b a.
(b -> a -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
foldl :: forall b a.
(b -> a -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
$cfoldl :: forall b a.
(b -> a -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
foldr' :: forall a b.
(a -> b -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
$cfoldr' :: forall a b.
(a -> b -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
foldr :: forall a b.
(a -> b -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
$cfoldr :: forall a b.
(a -> b -> b) -> b -> DeclaratorOrAbstractDeclarator a -> b
foldMap' :: forall m a.
Monoid m =>
(a -> m) -> DeclaratorOrAbstractDeclarator a -> m
$cfoldMap' :: forall m a.
Monoid m =>
(a -> m) -> DeclaratorOrAbstractDeclarator a -> m
foldMap :: forall m a.
Monoid m =>
(a -> m) -> DeclaratorOrAbstractDeclarator a -> m
$cfoldMap :: forall m a.
Monoid m =>
(a -> m) -> DeclaratorOrAbstractDeclarator a -> m
fold :: forall m. Monoid m => DeclaratorOrAbstractDeclarator m -> m
$cfold :: forall m. Monoid m => DeclaratorOrAbstractDeclarator m -> m
Foldable, Functor DeclaratorOrAbstractDeclarator
Foldable DeclaratorOrAbstractDeclarator
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
DeclaratorOrAbstractDeclarator (m a)
-> m (DeclaratorOrAbstractDeclarator a)
forall (f :: * -> *) a.
Applicative f =>
DeclaratorOrAbstractDeclarator (f a)
-> f (DeclaratorOrAbstractDeclarator a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> DeclaratorOrAbstractDeclarator a
-> m (DeclaratorOrAbstractDeclarator b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> DeclaratorOrAbstractDeclarator a
-> f (DeclaratorOrAbstractDeclarator b)
sequence :: forall (m :: * -> *) a.
Monad m =>
DeclaratorOrAbstractDeclarator (m a)
-> m (DeclaratorOrAbstractDeclarator a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
DeclaratorOrAbstractDeclarator (m a)
-> m (DeclaratorOrAbstractDeclarator a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> DeclaratorOrAbstractDeclarator a
-> m (DeclaratorOrAbstractDeclarator b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> DeclaratorOrAbstractDeclarator a
-> m (DeclaratorOrAbstractDeclarator b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
DeclaratorOrAbstractDeclarator (f a)
-> f (DeclaratorOrAbstractDeclarator a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
DeclaratorOrAbstractDeclarator (f a)
-> f (DeclaratorOrAbstractDeclarator a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> DeclaratorOrAbstractDeclarator a
-> f (DeclaratorOrAbstractDeclarator b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> DeclaratorOrAbstractDeclarator a
-> f (DeclaratorOrAbstractDeclarator b)
Traversable)
parameter_declaration :: CParser i m => m (ParameterDeclaration i)
parameter_declaration :: forall i (m :: * -> *). CParser i m => m (ParameterDeclaration i)
parameter_declaration =
forall i.
[DeclarationSpecifier]
-> DeclaratorOrAbstractDeclarator i -> ParameterDeclaration i
ParameterDeclaration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m [DeclarationSpecifier]
declaration_specifiers
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> m (DeclaratorOrAbstractDeclarator i)
mbabstract
where
mbabstract :: m (DeclaratorOrAbstractDeclarator i)
mbabstract =
forall i. Declarator i -> DeclaratorOrAbstractDeclarator i
IsDeclarator forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. Parsing m => m a -> m a
try forall i (m :: * -> *). CParser i m => m (Declarator i)
declarator forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
forall i. AbstractDeclarator i -> DeclaratorOrAbstractDeclarator i
IsAbstractDeclarator forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. Parsing m => m a -> m a
try forall i (m :: * -> *). CParser i m => m (AbstractDeclarator i)
abstract_declarator forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
forall (m :: * -> *) a. Monad m => a -> m a
return (forall i. AbstractDeclarator i -> DeclaratorOrAbstractDeclarator i
IsAbstractDeclarator (forall i.
[Pointer]
-> Maybe (DirectAbstractDeclarator i) -> AbstractDeclarator i
AbstractDeclarator [] forall a. Maybe a
Nothing))
data AbstractDeclarator i = AbstractDeclarator
{ forall i. AbstractDeclarator i -> [Pointer]
abstractDeclaratorPointers :: [Pointer]
, forall i.
AbstractDeclarator i -> Maybe (DirectAbstractDeclarator i)
abstractDeclaratorDirect :: Maybe (DirectAbstractDeclarator i)
} deriving (Typeable, AbstractDeclarator i -> AbstractDeclarator i -> Bool
forall i.
Eq i =>
AbstractDeclarator i -> AbstractDeclarator i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AbstractDeclarator i -> AbstractDeclarator i -> Bool
$c/= :: forall i.
Eq i =>
AbstractDeclarator i -> AbstractDeclarator i -> Bool
== :: AbstractDeclarator i -> AbstractDeclarator i -> Bool
$c== :: forall i.
Eq i =>
AbstractDeclarator i -> AbstractDeclarator i -> Bool
Eq, Int -> AbstractDeclarator i -> String -> String
forall i. Show i => Int -> AbstractDeclarator i -> String -> String
forall i. Show i => [AbstractDeclarator i] -> String -> String
forall i. Show i => AbstractDeclarator i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [AbstractDeclarator i] -> String -> String
$cshowList :: forall i. Show i => [AbstractDeclarator i] -> String -> String
show :: AbstractDeclarator i -> String
$cshow :: forall i. Show i => AbstractDeclarator i -> String
showsPrec :: Int -> AbstractDeclarator i -> String -> String
$cshowsPrec :: forall i. Show i => Int -> AbstractDeclarator i -> String -> String
Show, forall a b. a -> AbstractDeclarator b -> AbstractDeclarator a
forall a b.
(a -> b) -> AbstractDeclarator a -> AbstractDeclarator b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> AbstractDeclarator b -> AbstractDeclarator a
$c<$ :: forall a b. a -> AbstractDeclarator b -> AbstractDeclarator a
fmap :: forall a b.
(a -> b) -> AbstractDeclarator a -> AbstractDeclarator b
$cfmap :: forall a b.
(a -> b) -> AbstractDeclarator a -> AbstractDeclarator b
Functor, forall a. Eq a => a -> AbstractDeclarator a -> Bool
forall a. Num a => AbstractDeclarator a -> a
forall a. Ord a => AbstractDeclarator a -> a
forall m. Monoid m => AbstractDeclarator m -> m
forall a. AbstractDeclarator a -> Bool
forall a. AbstractDeclarator a -> Int
forall a. AbstractDeclarator a -> [a]
forall a. (a -> a -> a) -> AbstractDeclarator a -> a
forall m a. Monoid m => (a -> m) -> AbstractDeclarator a -> m
forall b a. (b -> a -> b) -> b -> AbstractDeclarator a -> b
forall a b. (a -> b -> b) -> b -> AbstractDeclarator a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => AbstractDeclarator a -> a
$cproduct :: forall a. Num a => AbstractDeclarator a -> a
sum :: forall a. Num a => AbstractDeclarator a -> a
$csum :: forall a. Num a => AbstractDeclarator a -> a
minimum :: forall a. Ord a => AbstractDeclarator a -> a
$cminimum :: forall a. Ord a => AbstractDeclarator a -> a
maximum :: forall a. Ord a => AbstractDeclarator a -> a
$cmaximum :: forall a. Ord a => AbstractDeclarator a -> a
elem :: forall a. Eq a => a -> AbstractDeclarator a -> Bool
$celem :: forall a. Eq a => a -> AbstractDeclarator a -> Bool
length :: forall a. AbstractDeclarator a -> Int
$clength :: forall a. AbstractDeclarator a -> Int
null :: forall a. AbstractDeclarator a -> Bool
$cnull :: forall a. AbstractDeclarator a -> Bool
toList :: forall a. AbstractDeclarator a -> [a]
$ctoList :: forall a. AbstractDeclarator a -> [a]
foldl1 :: forall a. (a -> a -> a) -> AbstractDeclarator a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> AbstractDeclarator a -> a
foldr1 :: forall a. (a -> a -> a) -> AbstractDeclarator a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> AbstractDeclarator a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> AbstractDeclarator a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> AbstractDeclarator a -> b
foldl :: forall b a. (b -> a -> b) -> b -> AbstractDeclarator a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> AbstractDeclarator a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> AbstractDeclarator a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> AbstractDeclarator a -> b
foldr :: forall a b. (a -> b -> b) -> b -> AbstractDeclarator a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> AbstractDeclarator a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> AbstractDeclarator a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> AbstractDeclarator a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> AbstractDeclarator a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> AbstractDeclarator a -> m
fold :: forall m. Monoid m => AbstractDeclarator m -> m
$cfold :: forall m. Monoid m => AbstractDeclarator m -> m
Foldable, Functor AbstractDeclarator
Foldable AbstractDeclarator
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
AbstractDeclarator (m a) -> m (AbstractDeclarator a)
forall (f :: * -> *) a.
Applicative f =>
AbstractDeclarator (f a) -> f (AbstractDeclarator a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AbstractDeclarator a -> m (AbstractDeclarator b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AbstractDeclarator a -> f (AbstractDeclarator b)
sequence :: forall (m :: * -> *) a.
Monad m =>
AbstractDeclarator (m a) -> m (AbstractDeclarator a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
AbstractDeclarator (m a) -> m (AbstractDeclarator a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AbstractDeclarator a -> m (AbstractDeclarator b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> AbstractDeclarator a -> m (AbstractDeclarator b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
AbstractDeclarator (f a) -> f (AbstractDeclarator a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
AbstractDeclarator (f a) -> f (AbstractDeclarator a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AbstractDeclarator a -> f (AbstractDeclarator b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> AbstractDeclarator a -> f (AbstractDeclarator b)
Traversable)
abstract_declarator :: CParser i m => m (AbstractDeclarator i)
abstract_declarator :: forall i (m :: * -> *). CParser i m => m (AbstractDeclarator i)
abstract_declarator = do
[Pointer]
ptrs <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall i (m :: * -> *). CParser i m => m Pointer
pointer
let p :: m (Maybe (DirectAbstractDeclarator i))
p = if forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Pointer]
ptrs
then forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *).
CParser i m =>
m (DirectAbstractDeclarator i)
direct_abstract_declarator
else (forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. Parsing m => m a -> m a
try forall i (m :: * -> *).
CParser i m =>
m (DirectAbstractDeclarator i)
direct_abstract_declarator) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Maybe a
Nothing
forall i.
[Pointer]
-> Maybe (DirectAbstractDeclarator i) -> AbstractDeclarator i
AbstractDeclarator [Pointer]
ptrs forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (Maybe (DirectAbstractDeclarator i))
p
data DirectAbstractDeclarator i
= ArrayOrProtoHere (ArrayOrProto i)
| ArrayOrProtoThere (DirectAbstractDeclarator i) (ArrayOrProto i)
| AbstractDeclaratorParens (AbstractDeclarator i)
deriving (Typeable, DirectAbstractDeclarator i -> DirectAbstractDeclarator i -> Bool
forall i.
Eq i =>
DirectAbstractDeclarator i -> DirectAbstractDeclarator i -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DirectAbstractDeclarator i -> DirectAbstractDeclarator i -> Bool
$c/= :: forall i.
Eq i =>
DirectAbstractDeclarator i -> DirectAbstractDeclarator i -> Bool
== :: DirectAbstractDeclarator i -> DirectAbstractDeclarator i -> Bool
$c== :: forall i.
Eq i =>
DirectAbstractDeclarator i -> DirectAbstractDeclarator i -> Bool
Eq, Int -> DirectAbstractDeclarator i -> String -> String
forall i.
Show i =>
Int -> DirectAbstractDeclarator i -> String -> String
forall i.
Show i =>
[DirectAbstractDeclarator i] -> String -> String
forall i. Show i => DirectAbstractDeclarator i -> String
forall a.
(Int -> a -> String -> String)
-> (a -> String) -> ([a] -> String -> String) -> Show a
showList :: [DirectAbstractDeclarator i] -> String -> String
$cshowList :: forall i.
Show i =>
[DirectAbstractDeclarator i] -> String -> String
show :: DirectAbstractDeclarator i -> String
$cshow :: forall i. Show i => DirectAbstractDeclarator i -> String
showsPrec :: Int -> DirectAbstractDeclarator i -> String -> String
$cshowsPrec :: forall i.
Show i =>
Int -> DirectAbstractDeclarator i -> String -> String
Show, forall a b.
a -> DirectAbstractDeclarator b -> DirectAbstractDeclarator a
forall a b.
(a -> b)
-> DirectAbstractDeclarator a -> DirectAbstractDeclarator b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b.
a -> DirectAbstractDeclarator b -> DirectAbstractDeclarator a
$c<$ :: forall a b.
a -> DirectAbstractDeclarator b -> DirectAbstractDeclarator a
fmap :: forall a b.
(a -> b)
-> DirectAbstractDeclarator a -> DirectAbstractDeclarator b
$cfmap :: forall a b.
(a -> b)
-> DirectAbstractDeclarator a -> DirectAbstractDeclarator b
Functor, forall a. Eq a => a -> DirectAbstractDeclarator a -> Bool
forall a. Num a => DirectAbstractDeclarator a -> a
forall a. Ord a => DirectAbstractDeclarator a -> a
forall m. Monoid m => DirectAbstractDeclarator m -> m
forall a. DirectAbstractDeclarator a -> Bool
forall a. DirectAbstractDeclarator a -> Int
forall a. DirectAbstractDeclarator a -> [a]
forall a. (a -> a -> a) -> DirectAbstractDeclarator a -> a
forall m a. Monoid m => (a -> m) -> DirectAbstractDeclarator a -> m
forall b a. (b -> a -> b) -> b -> DirectAbstractDeclarator a -> b
forall a b. (a -> b -> b) -> b -> DirectAbstractDeclarator a -> b
forall (t :: * -> *).
(forall m. Monoid m => t m -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall m a. Monoid m => (a -> m) -> t a -> m)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall a b. (a -> b -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall b a. (b -> a -> b) -> b -> t a -> b)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. (a -> a -> a) -> t a -> a)
-> (forall a. t a -> [a])
-> (forall a. t a -> Bool)
-> (forall a. t a -> Int)
-> (forall a. Eq a => a -> t a -> Bool)
-> (forall a. Ord a => t a -> a)
-> (forall a. Ord a => t a -> a)
-> (forall a. Num a => t a -> a)
-> (forall a. Num a => t a -> a)
-> Foldable t
product :: forall a. Num a => DirectAbstractDeclarator a -> a
$cproduct :: forall a. Num a => DirectAbstractDeclarator a -> a
sum :: forall a. Num a => DirectAbstractDeclarator a -> a
$csum :: forall a. Num a => DirectAbstractDeclarator a -> a
minimum :: forall a. Ord a => DirectAbstractDeclarator a -> a
$cminimum :: forall a. Ord a => DirectAbstractDeclarator a -> a
maximum :: forall a. Ord a => DirectAbstractDeclarator a -> a
$cmaximum :: forall a. Ord a => DirectAbstractDeclarator a -> a
elem :: forall a. Eq a => a -> DirectAbstractDeclarator a -> Bool
$celem :: forall a. Eq a => a -> DirectAbstractDeclarator a -> Bool
length :: forall a. DirectAbstractDeclarator a -> Int
$clength :: forall a. DirectAbstractDeclarator a -> Int
null :: forall a. DirectAbstractDeclarator a -> Bool
$cnull :: forall a. DirectAbstractDeclarator a -> Bool
toList :: forall a. DirectAbstractDeclarator a -> [a]
$ctoList :: forall a. DirectAbstractDeclarator a -> [a]
foldl1 :: forall a. (a -> a -> a) -> DirectAbstractDeclarator a -> a
$cfoldl1 :: forall a. (a -> a -> a) -> DirectAbstractDeclarator a -> a
foldr1 :: forall a. (a -> a -> a) -> DirectAbstractDeclarator a -> a
$cfoldr1 :: forall a. (a -> a -> a) -> DirectAbstractDeclarator a -> a
foldl' :: forall b a. (b -> a -> b) -> b -> DirectAbstractDeclarator a -> b
$cfoldl' :: forall b a. (b -> a -> b) -> b -> DirectAbstractDeclarator a -> b
foldl :: forall b a. (b -> a -> b) -> b -> DirectAbstractDeclarator a -> b
$cfoldl :: forall b a. (b -> a -> b) -> b -> DirectAbstractDeclarator a -> b
foldr' :: forall a b. (a -> b -> b) -> b -> DirectAbstractDeclarator a -> b
$cfoldr' :: forall a b. (a -> b -> b) -> b -> DirectAbstractDeclarator a -> b
foldr :: forall a b. (a -> b -> b) -> b -> DirectAbstractDeclarator a -> b
$cfoldr :: forall a b. (a -> b -> b) -> b -> DirectAbstractDeclarator a -> b
foldMap' :: forall m a. Monoid m => (a -> m) -> DirectAbstractDeclarator a -> m
$cfoldMap' :: forall m a. Monoid m => (a -> m) -> DirectAbstractDeclarator a -> m
foldMap :: forall m a. Monoid m => (a -> m) -> DirectAbstractDeclarator a -> m
$cfoldMap :: forall m a. Monoid m => (a -> m) -> DirectAbstractDeclarator a -> m
fold :: forall m. Monoid m => DirectAbstractDeclarator m -> m
$cfold :: forall m. Monoid m => DirectAbstractDeclarator m -> m
Foldable, Functor DirectAbstractDeclarator
Foldable DirectAbstractDeclarator
forall (t :: * -> *).
Functor t
-> Foldable t
-> (forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> t a -> f (t b))
-> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a))
-> (forall (m :: * -> *) a b.
Monad m =>
(a -> m b) -> t a -> m (t b))
-> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a))
-> Traversable t
forall (m :: * -> *) a.
Monad m =>
DirectAbstractDeclarator (m a) -> m (DirectAbstractDeclarator a)
forall (f :: * -> *) a.
Applicative f =>
DirectAbstractDeclarator (f a) -> f (DirectAbstractDeclarator a)
forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> DirectAbstractDeclarator a -> m (DirectAbstractDeclarator b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> DirectAbstractDeclarator a -> f (DirectAbstractDeclarator b)
sequence :: forall (m :: * -> *) a.
Monad m =>
DirectAbstractDeclarator (m a) -> m (DirectAbstractDeclarator a)
$csequence :: forall (m :: * -> *) a.
Monad m =>
DirectAbstractDeclarator (m a) -> m (DirectAbstractDeclarator a)
mapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> DirectAbstractDeclarator a -> m (DirectAbstractDeclarator b)
$cmapM :: forall (m :: * -> *) a b.
Monad m =>
(a -> m b)
-> DirectAbstractDeclarator a -> m (DirectAbstractDeclarator b)
sequenceA :: forall (f :: * -> *) a.
Applicative f =>
DirectAbstractDeclarator (f a) -> f (DirectAbstractDeclarator a)
$csequenceA :: forall (f :: * -> *) a.
Applicative f =>
DirectAbstractDeclarator (f a) -> f (DirectAbstractDeclarator a)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> DirectAbstractDeclarator a -> f (DirectAbstractDeclarator b)
$ctraverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b)
-> DirectAbstractDeclarator a -> f (DirectAbstractDeclarator b)
Traversable)
direct_abstract_declarator :: CParser i m => m (DirectAbstractDeclarator i)
direct_abstract_declarator :: forall i (m :: * -> *).
CParser i m =>
m (DirectAbstractDeclarator i)
direct_abstract_declarator = do
DirectAbstractDeclarator i
ddecltor <- forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, MonadPlus m) =>
t (m a) -> m a
msum
[ forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall i. ArrayOrProto i -> DirectAbstractDeclarator i
ArrayOrProtoHere forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall i (m :: * -> *). CParser i m => m (ArrayOrProto i)
array_or_proto)
, forall i. AbstractDeclarator i -> DirectAbstractDeclarator i
AbstractDeclaratorParens forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *) a. TokenParsing m => m a -> m a
parens forall i (m :: * -> *). CParser i m => m (AbstractDeclarator i)
abstract_declarator
] forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> String
"array, prototype, or parenthesised abstract declarator"
[ArrayOrProto i]
aops <- forall (f :: * -> *) a. Alternative f => f a -> f [a]
many forall i (m :: * -> *). CParser i m => m (ArrayOrProto i)
array_or_proto
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl forall i.
DirectAbstractDeclarator i
-> ArrayOrProto i -> DirectAbstractDeclarator i
ArrayOrProtoThere DirectAbstractDeclarator i
ddecltor [ArrayOrProto i]
aops
instance Pretty CIdentifier where
pretty :: forall ann. CIdentifier -> Doc ann
pretty = forall a. IsString a => String -> a
fromString forall b c a. (b -> c) -> (a -> b) -> a -> c
. CIdentifier -> String
unCIdentifier
instance Pretty DeclarationSpecifier where
pretty :: forall ann. DeclarationSpecifier -> Doc ann
pretty DeclarationSpecifier
dspec = case DeclarationSpecifier
dspec of
StorageClassSpecifier StorageClassSpecifier
x -> forall a ann. Pretty a => a -> Doc ann
pretty StorageClassSpecifier
x
TypeSpecifier TypeSpecifier
x -> forall a ann. Pretty a => a -> Doc ann
pretty TypeSpecifier
x
TypeQualifier TypeQualifier
x -> forall a ann. Pretty a => a -> Doc ann
pretty TypeQualifier
x
FunctionSpecifier FunctionSpecifier
x -> forall a ann. Pretty a => a -> Doc ann
pretty FunctionSpecifier
x
instance Pretty StorageClassSpecifier where
pretty :: forall ann. StorageClassSpecifier -> Doc ann
pretty StorageClassSpecifier
storage = case StorageClassSpecifier
storage of
StorageClassSpecifier
TYPEDEF -> Doc ann
"typedef"
StorageClassSpecifier
EXTERN -> Doc ann
"extern"
StorageClassSpecifier
STATIC -> Doc ann
"static"
StorageClassSpecifier
AUTO -> Doc ann
"auto"
StorageClassSpecifier
REGISTER -> Doc ann
"register"
instance Pretty TypeSpecifier where
pretty :: forall ann. TypeSpecifier -> Doc ann
pretty TypeSpecifier
tySpec = case TypeSpecifier
tySpec of
TypeSpecifier
VOID -> Doc ann
"void"
TypeSpecifier
BOOL -> Doc ann
"bool"
TypeSpecifier
CHAR -> Doc ann
"char"
TypeSpecifier
SHORT -> Doc ann
"short"
TypeSpecifier
INT -> Doc ann
"int"
TypeSpecifier
LONG -> Doc ann
"long"
TypeSpecifier
FLOAT -> Doc ann
"float"
TypeSpecifier
DOUBLE -> Doc ann
"double"
TypeSpecifier
SIGNED -> Doc ann
"signed"
TypeSpecifier
UNSIGNED -> Doc ann
"unsigned"
Struct CIdentifier
x -> Doc ann
"struct" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty CIdentifier
x
Enum CIdentifier
x -> Doc ann
"enum" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty CIdentifier
x
TypeName CIdentifier
x -> forall a ann. Pretty a => a -> Doc ann
pretty CIdentifier
x
Template CIdentifier
x [[TypeSpecifier]]
args ->
let concat_with_space :: [TypeSpecifier] -> Doc ann
concat_with_space = forall a. Monoid a => [a] -> a
mconcat forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. a -> [a] -> [a]
intersperse Doc ann
" ") forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty)
in forall a ann. Pretty a => a -> Doc ann
pretty CIdentifier
x forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"<" forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a. Monoid a => [a] -> a
mconcat (forall a. a -> [a] -> [a]
intersperse Doc ann
"," (forall a b. (a -> b) -> [a] -> [b]
map forall ann. [TypeSpecifier] -> Doc ann
concat_with_space [[TypeSpecifier]]
args)) forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
">"
TemplateConst String
x -> forall a ann. Pretty a => a -> Doc ann
pretty String
x
TemplatePointer TypeSpecifier
x -> forall a ann. Pretty a => a -> Doc ann
pretty TypeSpecifier
x forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"*"
instance Pretty TypeQualifier where
pretty :: forall ann. TypeQualifier -> Doc ann
pretty TypeQualifier
tyQual = case TypeQualifier
tyQual of
TypeQualifier
CONST -> Doc ann
"const"
TypeQualifier
RESTRICT -> Doc ann
"restrict"
TypeQualifier
VOLATILE -> Doc ann
"volatile"
instance Pretty FunctionSpecifier where
pretty :: forall ann. FunctionSpecifier -> Doc ann
pretty FunctionSpecifier
funSpec = case FunctionSpecifier
funSpec of
FunctionSpecifier
INLINE -> Doc ann
"inline"
instance Pretty i => Pretty (Declarator i) where
pretty :: forall ann. Declarator i -> Doc ann
pretty (Declarator [Pointer]
ptrs DirectDeclarator i
ddecltor) = case [Pointer]
ptrs of
[] -> forall a ann. Pretty a => a -> Doc ann
pretty DirectDeclarator i
ddecltor
Pointer
_:[Pointer]
_ -> forall ann. [Pointer] -> Doc ann
prettyPointers [Pointer]
ptrs forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty DirectDeclarator i
ddecltor
prettyPointers :: [Pointer] -> Doc ann
prettyPointers :: forall ann. [Pointer] -> Doc ann
prettyPointers [] = Doc ann
""
prettyPointers (Pointer
x : [Pointer]
xs) = forall a ann. Pretty a => a -> Doc ann
pretty Pointer
x forall a. Semigroup a => a -> a -> a
<> forall ann. [Pointer] -> Doc ann
prettyPointers [Pointer]
xs
instance Pretty Pointer where
pretty :: forall ann. Pointer -> Doc ann
pretty (Pointer [TypeQualifier]
tyQual) = Doc ann
"*" forall a. Semigroup a => a -> a -> a
<> forall ann. [Doc ann] -> Doc ann
hsep (forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty [TypeQualifier]
tyQual)
instance Pretty i => Pretty (DirectDeclarator i) where
pretty :: forall ann. DirectDeclarator i -> Doc ann
pretty DirectDeclarator i
decltor = case DirectDeclarator i
decltor of
DeclaratorRoot i
x -> forall a ann. Pretty a => a -> Doc ann
pretty i
x
DeclaratorParens Declarator i
x -> Doc ann
"(" forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty Declarator i
x forall a. Semigroup a => a -> a -> a
<> Doc ann
")"
ArrayOrProto DirectDeclarator i
ddecltor ArrayOrProto i
aorp -> forall a ann. Pretty a => a -> Doc ann
pretty DirectDeclarator i
ddecltor forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty ArrayOrProto i
aorp
instance Pretty i => Pretty (ArrayOrProto i) where
pretty :: forall ann. ArrayOrProto i -> Doc ann
pretty ArrayOrProto i
aorp = case ArrayOrProto i
aorp of
Array ArrayType i
x -> Doc ann
"[" forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty ArrayType i
x forall a. Semigroup a => a -> a -> a
<> Doc ann
"]"
Proto [ParameterDeclaration i]
x -> Doc ann
"(" forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => [a] -> Doc ann
prettyParams [ParameterDeclaration i]
x forall a. Semigroup a => a -> a -> a
<> Doc ann
")"
prettyParams :: (Pretty a) => [a] -> Doc ann
prettyParams :: forall a ann. Pretty a => [a] -> Doc ann
prettyParams [a]
xs = case [a]
xs of
[] -> Doc ann
""
[a
x] -> forall a ann. Pretty a => a -> Doc ann
pretty a
x
a
x : xs' :: [a]
xs'@(a
_:[a]
_) -> forall a ann. Pretty a => a -> Doc ann
pretty a
x forall a. Semigroup a => a -> a -> a
<> Doc ann
"," forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => [a] -> Doc ann
prettyParams [a]
xs'
instance Pretty i => Pretty (ArrayType i) where
pretty :: forall ann. ArrayType i -> Doc ann
pretty ArrayType i
at = case ArrayType i
at of
ArrayType i
VariablySized -> Doc ann
"*"
SizedByInteger Integer
n -> forall a ann. Pretty a => a -> Doc ann
pretty Integer
n
SizedByIdentifier i
s -> forall a ann. Pretty a => a -> Doc ann
pretty i
s
ArrayType i
Unsized -> Doc ann
""
instance Pretty i => Pretty (ParameterDeclaration i) where
pretty :: forall ann. ParameterDeclaration i -> Doc ann
pretty (ParameterDeclaration [DeclarationSpecifier]
declSpecs DeclaratorOrAbstractDeclarator i
decltor) = case [DeclarationSpecifier]
declSpecs of
[] -> forall {ann}. Doc ann
decltorDoc
DeclarationSpecifier
_:[DeclarationSpecifier]
_ -> forall ann. [Doc ann] -> Doc ann
hsep (forall a b. (a -> b) -> [a] -> [b]
map forall a ann. Pretty a => a -> Doc ann
pretty [DeclarationSpecifier]
declSpecs) forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall {ann}. Doc ann
decltorDoc
where
decltorDoc :: Doc ann
decltorDoc = case DeclaratorOrAbstractDeclarator i
decltor of
IsDeclarator Declarator i
x -> forall a ann. Pretty a => a -> Doc ann
pretty Declarator i
x
IsAbstractDeclarator AbstractDeclarator i
x -> forall a ann. Pretty a => a -> Doc ann
pretty AbstractDeclarator i
x
instance Pretty i => Pretty (AbstractDeclarator i) where
pretty :: forall ann. AbstractDeclarator i -> Doc ann
pretty (AbstractDeclarator [Pointer]
ptrs Maybe (DirectAbstractDeclarator i)
mbDecltor) = case ([Pointer]
ptrs, Maybe (DirectAbstractDeclarator i)
mbDecltor) of
([Pointer]
_, Maybe (DirectAbstractDeclarator i)
Nothing) -> forall ann. [Pointer] -> Doc ann
prettyPointers [Pointer]
ptrs
([], Just DirectAbstractDeclarator i
x) -> forall a ann. Pretty a => a -> Doc ann
pretty DirectAbstractDeclarator i
x
(Pointer
_:[Pointer]
_, Just DirectAbstractDeclarator i
x) -> forall ann. [Pointer] -> Doc ann
prettyPointers [Pointer]
ptrs forall ann. Doc ann -> Doc ann -> Doc ann
<+> forall a ann. Pretty a => a -> Doc ann
pretty DirectAbstractDeclarator i
x
instance Pretty i => Pretty (DirectAbstractDeclarator i) where
pretty :: forall ann. DirectAbstractDeclarator i -> Doc ann
pretty DirectAbstractDeclarator i
ddecltor = case DirectAbstractDeclarator i
ddecltor of
AbstractDeclaratorParens AbstractDeclarator i
x -> Doc ann
"(" forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty AbstractDeclarator i
x forall a. Semigroup a => a -> a -> a
<> Doc ann
")"
ArrayOrProtoHere ArrayOrProto i
aop -> forall a ann. Pretty a => a -> Doc ann
pretty ArrayOrProto i
aop
ArrayOrProtoThere DirectAbstractDeclarator i
ddecltor' ArrayOrProto i
aop -> forall a ann. Pretty a => a -> Doc ann
pretty DirectAbstractDeclarator i
ddecltor' forall a. Semigroup a => a -> a -> a
<> forall a ann. Pretty a => a -> Doc ann
pretty ArrayOrProto i
aop
many1 :: CParser i m => m a -> m [a]
many1 :: forall i (m :: * -> *) a. CParser i m => m a -> m [a]
many1 m a
p = (:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m a
p forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many m a
p
cppIdentParser :: (Monad m, CharParsing m) => Bool -> IdentifierStyle m -> m [Char]
cppIdentParser :: forall (m :: * -> *).
(Monad m, CharParsing m) =>
Bool -> IdentifierStyle m -> m String
cppIdentParser Bool
useCpp IdentifierStyle m
s = m String
cidentParserWithNamespace
where
cidentParser :: m String
cidentParser = ((:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: * -> *). IdentifierStyle m -> m Char
_styleStart IdentifierStyle m
s forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (forall (m :: * -> *). IdentifierStyle m -> m Char
_styleLetter IdentifierStyle m
s) forall (m :: * -> *) a. Parsing m => m a -> String -> m a
<?> forall (m :: * -> *). IdentifierStyle m -> String
_styleName IdentifierStyle m
s)
cidentParserWithNamespace :: m String
cidentParserWithNamespace =
if Bool
useCpp
then
forall (m :: * -> *) a. Parsing m => m a -> m a
try (forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence [m String
cidentParser, (forall (m :: * -> *). CharParsing m => String -> m String
string String
"::"), m String
cidentParserWithNamespace]) forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
m String
cidentParser
else
m String
cidentParser
identNoLex :: (TokenParsing m, Monad m, IsString s) => Bool -> IdentifierStyle m -> m s
identNoLex :: forall (m :: * -> *) s.
(TokenParsing m, Monad m, IsString s) =>
Bool -> IdentifierStyle m -> m s
identNoLex Bool
useCpp IdentifierStyle m
s = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. IsString a => String -> a
fromString forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try forall a b. (a -> b) -> a -> b
$ do
String
name <- forall (m :: * -> *) a. TokenParsing m => Highlight -> m a -> m a
highlight (forall (m :: * -> *). IdentifierStyle m -> Highlight
_styleHighlight IdentifierStyle m
s) (forall (m :: * -> *).
(Monad m, CharParsing m) =>
Bool -> IdentifierStyle m -> m String
cppIdentParser Bool
useCpp IdentifierStyle m
s)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
HashSet.member String
name (forall (m :: * -> *). IdentifierStyle m -> HashSet String
_styleReserved IdentifierStyle m
s)) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => String -> m a
unexpected forall a b. (a -> b) -> a -> b
$ String
"reserved " forall a. [a] -> [a] -> [a]
++ forall (m :: * -> *). IdentifierStyle m -> String
_styleName IdentifierStyle m
s forall a. [a] -> [a] -> [a]
++ String
" " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
name
forall (m :: * -> *) a. Monad m => a -> m a
return String
name
ident' :: (TokenParsing m, Monad m, IsString s) => Bool -> IdentifierStyle m -> m s
ident' :: forall (m :: * -> *) s.
(TokenParsing m, Monad m, IsString s) =>
Bool -> IdentifierStyle m -> m s
ident' Bool
useCpp IdentifierStyle m
s = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. IsString a => String -> a
fromString forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. TokenParsing m => m a -> m a
token forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => m a -> m a
try forall a b. (a -> b) -> a -> b
$ do
String
name <- forall (m :: * -> *) a. TokenParsing m => Highlight -> m a -> m a
highlight (forall (m :: * -> *). IdentifierStyle m -> Highlight
_styleHighlight IdentifierStyle m
s) (forall (m :: * -> *).
(Monad m, CharParsing m) =>
Bool -> IdentifierStyle m -> m String
cppIdentParser Bool
useCpp IdentifierStyle m
s)
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (forall a. (Eq a, Hashable a) => a -> HashSet a -> Bool
HashSet.member String
name (forall (m :: * -> *). IdentifierStyle m -> HashSet String
_styleReserved IdentifierStyle m
s)) forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. Parsing m => String -> m a
unexpected forall a b. (a -> b) -> a -> b
$ String
"reserved " forall a. [a] -> [a] -> [a]
++ forall (m :: * -> *). IdentifierStyle m -> String
_styleName IdentifierStyle m
s forall a. [a] -> [a] -> [a]
++ String
" " forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show String
name
forall (m :: * -> *) a. Monad m => a -> m a
return String
name