futhark-0.25.32: An optimising compiler for a functional, array-oriented language.

Safe Haskell | None
Language | GHC2021

Language.Futhark.Parser

Description

Interface to the Futhark parser.

Synopsis

- parseFuthark :: FilePath -> Text -> Either SyntaxError UncheckedProg
- parseFutharkWithComments :: FilePath -> Text -> Either SyntaxError (UncheckedProg, [Comment])
- parseExp :: FilePath -> Text -> Either SyntaxError UncheckedExp
- parseModExp :: FilePath -> Text -> Either SyntaxError (ModExpBase (NoInfo :: Type -> Type) Name)
- parseType :: FilePath -> Text -> Either SyntaxError UncheckedTypeExp
- parseDecOrExp :: FilePath -> Text -> Either SyntaxError (Either UncheckedDec UncheckedExp)
- data SyntaxError = SyntaxError {
  - syntaxErrorLoc :: Loc
  - syntaxErrorMsg :: Text
  }
- data Comment = Comment {
  - commentLoc :: Loc
  - commentText :: Text
  }

# Documentation

parseFuthark :: FilePath -> Text -> Either SyntaxError UncheckedProg Source #

Parse an entire Futhark program from the given `Text`, using the `FilePath` as the source name for error messages.

parseFutharkWithComments :: FilePath -> Text -> Either SyntaxError (UncheckedProg, [Comment]) Source #

Parse an entire Futhark program from the given `Text`, using the `FilePath` as the source name for error messages. Also returns the comments encountered.

parseExp :: FilePath -> Text -> Either SyntaxError UncheckedExp Source #

Parse an Futhark expression from the given `String`, using the `FilePath` as the source name for error messages.

parseModExp :: FilePath -> Text -> Either SyntaxError (ModExpBase (NoInfo :: Type -> Type) Name) Source #

Parse a Futhark module expression from the given `String`, using the `FilePath` as the source name for error messages.

parseType :: FilePath -> Text -> Either SyntaxError UncheckedTypeExp Source #

Parse an Futhark type from the given `String`, using the `FilePath` as the source name for error messages.

parseDecOrExp :: FilePath -> Text -> Either SyntaxError (Either UncheckedDec UncheckedExp) Source #

Parse either an expression or a declaration; favouring declarations in case of ambiguity.

data SyntaxError Source #

A syntax error.

Constructors

SyntaxError |

Fields

- syntaxErrorLoc :: Loc
- syntaxErrorMsg :: Text

data Comment Source #

A comment consists of its starting and end position, as well as its text. The contents include the comment start marker.

Constructors

Comment |

Fields

- commentLoc :: Loc
- commentText :: Text

#### Instances

Instances details

Show Comment Source # |
Instance details Defined in Language.Futhark.Parser.Monad Methods showsPrec :: Int -> Comment -> ShowS Source # show :: Comment -> String Source # showList :: [Comment] -> ShowS Source #
Eq Comment Source # |
Instance details Defined in Language.Futhark.Parser.Monad Methods (==) :: Comment -> Comment -> Bool Source # (/=) :: Comment -> Comment -> Bool Source #
Ord Comment Source # |
Instance details Defined in Language.Futhark.Parser.Monad Methods compare :: Comment -> Comment -> Ordering Source # (<) :: Comment -> Comment -> Bool Source # (<=) :: Comment -> Comment -> Bool Source # (>) :: Comment -> Comment -> Bool Source # (>=) :: Comment -> Comment -> Bool Source # max :: Comment -> Comment -> Comment Source # min :: Comment -> Comment -> Comment Source #
Located Comment Source # |
Instance details Defined in Language.Futhark.Parser.Monad Methods locOf :: Comment -> Loc Source # locOfList :: [Comment] -> Loc Source #