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

Safe Haskell | Safe-Inferred
Language | GHC2021

Language.Futhark.Parser.Monad

Contents

- Reexports

Description

Utility functions and definitions used in the Happy-generated parser. They are defined here because the `.y` file is opaque to linters and other tools. In particular, we cannot enable warnings for that file, because Happy-generated code is very dirty by GHC's standards.

Synopsis

- type ParserMonad = ExceptT SyntaxError (State ParserState)
- data ParserState
- data Comment = Comment {
  - commentLoc :: Loc
  - commentText :: Text
  }
- parse :: ParserMonad a -> FilePath -> Text -> Either SyntaxError a
- parseWithComments :: ParserMonad a -> FilePath -> Text -> Either SyntaxError (a, [Comment])
- lexer :: (L Token -> ParserMonad a) -> ParserMonad a
- mustBeEmpty :: Located loc => loc -> ValueType -> ParserMonad ()
- arrayFromList :: [a] -> Array Int a
- binOp :: UncheckedExp -> L Token -> UncheckedExp -> UncheckedExp
- binOpName :: L Token -> (QualName Name, Loc)
- mustBe :: L Token -> Text -> ParserMonad ()
- primNegate :: PrimValue -> PrimValue
- applyExp :: NonEmpty UncheckedExp -> ParserMonad UncheckedExp
- arrayLitExp :: [UncheckedExp] -> SrcLoc -> UncheckedExp
- addDocSpec :: DocComment -> SpecBase NoInfo Name -> SpecBase NoInfo Name
- addAttrSpec :: AttrInfo Name -> UncheckedSpec -> UncheckedSpec
- addDoc :: DocComment -> UncheckedDec -> UncheckedDec
- addAttr :: AttrInfo Name -> UncheckedDec -> UncheckedDec
- twoDotsRange :: Loc -> ParserMonad a
- data SyntaxError = SyntaxError {
  - syntaxErrorLoc :: Loc
  - syntaxErrorMsg :: Text
  }
- emptyArrayError :: Loc -> ParserMonad a
- parseError :: (L Token, [String]) -> ParserMonad a
- parseErrorAt :: Located loc => loc -> Maybe Text -> ParserMonad a
- backOneCol :: Loc -> Loc
- data L a
- data Token

# Documentation

type ParserMonad = ExceptT SyntaxError (State ParserState) Source #

data ParserState Source #

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 #

parse :: ParserMonad a -> FilePath -> Text -> Either SyntaxError a Source #

parseWithComments :: ParserMonad a -> FilePath -> Text -> Either SyntaxError (a, [Comment]) Source #

lexer :: (L Token -> ParserMonad a) -> ParserMonad a Source #

mustBeEmpty :: Located loc => loc -> ValueType -> ParserMonad () Source #

arrayFromList :: [a] -> Array Int a Source #

binOp :: UncheckedExp -> L Token -> UncheckedExp -> UncheckedExp Source #

binOpName :: L Token -> (QualName Name, Loc) Source #

mustBe :: L Token -> Text -> ParserMonad () Source #

primNegate :: PrimValue -> PrimValue Source #

applyExp :: NonEmpty UncheckedExp -> ParserMonad UncheckedExp Source #

arrayLitExp :: [UncheckedExp] -> SrcLoc -> UncheckedExp Source #

addDocSpec :: DocComment -> SpecBase NoInfo Name -> SpecBase NoInfo Name Source #

addAttrSpec :: AttrInfo Name -> UncheckedSpec -> UncheckedSpec Source #

addDoc :: DocComment -> UncheckedDec -> UncheckedDec Source #

addAttr :: AttrInfo Name -> UncheckedDec -> UncheckedDec Source #

twoDotsRange :: Loc -> ParserMonad a Source #

data SyntaxError Source #

A syntax error.

Constructors

SyntaxError |

Fields

- syntaxErrorLoc :: Loc
- syntaxErrorMsg :: Text

emptyArrayError :: Loc -> ParserMonad a Source #

parseError :: (L Token, [String]) -> ParserMonad a Source #

parseErrorAt :: Located loc => loc -> Maybe Text -> ParserMonad a Source #

backOneCol :: Loc -> Loc Source #

Move the end position back one column.

# Reexports

data L a Source #

A value of type `L a` is a value of type `a` with an associated `Loc`, but this location is ignored when performing comparisons.

#### Instances

Instances details

Functor L |
Instance details Defined in Data.Loc Methods fmap :: (a -> b) -> L a -> L b Source # (<$) :: a -> L b -> L a Source #
Data a => Data (L a) |

Instance details

Defined in Data.Loc

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> L a -> c (L a) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (L a) Source #

toConstr :: L a -> Constr Source #

dataTypeOf :: L a -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (L a)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (L a)) Source #

gmapT :: (forall b. Data b => b -> b) -> L a -> L a Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> L a -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> L a -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> L a -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> L a -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> L a -> m (L a) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> L a -> m (L a) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> L a -> m (L a) Source #

Show x => Show (L x) |
Instance details Defined in Data.Loc Methods showsPrec :: Int -> L x -> ShowS Source # show :: L x -> String Source # showList :: [L x] -> ShowS Source #
Eq x => Eq (L x) |
Instance details Defined in Data.Loc Methods (==) :: L x -> L x -> Bool Source # (/=) :: L x -> L x -> Bool Source #
Ord x => Ord (L x) |
Instance details Defined in Data.Loc Methods compare :: L x -> L x -> Ordering Source # (<) :: L x -> L x -> Bool Source # (<=) :: L x -> L x -> Bool Source # (>) :: L x -> L x -> Bool Source # (>=) :: L x -> L x -> Bool Source # max :: L x -> L x -> L x Source # min :: L x -> L x -> L x Source #
Pretty x => Pretty (L x) |
Instance details Defined in Text.PrettyPrint.Mainland.Class Methods ppr :: L x -> Doc Source # pprPrec :: Int -> L x -> Doc Source # pprList :: [L x] -> Doc Source #
Located (L a) |
Instance details Defined in Data.Loc Methods locOf :: L a -> Loc Source # locOfList :: [L a] -> Loc Source #
Relocatable (L a) |
Instance details Defined in Data.Loc Methods reloc :: Loc -> L a -> L a Source #

data Token Source #

A lexical token. It does not itself contain position information, so in practice the parser will consume tokens tagged with a source position.

#### Instances

Instances details

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