purescript-0.15.15: PureScript Programming Language Compiler

Safe Haskell | None
Language | Haskell2010

Language.PureScript.CST.Monad

Synopsis

- type LexResult = Either (LexState, ParserError) SourceToken
- data LexState = LexState {
  - lexPos :: SourcePos
  - lexLeading :: [Comment LineFeed]
  - lexSource :: Text
  - lexStack :: LayoutStack
  }
- data ParserState = ParserState {
  - parserBuff :: [LexResult]
  - parserErrors :: [ParserError]
  - parserWarnings :: [ParserWarning]
  }
- newtype ParserM e s a = Parser (forall r. s -> (s -> e -> r) -> (s -> a -> r) -> r)
- type Parser = ParserM ParserError ParserState
- runParser :: ParserState -> Parser a -> (ParserState, Either (NonEmpty ParserError) a)
- runTokenParser :: Parser a -> [LexResult] -> Either (NonEmpty ParserError) ([ParserWarning], a)
- throw :: e -> ParserM e s a
- parseError :: SourceToken -> Parser a
- mkParserError :: LayoutStack -> [SourceToken] -> a -> ParserErrorInfo a
- addFailure :: [SourceToken] -> ParserErrorType -> Parser ()
- parseFail' :: [SourceToken] -> ParserErrorType -> Parser a
- parseFail :: SourceToken -> ParserErrorType -> Parser a
- addWarning :: [SourceToken] -> ParserWarningType -> Parser ()
- pushBack :: SourceToken -> Parser ()
- tryPrefix :: Parser a -> Parser b -> Parser (Maybe a, b)
- oneOf :: NonEmpty (Parser a) -> Parser a
- manyDelimited :: Token -> Token -> Token -> Parser a -> Parser [a]
- token :: Token -> Parser SourceToken
- munch :: Parser SourceToken

# Documentation

type LexResult = Either (LexState, ParserError) SourceToken #

data LexState #

Constructors

LexState |

Fields

- lexPos :: SourcePos
- lexLeading :: [Comment LineFeed]
- lexSource :: Text
- lexStack :: LayoutStack

#### Instances

Instances details

Show LexState # |
Instance details Defined in Language.PureScript.CST.Monad Methods showsPrec :: Int -> LexState -> ShowS # show :: LexState -> String # showList :: [LexState] -> ShowS #

data ParserState #

Constructors

ParserState |

Fields

- parserBuff :: [LexResult]
- parserErrors :: [ParserError]
- parserWarnings :: [ParserWarning]

#### Instances

Instances details

Show ParserState # |
Instance details Defined in Language.PureScript.CST.Monad Methods showsPrec :: Int -> ParserState -> ShowS # show :: ParserState -> String # showList :: [ParserState] -> ShowS #

newtype ParserM e s a #

A bare bones, CPS'ed `StateT s (Except e) a`.

Constructors

Parser (forall r. s -> (s -> e -> r) -> (s -> a -> r) -> r) |

#### Instances

Instances details

Applicative (ParserM e s) # |
Instance details Defined in Language.PureScript.CST.Monad Methods pure :: a -> ParserM e s a # (<*>) :: ParserM e s (a -> b) -> ParserM e s a -> ParserM e s b # liftA2 :: (a -> b -> c) -> ParserM e s a -> ParserM e s b -> ParserM e s c # (*>) :: ParserM e s a -> ParserM e s b -> ParserM e s b # (<*) :: ParserM e s a -> ParserM e s b -> ParserM e s a #
Functor (ParserM e s) # |
Instance details Defined in Language.PureScript.CST.Monad Methods fmap :: (a -> b) -> ParserM e s a -> ParserM e s b # (<$) :: a -> ParserM e s b -> ParserM e s a #
Monad (ParserM e s) # |
Instance details Defined in Language.PureScript.CST.Monad Methods (>>=) :: ParserM e s a -> (a -> ParserM e s b) -> ParserM e s b # (>>) :: ParserM e s a -> ParserM e s b -> ParserM e s b # return :: a -> ParserM e s a #

type Parser = ParserM ParserError ParserState #

runParser :: ParserState -> Parser a -> (ParserState, Either (NonEmpty ParserError) a) #

runTokenParser :: Parser a -> [LexResult] -> Either (NonEmpty ParserError) ([ParserWarning], a) #

throw :: e -> ParserM e s a #

parseError :: SourceToken -> Parser a #

mkParserError :: LayoutStack -> [SourceToken] -> a -> ParserErrorInfo a #

addFailure :: [SourceToken] -> ParserErrorType -> Parser () #

parseFail' :: [SourceToken] -> ParserErrorType -> Parser a #

parseFail :: SourceToken -> ParserErrorType -> Parser a #

addWarning :: [SourceToken] -> ParserWarningType -> Parser () #

pushBack :: SourceToken -> Parser () #

tryPrefix :: Parser a -> Parser b -> Parser (Maybe a, b) #

oneOf :: NonEmpty (Parser a) -> Parser a #

manyDelimited :: Token -> Token -> Token -> Parser a -> Parser [a] #

token :: Token -> Parser SourceToken #

munch :: Parser SourceToken #