From 359e28d2dde562842b615534aad0f10531e95ecb Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 31 May 2017 11:17:16 -0700 Subject: [PATCH] Flow alternative choices over multiple lines --- src/Language/Python/Syntax.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index 0c0ccf461..cfbc7bdb8 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -61,11 +61,9 @@ instance Show1 Redirect where liftShowsPrec = genericLiftShowsPrec assignment :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) assignment = makeTerm <$> symbol Module <*> children (many declaration) - declaration :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) declaration = comment <|> literal <|> statement <|> import' <|> importFrom - statement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) statement = expressionStatement <|> ifStatement @@ -77,14 +75,21 @@ statement = expressionStatement <|> assertStatement <|> globalStatement -tuple :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) -tuple = makeTerm <$> symbol Tuple <*> children (Literal.Tuple <$> (many expression)) - expressionStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) expressionStatement = symbol ExpressionStatement *> children expression expression :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) -expression = statement <|> unaryOperator <|> binaryOperator <|> booleanOperator <|> tuple <|> literal <|> memberAccess <|> subscript +expression = statement + <|> unaryOperator + <|> binaryOperator + <|> booleanOperator + <|> tuple + <|> literal + <|> memberAccess + <|> subscript + +tuple :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location) +tuple = makeTerm <$> symbol Tuple <*> children (Literal.Tuple <$> (many expression)) -- TODO: Consider flattening single element lists expressionList :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)