1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 21:16:12 +03:00

Parse out ImportSymbols for Python

This commit is contained in:
Timothy Clem 2018-01-30 12:39:10 -08:00
parent 9e977ebb71
commit bfdf50b67a

View File

@ -372,8 +372,12 @@ comment = makeTerm <$> symbol Comment <*> (Comment.Comment <$> source)
import' :: Assignment
import' = makeTerm'' <$> symbol ImportStatement <*> children (manyTerm (aliasedImport <|> plainImport))
<|> makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> expression <*> emptyTerm <*> (pure <$> (wildCard <|> expressions)))
-- <|> makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> expression <*> emptyTerm <*> (pure <$> (wildCard <|> expressions)))
<|> makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> expression <*> emptyTerm <*> ((pure <$> wildCard <|> importSymbols)))
where
importSymbols = many (makeTerm <$> location <*> (Declaration.ImportSymbol <$> expression <*> emptyTerm))
-- importSymbols = makeTerm'' <$> location <*> fmap (\e -> Declaration.ImportSymbol e emptyTerm) (manyTerm expression)
-- expressions = makeTerm'' <$> location <*> manyTerm expression
aliasedImport = makeTerm <$> symbol AliasedImport <*> children (Declaration.Import <$> expression <*> expression <*> pure [])
plainImport = makeTerm <$> symbol DottedName <*> children (Declaration.Import <$> expression <*> emptyTerm <*> pure [])
wildCard = makeTerm <$> symbol WildcardImport <*> (Syntax.Identifier <$> source)