1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

Assign raise statements

This commit is contained in:
Rick Winfrey 2017-06-07 11:25:59 -07:00
parent d44d0c6df0
commit a264123196
2 changed files with 7 additions and 1 deletions

View File

@ -97,7 +97,7 @@ instance Show1 DoWhile where liftShowsPrec = genericLiftShowsPrec
-- Exception handling
newtype Throw a = Throw a
newtype Throw a = Throw [a]
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
instance Eq1 Throw where liftEq = genericLiftEq

View File

@ -55,6 +55,7 @@ type Syntax' =
, Statement.Assignment
, Statement.If
, Statement.Return
, Statement.Throw
, Statement.Yield
, Language.Python.Syntax.Ellipsis
, Syntax.Empty
@ -97,6 +98,7 @@ statement = assertStatement
<|> import'
<|> importFrom
<|> printStatement
<|> raiseStatement
<|> returnStatement
<|> deleteStatement
@ -113,6 +115,7 @@ expression = await
<|> conditionalExpression
<|> dottedName
<|> ellipsis
<|> expressionList
<|> lambda
<|> keywordIdentifier
<|> literal
@ -279,6 +282,9 @@ deleteStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Locati
deleteStatement = makeTerm <$> symbol DeleteStatement <*> children (Expression.Call <$> deleteIdentifier <* symbol ExpressionList <*> children (many expression))
where deleteIdentifier = makeTerm <$> symbol AnonDel <*> (Syntax.Identifier <$> source)
raiseStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
raiseStatement = makeTerm <$> symbol RaiseStatement <*> children (Statement.Throw <$> (many expression))
ifStatement :: HasCallStack => Assignment (Node Grammar) (Term Syntax Location)
ifStatement = makeTerm <$> symbol IfStatement <*> children (Statement.If <$> expression <*> statement <*> (flip (foldr makeElif) <$> many elifClause <*> optionalElse))
where elseClause = symbol ElseClause *> children statement