Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Common functions for parsers of UPLC, PLC, and PIR.
Synopsis
- newtype ParserState = ParserState {}
- type Parser = ParsecT ParserError Text (StateT ParserState (ReaderT (Maybe Version) Quote))
- initial ∷ ParserState
- getVersion ∷ Parser (Maybe Version)
- withVersion ∷ Version → Parser a → Parser a
- whenVersion ∷ (Version → Bool) → Parser () → Parser ()
- parse ∷ (AsParserErrorBundle e, MonadError e m, MonadQuote m) ⇒ Parser a → String → Text → m a
- toErrorB ∷ Either (ParseErrorBundle Text ParserError) a → Either ParserErrorBundle a
- parseGen ∷ (AsParserErrorBundle e, MonadError e m, MonadQuote m) ⇒ Parser a → Text → m a
- whitespace ∷ Parser ()
- leadingWhitespace ∷ Parser a → Parser a
- trailingWhitespace ∷ Parser a → Parser a
- withSpan' ∷ (SrcSpan → Parser a) → Parser a
- withSpan ∷ (SrcSpan → Parser a) → Parser a
- lexeme ∷ Parser a → Parser a
- symbol ∷ Text → Parser Text
- inParens ∷ Parser a → Parser a
- inBrackets ∷ Parser a → Parser a
- inBraces ∷ Parser a → Parser a
- toSrcSpan ∷ SourcePos → SourcePos → SrcSpan
- version ∷ Parser Version
- name ∷ Parser Name
Documentation
newtype ParserState Source #
Instances
Show ParserState Source # | |
Defined in PlutusCore.Parser.ParserCommon |
type Parser = ParsecT ParserError Text (StateT ParserState (ReaderT (Maybe Version) Quote)) Source #
getVersion ∷ Parser (Maybe Version) Source #
Get the version of the program being parsed, if we know it.
whenVersion ∷ (Version → Bool) → Parser () → Parser () Source #
Run an action conditionally based on a predicate on the version. If we don't know the version then the predicate is assumed to be false, i.e. we act if we _know_ the predicate is satisfied.
parse ∷ (AsParserErrorBundle e, MonadError e m, MonadQuote m) ⇒ Parser a → String → Text → m a Source #
parseGen ∷ (AsParserErrorBundle e, MonadError e m, MonadQuote m) ⇒ Parser a → Text → m a Source #
Generic parser function in which the file path is just "test".
whitespace ∷ Parser () Source #
Space consumer.
leadingWhitespace ∷ Parser a → Parser a Source #
trailingWhitespace ∷ Parser a → Parser a Source #
withSpan' ∷ (SrcSpan → Parser a) → Parser a Source #
Returns a parser for a
by calling the supplied function on the starting
and ending positions of a
.
The supplied function should usually return a parser that does not consume trailing whitespaces. Otherwise, the end position will be the first character after the trailing whitespaces.
withSpan ∷ (SrcSpan → Parser a) → Parser a Source #
Like withSpan'
, but the result parser consumes whitespaces.
@withSpan = (<* whitespace) . withSpan'
inBrackets ∷ Parser a → Parser a Source #