plutus-core-1.30.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

PlutusCore.Parser.ParserCommon

Description

Common functions for parsers of UPLC, PLC, and PIR.

Synopsis

Documentation

newtype ParserState Source #

Constructors

ParserState 

Fields

Instances

Instances details
Show ParserState Source # 
Instance details

Defined in PlutusCore.Parser.ParserCommon

type Parser = ParsecT ParserError Text (StateT ParserState (ReaderT (Maybe Version) Quote)) Source #

intern ∷ (MonadState ParserState m, MonadQuote m) ⇒ Text → m Unique Source #

Return the unique identifier of a name. If it's not in the current parser state, map the name to a fresh id and add it to the state. Used in the Name parser.

getVersionParser (Maybe Version) Source #

Get the version of the program being parsed, if we know it.

withVersionVersionParser a → Parser a Source #

Set the version of the program being parsed.

whenVersion ∷ (VersionBool) → 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 #

toErrorBEither (ParseErrorBundle Text ParserError) a → Either ParserErrorBundle 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".

whitespaceParser () Source #

Space consumer.

withSpan' ∷ (SrcSpanParser 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 ∷ (SrcSpanParser a) → Parser a Source #

Like withSpan', but the result parser consumes whitespaces.

@withSpan = (<* whitespace) . withSpan'

symbol ∷ Text → Parser Text Source #

nameParser Name Source #

Parses a Name. Does not consume leading or trailing whitespaces.

Orphan instances

(Stream s, MonadQuote m) ⇒ MonadQuote (ParsecT e s m) Source # 
Instance details

Methods

liftQuoteQuote a → ParsecT e s m a Source #