From 561dee4753172c0b42ab6216ac0e0a810968d0c7 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 17 May 2017 17:31:55 -0700 Subject: [PATCH] Add questions for statements --- src/Language/Python/Syntax.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index 39e27a549..e7e0b9da2 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -136,6 +136,17 @@ importFrom = makeTerm <$> symbol ImportFromStatement <*> (Declaration.Import <$> -- TODO How should we assign chevron for print statements? chevron :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) chevron = makeTerm <$> symbol Chevron <*> (Syntax.Empty <$ source) + +-- TODO How to convert statements like this into a `Expression.Call`? The (pack "assert") produces a ByteString but that reduces the `Call` constructor to only accepting byteStrings. +-- assertStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) +-- assertStatement = makeTerm <$> symbol AssertStatement <*> children (Expression.Call <$> (symbol AnonAssert *> pack "assert" <$> many expression)) + +-- printStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) +-- printStatement = makeTerm <$ symbol PrintStatement <*> location <*> children (Expression.Call (pack "print") <$> source) + +-- globalStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) +-- globalStatement = makeTerm <$ symbol GlobalStatement <*> location <*> children (some identifier) + returnStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) returnStatement = makeTerm <$> symbol ReturnStatement <*> children (Statement.Return <$> (symbol ExpressionList *> children (statement <|> literal)))