mirror of
https://github.com/github/semantic.git
synced 2024-12-20 05:11:44 +03:00
Merge pull request #1194 from github/aliased-import
Assign aliased import
This commit is contained in:
commit
65a0e31b91
@ -38,7 +38,7 @@ newtype Pattern a = Pattern a
|
||||
instance Eq1 Pattern where liftEq = genericLiftEq
|
||||
instance Show1 Pattern where liftShowsPrec = genericLiftShowsPrec
|
||||
|
||||
|
||||
-- | A let statement or local binding, like 'a as b' or 'let a = b'.
|
||||
data Let a = Let { letVariable :: !a, letValue :: !a, letBody :: !a }
|
||||
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||
|
||||
|
@ -124,6 +124,7 @@ statement = assertStatement
|
||||
<|> ifStatement
|
||||
<|> identifier
|
||||
<|> import'
|
||||
<|> importAlias
|
||||
<|> importFrom
|
||||
<|> nonlocalStatement
|
||||
<|> passStatement
|
||||
@ -132,6 +133,7 @@ statement = assertStatement
|
||||
<|> returnStatement
|
||||
<|> tryStatement
|
||||
<|> whileStatement
|
||||
<|> wildcardImport
|
||||
<|> withStatement
|
||||
|
||||
expressionStatement :: Assignment
|
||||
@ -354,6 +356,12 @@ import' = makeTerm <$> symbol ImportStatement <*> children (Declaration.Import <
|
||||
importFrom :: Assignment
|
||||
importFrom = makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> many expression)
|
||||
|
||||
importAlias :: Assignment
|
||||
importAlias = makeTerm <$> symbol AliasedImport <*> children (flip Statement.Let <$> expression <*> expression <*> emptyTerm)
|
||||
|
||||
wildcardImport :: Assignment
|
||||
wildcardImport = makeTerm <$> symbol WildcardImport <*> (Syntax.Identifier <$> source)
|
||||
|
||||
assertStatement :: Assignment
|
||||
assertStatement = makeTerm <$ symbol AssertStatement <*> location <*> children (Expression.Call <$> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier <$> source)) <*> many expression)
|
||||
|
||||
|
4
test/fixtures/python/import-statement.A.py
vendored
4
test/fixtures/python/import-statement.A.py
vendored
@ -1,2 +1,2 @@
|
||||
import a, b
|
||||
import b.c as d
|
||||
import a, b as c
|
||||
import b.c as d, e
|
||||
|
Loading…
Reference in New Issue
Block a user