From 91d15699ce14c7cb854d31bae03d9aa5bf9da3de Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Wed, 12 Jul 2017 15:31:41 -0700 Subject: [PATCH] Assign slice expressions --- src/Language/Python/Syntax.hs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index e0281e1d4..52f6e6660 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -40,6 +40,7 @@ type Syntax = , Expression.Bitwise , Expression.Call , Expression.Comparison + , Expression.Enumeration , Expression.ScopeResolution , Expression.MemberAccess , Expression.Subscript @@ -163,6 +164,7 @@ expression = argument <|> memberAccess <|> notOperator <|> parameter + <|> slice <|> subscript <|> statement <|> tuple @@ -419,6 +421,13 @@ memberAccess = makeTerm <$> symbol Attribute <*> children (Expression.MemberAcce subscript :: Assignment subscript = makeTerm <$> symbol Subscript <*> children (Expression.Subscript <$> expression <*> many expression) +slice :: Assignment +slice = makeTerm <$> symbol Slice <*> children + (toEnumeration <$> ((emptyTerm <* symbol AnonColon <* source) <|> (expression <* symbol AnonColon <* source)) + <*> ((emptyTerm <* symbol AnonColon <* source) <|> (expression <* symbol AnonColon <* source) <|> (expression <|> emptyTerm)) + <*> (expression <|> emptyTerm)) + where toEnumeration start stop step = Expression.Enumeration start stop step + call :: Assignment call = makeTerm <$> symbol Call <*> children (Expression.Call <$> identifier <*> (symbol ArgumentList *> children (many expression) <|> some comprehension))