2015-11-18 01:44:16 +03:00
|
|
|
module Main where
|
|
|
|
|
2015-11-18 22:45:23 +03:00
|
|
|
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
|
2015-11-20 19:50:11 +03:00
|
|
|
import Data.Set
|
2015-11-20 19:36:54 +03:00
|
|
|
import Language.Haskell.Parser
|
|
|
|
import Language.Haskell.Syntax
|
|
|
|
import System.Environment
|
2015-11-18 22:45:23 +03:00
|
|
|
|
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
|
|
|
|
2015-11-24 21:23:18 +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-18 22:45:23 +03:00
|
|
|
|
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
|
|
|
|
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
|
2015-11-24 21:53:35 +03:00
|
|
|
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"
|