morley-1.7.0: Developer tools for the Michelson Language
Safe HaskellNone
LanguageHaskell2010

Michelson.Parser

Synopsis

Main parser type

Parsers

program :: Parsec CustomParserException Text (Contract' ParsedOp) Source #

Michelson contract with let definitions

Errors

data CustomParserException Source #

Instances

Instances details
Eq CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Data CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CustomParserException -> c CustomParserException #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CustomParserException #

toConstr :: CustomParserException -> Constr #

dataTypeOf :: CustomParserException -> DataType #

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

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

gmapT :: (forall b. Data b => b -> b) -> CustomParserException -> CustomParserException #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CustomParserException -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CustomParserException -> r #

gmapQ :: (forall d. Data d => d -> u) -> CustomParserException -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> CustomParserException -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CustomParserException -> m CustomParserException #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CustomParserException -> m CustomParserException #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CustomParserException -> m CustomParserException #

Ord CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Show CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Generic CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Associated Types

type Rep CustomParserException :: Type -> Type #

NFData CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Methods

rnf :: CustomParserException -> () #

ShowErrorComponent CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Default a => Default (Parser a) Source # 
Instance details

Defined in Michelson.Parser.Types

Methods

def :: Parser a #

type Rep CustomParserException Source # 
Instance details

Defined in Michelson.Parser.Error

type Rep CustomParserException = D1 ('MetaData "CustomParserException" "Michelson.Parser.Error" "morley-1.7.0-inplace" 'False) (((C1 ('MetaCons "UnknownTypeException" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "StringLiteralException" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 StringLiteralParserException))) :+: (C1 ('MetaCons "OddNumberBytesException" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WrongTagArgs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Positive)))) :+: ((C1 ('MetaCons "WrongAccessArgs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Positive)) :+: C1 ('MetaCons "WrongSetArgs" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Natural) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Positive))) :+: (C1 ('MetaCons "ExcessFieldAnnotation" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MultiRootAnnotationException" 'PrefixI 'False) (U1 :: Type -> Type))))

data ParseErrorBundle s e #

A non-empty collection of ParseErrors equipped with PosState that allows to pretty-print the errors efficiently and correctly.

Since: megaparsec-7.0.0

Instances

Instances details
(Eq s, Eq (Token s), Eq e) => Eq (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

(Data s, Data (Token s), Ord (Token s), Data e, Ord e) => Data (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ParseErrorBundle s e -> c (ParseErrorBundle s e) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ParseErrorBundle s e) #

toConstr :: ParseErrorBundle s e -> Constr #

dataTypeOf :: ParseErrorBundle s e -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ParseErrorBundle s e)) #

dataCast2 :: Typeable t => (forall d e0. (Data d, Data e0) => c (t d e0)) -> Maybe (c (ParseErrorBundle s e)) #

gmapT :: (forall b. Data b => b -> b) -> ParseErrorBundle s e -> ParseErrorBundle s e #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ParseErrorBundle s e -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ParseErrorBundle s e -> r #

gmapQ :: (forall d. Data d => d -> u) -> ParseErrorBundle s e -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ParseErrorBundle s e -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ParseErrorBundle s e -> m (ParseErrorBundle s e) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ParseErrorBundle s e -> m (ParseErrorBundle s e) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ParseErrorBundle s e -> m (ParseErrorBundle s e) #

(Show s, Show (Token s), Show e) => Show (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

Generic (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

Associated Types

type Rep (ParseErrorBundle s e) :: Type -> Type #

(Show s, Show (Token s), Show e, ShowErrorComponent e, Stream s, Typeable s, Typeable e) => Exception (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

(NFData s, NFData (Token s), NFData e) => NFData (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

Methods

rnf :: ParseErrorBundle s e -> () #

type Rep (ParseErrorBundle s e) 
Instance details

Defined in Text.Megaparsec.Error

type Rep (ParseErrorBundle s e) = D1 ('MetaData "ParseErrorBundle" "Text.Megaparsec.Error" "megaparsec-8.0.0-f2d82a512bed2c13e307d9cc9ac9be855c5332a59a60ea14f90b90adc50f1b21" 'False) (C1 ('MetaCons "ParseErrorBundle" 'PrefixI 'True) (S1 ('MetaSel ('Just "bundleErrors") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty (ParseError s e))) :*: S1 ('MetaSel ('Just "bundlePosState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PosState s))))

data StringLiteralParserException Source #

Instances

Instances details
Eq StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Data StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> StringLiteralParserException -> c StringLiteralParserException #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c StringLiteralParserException #

toConstr :: StringLiteralParserException -> Constr #

dataTypeOf :: StringLiteralParserException -> DataType #

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

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

gmapT :: (forall b. Data b => b -> b) -> StringLiteralParserException -> StringLiteralParserException #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> StringLiteralParserException -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> StringLiteralParserException -> r #

gmapQ :: (forall d. Data d => d -> u) -> StringLiteralParserException -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> StringLiteralParserException -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> StringLiteralParserException -> m StringLiteralParserException #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> StringLiteralParserException -> m StringLiteralParserException #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> StringLiteralParserException -> m StringLiteralParserException #

Ord StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Show StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Generic StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

Associated Types

type Rep StringLiteralParserException :: Type -> Type #

NFData StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

ShowErrorComponent StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

type Rep StringLiteralParserException Source # 
Instance details

Defined in Michelson.Parser.Error

type Rep StringLiteralParserException = D1 ('MetaData "StringLiteralParserException" "Michelson.Parser.Error" "morley-1.7.0-inplace" 'False) (C1 ('MetaCons "InvalidEscapeSequence" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char)) :+: C1 ('MetaCons "InvalidChar" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Char)))

Additional helpers

parseNoEnv :: Parser a -> String -> Text -> Either (ParseErrorBundle Text CustomParserException) a Source #

Parse with empty environment

parseValue :: Text -> Either ParserException ParsedValue Source #

Parse untyped value from text which comes from something that is not a file (which is often the case). So we assume it does not need any parsing environment.

parseExpandValue :: Text -> Either ParserException Value Source #

Like parseValue, but also expands macros.

For tests

codeEntry :: Parser [ParsedOp] Source #

Parses code block after "code" keyword of a contract.

This function is part of the module API, its semantics should not change.

letInner :: Parser ParsedOp -> Parser LetEnv Source #

Incrementally build the let environment

Quoters

utypeQ :: QuasiQuoter Source #

Creates Type by its Morley representation.

>>> [utypeQ| (int :a | nat :b) |]
Type (TOr % % (Type (Tc CInt) :a) (Type (Tc CNat) :b)) :

Re-exports

errorBundlePretty #

Arguments

:: (Stream s, ShowErrorComponent e) 
=> ParseErrorBundle s e

Parse error bundle to display

-> String

Textual rendition of the bundle

Pretty-print a ParseErrorBundle. All ParseErrors in the bundle will be pretty-printed in order together with the corresponding offending lines by doing a single efficient pass over the input stream. The rendered String always ends with a newline.

Since: megaparsec-7.0.0