1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Print out the unified diff.

This commit is contained in:
Rob Rix 2015-11-27 12:42:00 -05:00
parent 070e60f149
commit 4aa89bd919

View File

@ -6,9 +6,12 @@ import Interpreter
import Patch
import Syntax
import Term
import Unified
import Control.Comonad.Cofree
import Control.Monad
import Control.Monad.Free hiding (unfoldM)
import qualified Data.Map as Map
import qualified Data.ByteString.Char8 as ByteString
import Data.Maybe
import Data.Set
import System.Environment
@ -51,18 +54,19 @@ foreign import ccall "app/bridge.h ts_node_p_size_chars" ts_node_p_size_chars ::
main :: IO ()
main = do
args <- getArgs
let (a, b) = files args in do
a' <- parseTreeSitterFile a
b' <- parseTreeSitterFile b
return $ interpret comparable a' b'
return ()
output <- let (a, b) = files args in do
aContents <- readFile a
bContents <- readFile b
aTerm <- parseTreeSitterFile aContents
bTerm <- parseTreeSitterFile bContents
unified (interpret comparable aTerm bTerm) aContents bContents
ByteString.putStr output
parseTreeSitterFile :: FilePath -> IO (Term String Info)
parseTreeSitterFile file = do
parseTreeSitterFile :: String -> IO (Term String Info)
parseTreeSitterFile contents = do
document <- ts_document_make
language <- ts_language_c
ts_document_set_language document language
contents <- readFile file
withCString contents (\source -> do
ts_document_set_input_string document source
ts_document_parse document