1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

:note: Parsing.TreeSitter.

This commit is contained in:
Patrick Thomson 2020-01-27 11:20:38 -05:00
parent 5a713a3e01
commit 9755413808

View File

@ -1,5 +1,11 @@
{-# LANGUAGE DataKinds, DeriveGeneric, FlexibleContexts, GADTs, LambdaCase, RecordWildCards, ScopedTypeVariables,
TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
module Parsing.TreeSitter
( TSParseException (..)
, Duration(..)
@ -7,16 +13,19 @@ module Parsing.TreeSitter
, parseToPreciseAST
) where
import Prologue
import Control.Carrier.Reader
import qualified Control.Exception as Exc
import Foreign
import Foreign.C.Types (CBool (..))
import Control.Carrier.Reader
import Control.Exception as Exc
import Control.Monad
import Control.Monad.IO.Class
import Data.Functor.Foldable
import Foreign
import Foreign.C.Types (CBool (..))
import GHC.Generics
import Data.AST (AST, Node (Node))
import Data.Blob
import Data.Duration
import Data.Maybe.Exts
import Data.Term
import Source.Loc
import qualified Source.Source as Source
@ -67,7 +76,7 @@ parseToPreciseAST parseTimeout unmarshalTimeout language blob = runParse parseTi
withTimeout :: IO a -> IO a
withTimeout action = System.timeout (toMicroseconds unmarshalTimeout) action >>= maybeM (Exc.throw UnmarshalTimedOut)
instance Exception TSParseException where
instance Exc.Exception TSParseException where
displayException = \case
ParserTimedOut -> "tree-sitter: parser timed out"
IncompatibleVersions -> "tree-sitter: incompatible versions"