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:
parent
d44d0c6df0
commit
a264123196
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user