1
1
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:
Rick Winfrey 2017-07-11 09:31:11 -07:00 committed by GitHub
commit 65a0e31b91
3 changed files with 11 additions and 3 deletions

View File

@ -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)

View File

@ -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)

View File

@ -1,2 +1,2 @@
import a, b
import b.c as d
import a, b as c
import b.c as d, e