Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- type Parser = ReaderT LetEnv (Parsec CustomParserException Text)
- program :: Parsec CustomParserException Text (Contract' ParsedOp)
- value :: Parser ParsedValue
- data CustomParserException
- data ParseErrorBundle s e
- data ParserException = ParserException (ParseErrorBundle Text CustomParserException)
- data StringLiteralParserException
- data MichelsonSource where
- MSFile FilePath
- MSName Text
- MSCode SrcLoc
- MSUnspecified
- pattern MSStdin :: MichelsonSource
- pattern MSCli :: MichelsonSource
- codeSrc :: HasCallStack => MichelsonSource
- parseNoEnv :: Parser a -> MichelsonSource -> Text -> Either (ParseErrorBundle Text CustomParserException) a
- parseValue :: MichelsonSource -> Text -> Either ParserException ParsedValue
- parseExpandValue :: MichelsonSource -> Text -> Either ParserException Value
- codeEntry :: Parser [ParsedOp]
- ops :: Parser [ParsedOp]
- type_ :: Parser Ty
- letInner :: Parser ParsedOp -> Parser LetEnv
- letType :: Parser LetType
- stringLiteral :: Parser ParsedValue
- bytesLiteral :: Parser (Value' op)
- intLiteral :: Parser (Value' op)
- parsedOp :: Parser ParsedOp
- printComment :: Parser PrintComment
- utypeQ :: QuasiQuoter
- uparamTypeQ :: QuasiQuoter
- errorBundlePretty :: (VisualStream s, TraversableStream s, ShowErrorComponent e) => ParseErrorBundle s e -> String
Main parser type
Parsers
program :: Parsec CustomParserException Text (Contract' ParsedOp) Source #
Michelson contract with let definitions
Errors
data CustomParserException Source #
Instances
data ParseErrorBundle s e #
A non-empty collection of ParseError
s equipped with PosState
that
allows to pretty-print the errors efficiently and correctly.
Since: megaparsec-7.0.0
Instances
data ParserException Source #
Instances
Eq ParserException Source # | |
Defined in Morley.Michelson.Parser.Error (==) :: ParserException -> ParserException -> Bool # (/=) :: ParserException -> ParserException -> Bool # | |
Show ParserException Source # | |
Defined in Morley.Michelson.Parser.Error showsPrec :: Int -> ParserException -> ShowS # show :: ParserException -> String # showList :: [ParserException] -> ShowS # | |
Exception ParserException Source # | |
Defined in Morley.Michelson.Parser.Error | |
Buildable ParserException Source # | |
Defined in Morley.Michelson.Parser.Error build :: ParserException -> Builder # |
data StringLiteralParserException Source #
Instances
Additional helpers
data MichelsonSource Source #
Where a contract or value in Michelson comes from.
MSFile FilePath | From given file. |
MSName Text | Only source name is known. |
MSCode SrcLoc | Defined in Haskell code. |
MSUnspecified | Some unknown source. |
pattern MSStdin :: MichelsonSource | Designates |
pattern MSCli :: MichelsonSource | Designates command line input source. |
Instances
Eq MichelsonSource Source # | |
Defined in Morley.Michelson.Parser.Types (==) :: MichelsonSource -> MichelsonSource -> Bool # (/=) :: MichelsonSource -> MichelsonSource -> Bool # | |
Show MichelsonSource Source # | |
Defined in Morley.Michelson.Parser.Types showsPrec :: Int -> MichelsonSource -> ShowS # show :: MichelsonSource -> String # showList :: [MichelsonSource] -> ShowS # | |
IsString MichelsonSource Source # | |
Defined in Morley.Michelson.Parser.Types fromString :: String -> MichelsonSource # | |
Buildable MichelsonSource Source # | |
Defined in Morley.Michelson.Parser.Types build :: MichelsonSource -> Builder # |
codeSrc :: HasCallStack => MichelsonSource Source #
MichelsonSource
that points to the current position.
parseNoEnv :: Parser a -> MichelsonSource -> Text -> Either (ParseErrorBundle Text CustomParserException) a Source #
Parse with empty environment
parseValue :: MichelsonSource -> 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.
>>>
parseValue MSUnspecified "{PUSH int aaa}"
Left 1:11: | 1 | {PUSH int aaa} | ^^^^ unexpected "aaa}" expecting value
parseExpandValue :: MichelsonSource -> 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.
This parses arbitrary type expressions.
Note that this includes parenthesized ones for efficiency, see t_operator
.
That is to say, int
, (int)
, ((int))
, etc will match with this parser and produce TInt
.
bytesLiteral :: Parser (Value' op) Source #
intLiteral :: Parser (Value' op) Source #
parsedOp :: Parser ParsedOp Source #
>>>
first ParserException $ parseNoEnv parsedOp "" "{a}"
Left 1:2: | 1 | {a} | ^ unexpected 'a' expecting '{', '}', macro, morley instruction, or primitive instruction
Quoters
utypeQ :: QuasiQuoter Source #
Creates Ty
by its Morley representation.
>>>
[utypeQ| (int :a | nat :b) |]
Ty (TOr % % (Ty TInt :a) (Ty TNat :b)) :
>>>
[utypeQ|a|]
... | 1 | a | ^ unexpected 'a' expecting type ...
uparamTypeQ :: QuasiQuoter Source #
Creates ParameterType
by its Morley representation.
Re-exports
:: (VisualStream s, TraversableStream s, ShowErrorComponent e) | |
=> ParseErrorBundle s e | Parse error bundle to display |
-> String | Textual rendition of the bundle |
Pretty-print a ParseErrorBundle
. All ParseError
s 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