Skip to content

Commit

Permalink
Tidy up a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
thealmarty committed Jan 26, 2022
1 parent e3eadcc commit 3b0d9e1
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 49 deletions.
3 changes: 1 addition & 2 deletions plutus-core/executables/Common.hs
Expand Up @@ -72,7 +72,6 @@ class Executable p where

-- | Parse a program.
parseProgram ::
-- (AsParseError e, MonadError e m, PLC.MonadQuote m) =>
BSL.ByteString ->
Either (ParseErrorBundle T.Text PLC.ParseError) (p PLC.SourcePos)

Expand All @@ -89,7 +88,7 @@ class Executable p where
serialiseProgramFlat :: (Flat ann, PP.Pretty ann) => AstNameType -> p ann -> IO BSL.ByteString

-- | Read and deserialise a Flat-encoded UPLC AST
loadASTfromFlat :: AstNameType -> Input -> IO (p())
loadASTfromFlat :: AstNameType -> Input -> IO (p ())

-- | Instance for PLC program.
instance Executable PlcProg where
Expand Down
29 changes: 0 additions & 29 deletions plutus-core/plutus-core/src/PlutusCore/Default/Universe.hs
Expand Up @@ -135,35 +135,6 @@ instance Show (DefaultUni a) where
uniG `DefaultUniApply` _ `DefaultUniApply` _ -> noMoreTypeFunctions uniG
show DefaultUniData = "data"

-- -- See Note [Parsing horribly broken].
-- instance Parsable (SomeTypeIn (Kinded DefaultUni)) where
-- parse "bool" = Just . SomeTypeIn $ Kinded DefaultUniBool
-- parse "bytestring" = Just . SomeTypeIn $ Kinded DefaultUniByteString
-- parse "string" = Just . SomeTypeIn $ Kinded DefaultUniString
-- parse "integer" = Just . SomeTypeIn $ Kinded DefaultUniInteger
-- parse "unit" = Just . SomeTypeIn $ Kinded DefaultUniUnit
-- parse text = asum
-- [ do
-- aT <- Text.stripPrefix "[" text >>= Text.stripSuffix "]"
-- SomeTypeIn (Kinded a) <- parse aT
-- Refl <- checkStar @DefaultUni a
-- Just . SomeTypeIn . Kinded $ DefaultUniList a
-- , do
-- abT <- Text.stripPrefix "(" text >>= Text.stripSuffix ")"
-- -- Note that we don't allow whitespace after @,@ (but we could).
-- -- Anyway, looking for a single comma is just plain wrong, as we may have a nested
-- -- tuple (and it can be left- or right- or both-nested), so we're running into
-- -- the same parsing problem as with constants.
-- case Text.splitOn "," abT of
-- [aT, bT] -> do
-- SomeTypeIn (Kinded a) <- parse aT
-- Refl <- checkStar @DefaultUni a
-- SomeTypeIn (Kinded b) <- parse bT
-- Refl <- checkStar @DefaultUni b
-- Just . SomeTypeIn . Kinded $ DefaultUniPair a b
-- _ -> Nothing
-- ]

instance DefaultUni `Contains` Integer where knownUni = DefaultUniInteger
instance DefaultUni `Contains` BS.ByteString where knownUni = DefaultUniByteString
instance DefaultUni `Contains` Text.Text where knownUni = DefaultUniString
Expand Down
13 changes: 1 addition & 12 deletions plutus-core/plutus-core/src/PlutusCore/Parser/ParserCommon.hs
Expand Up @@ -136,10 +136,7 @@ defaultUniType = choice $ map try
, SomeTypeIn DefaultUniString <$ symbol "string"
, SomeTypeIn DefaultUniUnit <$ symbol "unit"
, SomeTypeIn DefaultUniBool <$ symbol "bool"
-- , SomeTypeIn DefaultUniProtoList <$ symbol "list"
-- , SomeTypeIn DefaultUniProtoPair <$ symbol "pair"
-- , SomeTypeIn DefaultUniApply <$ symbol "?" TODO need to make this an operator
]
] --TODO complete all defaultUni types

inParens :: Parser a -> Parser a
inParens = between (symbol "(") (symbol ")")
Expand Down Expand Up @@ -288,14 +285,6 @@ conBool = choice
, someValue False <$ symbol "False"
]

--TODO fix these (add parsing of constant after symbol?):
-- conPair :: Parser (Some (ValueOf DefaultUni))
-- conPair = someValue (,) <$ symbol "pair"
-- conList :: Parser (Some (ValueOf DefaultUni))
-- conList = someValue [] <$ symbol "list"
-- conData :: Parser (Some (ValueOf DefaultUni))
-- conData = someValue Data? <$ symbol "data"

constant :: Parser (Some (ValueOf DefaultUni))
constant = choice $ map try
[ inParens constant
Expand Down
7 changes: 1 addition & 6 deletions plutus-core/plutus-ir/src/PlutusIR/Parser.hs
Expand Up @@ -98,6 +98,7 @@ pTerm = choice $ map try
, builtinTerm
, unwrapTerm
]

-- Note that PIR programs do not actually carry a version number
-- we (optionally) parse it all the same so we can parse all PLC code
program :: Parser (Program TyName Name PLC.DefaultUni PLC.DefaultFun SourcePos)
Expand All @@ -108,9 +109,3 @@ program = whitespace >> do
Program p <$> pTerm
notFollowedBy anySingle
return prog

-- plcProgram :: Parser (PLC.Program TyName Name PLC.DefaultUni PLC.DefaultFun SourcePos)
-- plcProgram = whitespace >> do
-- prog <- inParens $ PLC.Program <$> wordPos "program" <*> version <*> plcTerm
-- notFollowedBy anySingle
-- return prog

0 comments on commit 3b0d9e1

Please sign in to comment.