plutus-core- Language library for Plutus Core
Safe HaskellSafe-Inferred



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



newtype ParserState Source #





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


liftQuoteQuote a → ParsecT e s m a Source #