1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00
semantic/app/Main.hs

66 lines
2.5 KiB
Haskell
Raw Normal View History

2015-11-18 01:44:16 +03:00
module Main where
import Diff
import Patch
import Term
import Syntax
import Control.Comonad.Cofree
import Control.Monad.Free
import Data.Map
2015-11-21 00:21:09 +03:00
import Data.Maybe
import Data.Set
2015-11-20 19:36:54 +03:00
import Language.Haskell.Parser
import Language.Haskell.Syntax
import System.Environment
2015-11-24 21:15:45 +03:00
import GHC.Generics
import Foreign
import Foreign.CStorable
import Foreign.C.Types
2015-11-24 21:50:10 +03:00
import Foreign.C.String
2015-11-24 21:15:45 +03:00
data TSLanguage = TsLanguage deriving (Show, Eq, Generic, CStorable)
foreign import ccall "prototype/doubt-difftool/doubt-difftool-Bridging-Header.h ts_language_c" ts_language_c :: IO (Foreign.Ptr TSLanguage)
2015-11-24 21:23:29 +03:00
data TSDocument = TsDocument deriving (Show, Eq, Generic, CStorable)
foreign import ccall "prototype/External/tree-sitter/include/tree_sitter/runtime.h ts_document_make" ts_document_make :: IO (Foreign.Ptr TSDocument)
2015-11-24 21:45:12 +03:00
foreign import ccall "prototype/External/tree-sitter/include/tree_sitter/runtime.h ts_document_set_language" ts_document_set_language :: Foreign.Ptr TSDocument -> Foreign.Ptr TSLanguage -> IO ()
2015-11-24 21:50:10 +03:00
foreign import ccall "prototype/External/tree-sitter/include/tree_sitter/runtime.h ts_document_set_input_string" ts_document_set_input_string :: Foreign.Ptr TSDocument -> CString -> IO ()
2015-11-24 21:52:16 +03:00
foreign import ccall "prototype/External/tree-sitter/include/tree_sitter/runtime.h ts_document_parse" ts_document_parse :: Foreign.Ptr TSDocument -> IO ()
2015-11-24 21:53:13 +03:00
foreign import ccall "prototype/External/tree-sitter/include/tree_sitter/runtime.h ts_document_free" ts_document_free :: Foreign.Ptr TSDocument -> IO ()
2015-11-24 21:23:29 +03:00
data TSLength = TsLength CSize CSize
2015-11-24 22:13:41 +03:00
deriving (Show, Eq, Generic, CStorable)
2015-11-24 22:32:02 +03:00
data TSNode = TsNode (Foreign.Ptr ()) TSLength
2015-11-24 22:17:04 +03:00
deriving (Show, Eq, Generic, CStorable)
2015-11-24 22:16:56 +03:00
foreign import ccall "prototype/External/tree-sitter/include/tree_sitter/runtime.h ts_document_root_node" ts_document_root_node :: Foreign.Ptr TSDocument -> IO TSNode
2015-11-24 22:08:08 +03:00
2015-11-18 01:44:16 +03:00
main :: IO ()
2015-11-20 19:36:54 +03:00
main = do
2015-11-24 21:41:30 +03:00
-- args <- getArgs
-- return f
-- let (a, b) = files args in do
-- -- a' <- parseModuleFile a
-- -- b' <- parseModuleFile b
-- return f
-- return ()
document <- ts_document_make
2015-11-24 21:45:54 +03:00
language <- ts_language_c
2015-11-24 21:46:00 +03:00
ts_document_set_language document language
2015-11-24 21:51:18 +03:00
source <- newCString ""
2015-11-24 21:51:21 +03:00
ts_document_set_input_string document source
2015-11-24 21:52:45 +03:00
ts_document_parse document
root <- ts_document_root_node document
ts_document_free document
2015-11-24 21:53:42 +03:00
free source
2015-11-24 21:42:09 +03:00
putStrLn $ "cSizeOf " ++ show (cSizeOf document)
2015-11-20 19:36:54 +03:00
parseModuleFile :: FilePath -> IO (ParseResult HsModule)
parseModuleFile file = do
contents <- readFile file
return $ parseModule contents
files (a : as) = (a, file as) where
file (a : as) = a
2015-11-24 21:40:07 +03:00
files [] = error "expected two files to diff"