Agda-2.5.2: A dependently typed functional programming language and proof assistant

Safe Haskell | None
Language | Haskell2010

Agda.Syntax.Parser

Contents

- Types
- Parse functions
- Parsers
- Parse errors

Synopsis

- data Parser a
- parse :: Parser a -> String -> PM a
- parsePosString :: Parser a -> Position -> String -> PM a
- parseFile' :: Show a => Parser a -> AbsolutePath -> PM a
- moduleParser :: Parser Module
- moduleNameParser :: Parser QName
- exprParser :: Parser Expr
- exprWhereParser :: Parser ExprWhere
- tokensParser :: Parser [Token]
- data ParseError
  - = ParseError {
    - errSrcFile :: !SrcFile
    - errPos :: !PositionWithoutFile
    - errInput :: String
    - errPrevToken :: String
    - errMsg :: String
    }
  - | OverlappingTokensError {
    - errRange :: !(Range' SrcFile)
    }
  - | InvalidExtensionError {
    - errPath :: !AbsolutePath
    - errValidExts :: [String]
    }
  - | ReadFileError {
    - errPath :: !AbsolutePath
    - errIOError :: IOError
    }
- data ParseWarning = OverlappingTokensWarning {
  - warnRange :: !(Range' SrcFile)
  }
- newtype PM a = PM {
  - unPM :: ExceptT ParseError (StateT [ParseWarning] IO) a
  }
- runPMIO :: MonadIO m => PM a -> m (Either ParseError a, [ParseWarning])

# Types

data Parser a #

Wrapped Parser type.

# Parse functions

parse :: Parser a -> String -> PM a #

parsePosString :: Parser a -> Position -> String -> PM a #

parseFile' :: Show a => Parser a -> AbsolutePath -> PM a #

# Parsers

moduleParser :: Parser Module #

Parses a module.

moduleNameParser :: Parser QName #

Parses a module name.

exprParser :: Parser Expr #

Parses an expression.

exprWhereParser :: Parser ExprWhere #

Parses an expression followed by a where clause.

tokensParser :: Parser [Token] #

Gives the parsed token stream (including comments).

# Parse errors

data ParseError #

What you get if parsing fails.

Constructors

ParseError | Errors that arise at a specific position in the file
Fields errSrcFile :: !SrcFile The file in which the error occurred. errPos :: !PositionWithoutFile Where the error occurred. errInput :: String The remaining input. errPrevToken :: String The previous token. errMsg :: String Hopefully an explanation of what happened.
OverlappingTokensError | Parse errors that concern a range in a file.
Fields errRange :: !(Range' SrcFile) The range of the bigger overlapping token
InvalidExtensionError | Parse errors that concern a whole file.
Fields errPath :: !AbsolutePath The file which the error concerns. errValidExts :: [String]
ReadFileError |
Fields errPath :: !AbsolutePath The file which the error concerns. errIOError :: IOError

Instances

Show ParseError # |
Methods showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS #
Pretty ParseError # |
Methods pretty :: ParseError -> Doc # prettyPrec :: Int -> ParseError -> Doc #
HasRange ParseError # |
Methods getRange :: ParseError -> Range #
MonadError ParseError Parser # |
Methods throwError :: ParseError -> Parser a # catchError :: Parser a -> (ParseError -> Parser a) -> Parser a #
MonadError ParseError PM # |
Methods throwError :: ParseError -> PM a # catchError :: PM a -> (ParseError -> PM a) -> PM a #

data ParseWarning #

Warnings for parsing

Constructors

OverlappingTokensWarning | Parse errors that concern a range in a file.
Fields warnRange :: !(Range' SrcFile) The range of the bigger overlapping token

Instances

Show ParseWarning # |
Methods showsPrec :: Int -> ParseWarning -> ShowS # show :: ParseWarning -> String # showList :: [ParseWarning] -> ShowS #
Pretty ParseWarning # |
Methods pretty :: ParseWarning -> Doc # prettyPrec :: Int -> ParseWarning -> Doc #
HasRange ParseWarning # |
Methods getRange :: ParseWarning -> Range #

newtype PM a #

A monad for handling parse results

Constructors

PM |
Fields unPM :: ExceptT ParseError (StateT [ParseWarning] IO) a

Instances

Monad PM # |
Methods (>>=) :: PM a -> (a -> PM b) -> PM b # (>>) :: PM a -> PM b -> PM b # return :: a -> PM a # fail :: String -> PM a #
Functor PM # |
Methods fmap :: (a -> b) -> PM a -> PM b # (<$) :: a -> PM b -> PM a #
Applicative PM # |
Methods pure :: a -> PM a # (<*>) :: PM (a -> b) -> PM a -> PM b # (*>) :: PM a -> PM b -> PM b # (<*) :: PM a -> PM b -> PM a #
MonadIO PM # |
Methods liftIO :: IO a -> PM a #
MonadError ParseError PM # |
Methods throwError :: ParseError -> PM a # catchError :: PM a -> (ParseError -> PM a) -> PM a #

runPMIO :: MonadIO m => PM a -> m (Either ParseError a, [ParseWarning]) #