mirror of
https://github.com/github/semantic.git
synced 2024-11-24 08:54:07 +03:00
Delete all the Haskell parsing stuff.
This commit is contained in:
parent
b2ed7144e2
commit
217fd1529c
34
app/Main.hs
34
app/Main.hs
@ -23,44 +23,10 @@ main = do
|
|||||||
return (a', b')
|
return (a', b')
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
data Leaf =
|
|
||||||
HsQName HsQName
|
|
||||||
| HsCName HsCName
|
|
||||||
| HsImportDecl HsImportDecl
|
|
||||||
| HsName HsName
|
|
||||||
|
|
||||||
parseModuleFile :: FilePath -> IO (ParseResult HsModule)
|
parseModuleFile :: FilePath -> IO (ParseResult HsModule)
|
||||||
parseModuleFile file = do
|
parseModuleFile file = do
|
||||||
contents <- readFile file
|
contents <- readFile file
|
||||||
return $ parseModule contents
|
return $ parseModule contents
|
||||||
|
|
||||||
_info = Info Range { start = 0, end = 0 } Data.Set.empty
|
|
||||||
|
|
||||||
moduleToTerm :: HsModule -> Term Leaf Info
|
|
||||||
moduleToTerm (HsModule loc name exports imports declarations) = _info :< Indexed terms where
|
|
||||||
exportTerms = exportSpecToTerm <$> fromMaybe [] exports
|
|
||||||
importTerms = importDeclarationToTerm <$> imports
|
|
||||||
declarationTerms = declarationToTerm <$> declarations
|
|
||||||
terms = exportTerms ++ importTerms ++ declarationTerms
|
|
||||||
|
|
||||||
exportSpecToTerm :: HsExportSpec -> Term Leaf Info
|
|
||||||
exportSpecToTerm (HsEVar name) = qualifiedNameToTerm name
|
|
||||||
exportSpecToTerm (HsEAbs name) = qualifiedNameToTerm name
|
|
||||||
exportSpecToTerm (HsEThingAll name) = qualifiedNameToTerm name
|
|
||||||
exportSpecToTerm (HsEThingWith name components) = _info :< (Fixed $ qualifiedNameToTerm name : (componentNameToTerm <$> components))
|
|
||||||
|
|
||||||
qualifiedNameToTerm :: HsQName -> Term Leaf Info
|
|
||||||
qualifiedNameToTerm name = _info :< Leaf (HsQName name)
|
|
||||||
|
|
||||||
componentNameToTerm :: HsCName -> Term Leaf Info
|
|
||||||
componentNameToTerm name = _info :< Leaf (HsCName name)
|
|
||||||
|
|
||||||
importDeclarationToTerm :: HsImportDecl -> Term Leaf Info
|
|
||||||
importDeclarationToTerm declaration = _info :< Leaf (Main.HsImportDecl declaration)
|
|
||||||
|
|
||||||
declarationToTerm :: HsDecl -> Term Leaf Info
|
|
||||||
declarationToTerm (HsTypeDecl location name names ty) = _info :< Fixed [ _info :< Leaf (HsName name) ]
|
|
||||||
declarationToTerm (HsDataDecl location context name names constructors names2) = _info :< Fixed []
|
|
||||||
|
|
||||||
files (a : as) = (a, file as) where
|
files (a : as) = (a, file as) where
|
||||||
file (a : as) = a
|
file (a : as) = a
|
||||||
|
Loading…
Reference in New Issue
Block a user