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

Merge pull request #1500 from github/python-fixes

Fix definition of plainImport
This commit is contained in:
Josh Vera 2018-02-13 20:38:02 -05:00 committed by GitHub
commit 13d311f544
13 changed files with 104 additions and 48 deletions

View File

@ -372,14 +372,14 @@ 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 <*> someTerm (wildCard <|> dottedName <|> aliasedSymbol <|> importSymbol))
<|> makeTerm <$> symbol ImportFromStatement <*> children (Declaration.Import <$> (dottedName <|> emptyTerm) <*> emptyTerm <*> someTerm (wildCard <|> dottedName <|> aliasedSymbol <|> importSymbol))
where
importSymbol = makeTerm <$> location <*> (Declaration.ImportSymbol <$> expression <*> emptyTerm)
aliasedSymbol = makeTerm <$> symbol AliasedImport <*> children (Declaration.ImportSymbol <$> expression <*> expression)
wildCard = makeTerm <$> symbol WildcardImport <*> (Syntax.Identifier <$> source)
aliasedImport = makeTerm <$> symbol AliasedImport <*> children (Declaration.Import <$> expression <*> expression <*> pure [])
plainImport = makeTerm <$> symbol DottedName <*> children (Declaration.Import <$> expression <*> emptyTerm <*> pure [])
plainImport = makeTerm <$> symbol DottedName <*> children (Declaration.Import <$> expressions <*> emptyTerm <*> pure [])
assertStatement :: Assignment
assertStatement = makeTerm <$> symbol AssertStatement <*> children (Expression.Call <$> pure [] <*> (makeTerm <$> symbol AnonAssert <*> (Syntax.Identifier <$> source)) <*> manyTerm expression <*> emptyTerm)

View File

@ -1,3 +1,5 @@
from a import b
from a import (b, c)
from a import *
from a.b import c
from . import b

View File

@ -2,3 +2,5 @@ from b import a
from b import (c, a)
from b import *
from b import a as x, b as y
from b.c import d
from . import d

View File

@ -35,4 +35,15 @@
{+(ImportSymbol
{+(ScopeResolution
{+(Identifier)+})+}
{+(Identifier)+})+})+})
{+(Identifier)+})+})+}
(Import
(ScopeResolution
{-(Identifier)-}
(Identifier)
{+(Identifier)+})
(Empty)
(ScopeResolution{(Identifier)->(Identifier)}))
(Import
(Empty)
(Empty)
(ScopeResolution{(Identifier)->(Identifier)})))

View File

@ -24,6 +24,16 @@
->(Identifier) })
(Empty)
(Identifier))
{+(Import
{+(ScopeResolution
{+(Identifier)+}
{+(Identifier)+})+}
{+(Empty)+}
{+(ScopeResolution{+(Identifier)+})+})+}
{+(Import
{+(Empty)+}
{+(Empty)+}
{+(ScopeResolution{+(Identifier)+})+})+}
{-(Import
{-(ScopeResolution
{-(Identifier)-})-}
@ -35,4 +45,14 @@
{-(ImportSymbol
{-(ScopeResolution
{-(Identifier)-})-}
{-(Identifier)-})-})-})
{-(Identifier)-})-})-}
{-(Import
{-(ScopeResolution
{-(Identifier)-}
{-(Identifier)-})-}
{-(Empty)-}
{-(ScopeResolution{-(Identifier)-})-})-}
{-(Import
{-(Empty)-}
{-(Empty)-}
{-(ScopeResolution{-(Identifier)-})-})-})

View File

@ -17,4 +17,14 @@
(ScopeResolution
(Identifier))
(Empty)
(Identifier)))
(Identifier))
(Import
(ScopeResolution
(Identifier)
(Identifier))
(Empty)
(ScopeResolution(Identifier)))
(Import
(Empty)
(Empty)
(ScopeResolution(Identifier))))

View File

@ -29,4 +29,14 @@
(ImportSymbol
(ScopeResolution
(Identifier))
(Identifier))))
(Identifier)))
(Import
(ScopeResolution
(Identifier)
(Identifier))
(Empty)
(ScopeResolution(Identifier)))
(Import
(Empty)
(Empty)
(ScopeResolution(Identifier))))

View File

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

View File

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

View File

@ -1,26 +1,16 @@
(Program
(
{+(Import
({+(Import
{+(Identifier)+}
{+(Empty)+})+}
(Import
(Identifier)
(Empty))
{-(Import
{-(ScopeResolution
{-(Identifier)-})-}
{-(Identifier)-})-})
{+(Empty)+})+}(Import(Identifier)(Empty))
{-(Import{-(ScopeResolution{-(Identifier)-})-}{-(Identifier)-})-})
{+(Import
{+(ScopeResolution
{+(Identifier)+}
{+(ScopeResolution
{+(Identifier)+}
{+(Identifier)+})+}
{+(Identifier)+})+}
{+(Identifier)+})+}
{-(
{-(Import
{-(ScopeResolution
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})-}
{-(Import
{-(Identifier)-}
{-(Empty)-})-})-})
{+(Import
{+({+(Identifier)+}{+(Identifier)+}{+(Identifier)+})+}
{+(Empty)+})+}
{-({-(Import{-(ScopeResolution{-(Identifier)-}{-(Identifier)-})-}{-(Identifier)-})-}
{-(Import{-(Identifier)-}{-(Empty)-})-})-}
{-(Import{-({-(Identifier)-}{-(Identifier)-}{-(Identifier)-})-}{-(Empty)-})-})

View File

@ -1,26 +1,31 @@
(Program
(
(
{-(Import
{-(Identifier)-}
{-(Empty)-})-}
(Import
(Identifier)
(Empty))
(Import
(Identifier)
(Empty))
{+(Import
{+(ScopeResolution
{+(Identifier)+})+}
{+(Identifier)+})+})
{+(
{+(Import
{+(ScopeResolution
{+(Identifier)+}
{+(Identifier)+})+}
{+(ScopeResolution{+(Identifier)+})+}
{+(Identifier)+})+}
{+(Import
)
{+({+
(Import
{+(ScopeResolution
{+(Identifier)+}
{+(Empty)+})+})+}
{-(Import
{-(ScopeResolution
{+(Identifier)+})+}
{+(Identifier)+})+}
{+(Import
{+(Identifier)+}
{+(Empty)+})+})+}
(Import
{(ScopeResolution
{-(Identifier)-}
{-(Identifier)-})-}
{-(Identifier)-})-})
{-(Identifier)-})->({+(Identifier)+}{+(Identifier)+}{+(Identifier)+})}
{(Identifier)->(Empty)})
{-(Import
{-({-(Identifier)-}{-(Identifier)-}{-(Identifier)-})-}
{-(Empty)-})-})

View File

@ -15,4 +15,5 @@
(Identifier))
(Import
(Identifier)
(Empty))))
(Empty)))
(Import((Identifier)(Identifier)(Identifier))(Empty)))

View File

@ -10,4 +10,7 @@
(ScopeResolution
(Identifier)
(Identifier))
(Identifier)))
(Identifier))
(Import
((Identifier) (Identifier) (Identifier))
(Empty)))