{-# OPTIONS  #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Language.C.Parser
-- Copyright   :  (c) 2008 Benedikt Huber
-- License     :  BSD-style
-- Maintainer  : benedikt.huber@gmail.com
-- Stability   : experimental
-- Portability : ghc
--
-- Language.C parser
-----------------------------------------------------------------------------
module Language.C.Parser (
    -- * Simple API
    parseC,
    -- * Parser Monad
    P,execParser,execParser_,builtinTypeNames,
    -- * Exposed Parsers
    translUnitP, extDeclP, statementP, expressionP,
    -- * Parser Monad
    ParseError(..)
)
where
import Language.C.Parser.Parser (parseC,translUnitP, extDeclP, statementP, expressionP)
import Language.C.Parser.ParserMonad (execParser, ParseError(..),P)
import Language.C.Parser.Builtin (builtinTypeNames)

import Language.C.Data

-- | run the given parser using a new name supply and builtin typedefs
--   see 'execParser'
--
-- Synopsis: @runParser parser inputStream initialPos@
execParser_ :: P a -> InputStream -> Position -> Either ParseError a
execParser_ :: forall a. P a -> InputStream -> Position -> Either ParseError a
execParser_ P a
parser InputStream
input Position
pos =
  ((a, [Name]) -> a)
-> Either ParseError (a, [Name]) -> Either ParseError a
forall a b. (a -> b) -> Either ParseError a -> Either ParseError b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a, [Name]) -> a
forall a b. (a, b) -> a
fst (Either ParseError (a, [Name]) -> Either ParseError a)
-> Either ParseError (a, [Name]) -> Either ParseError a
forall a b. (a -> b) -> a -> b
$ P a
-> InputStream
-> Position
-> [Ident]
-> [Name]
-> Either ParseError (a, [Name])
forall a.
P a
-> InputStream
-> Position
-> [Ident]
-> [Name]
-> Either ParseError (a, [Name])
execParser P a
parser InputStream
input Position
pos [Ident]
builtinTypeNames [Name]
newNameSupply