mirror of
https://github.com/github/semantic.git
synced 2024-12-24 15:35:14 +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 Eq1 Pattern where liftEq = genericLiftEq
|
||||||
instance Show1 Pattern where liftShowsPrec = genericLiftShowsPrec
|
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 }
|
data Let a = Let { letVariable :: !a, letValue :: !a, letBody :: !a }
|
||||||
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
deriving (Eq, Foldable, Functor, GAlign, Generic1, Show, Traversable)
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ statement = assertStatement
|
|||||||
<|> ifStatement
|
<|> ifStatement
|
||||||
<|> identifier
|
<|> identifier
|
||||||
<|> import'
|
<|> import'
|
||||||
|
<|> importAlias
|
||||||
<|> importFrom
|
<|> importFrom
|
||||||
<|> nonlocalStatement
|
<|> nonlocalStatement
|
||||||
<|> passStatement
|
<|> passStatement
|
||||||
@ -132,6 +133,7 @@ statement = assertStatement
|
|||||||
<|> returnStatement
|
<|> returnStatement
|
||||||
<|> tryStatement
|
<|> tryStatement
|
||||||
<|> whileStatement
|
<|> whileStatement
|
||||||
|
<|> wildcardImport
|
||||||
<|> withStatement
|
<|> withStatement
|
||||||
|
|
||||||
expressionStatement :: Assignment
|
expressionStatement :: Assignment
|
||||||
@ -354,6 +356,12 @@ import' = makeTerm <$> symbol ImportStatement <*> children (Declaration.Import <
|
|||||||
importFrom :: Assignment
|
importFrom :: Assignment
|
||||||
importFrom = makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> many expression)
|
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 :: Assignment
|
||||||
assertStatement = makeTerm <$ symbol AssertStatement <*> location <*> children (Expression.Call <$> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier <$> source)) <*> many expression)
|
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 a, b as c
|
||||||
import b.c as d
|
import b.c as d, e
|
||||||
|
Loading…
Reference in New Issue
Block a user