mirror of
https://github.com/github/semantic.git
synced 2024-12-29 18:06:14 +03:00
Merge branch 'master' into distribute-alternation-through-binds-and-overlapping-committed-choices
This commit is contained in:
commit
bc5a98766c
@ -1,2 +0,0 @@
|
||||
import Distribution.Simple
|
||||
main = defaultMain
|
@ -1,25 +0,0 @@
|
||||
name: c
|
||||
version: 0.1.0
|
||||
synopsis: tree-sitter c language bindings
|
||||
description: Please see README.md
|
||||
homepage: https://github.com/github/semantic-diff#readme
|
||||
author: semantic-code
|
||||
maintainer: tclem@github.com
|
||||
copyright: 2017 GitHub
|
||||
category: Web
|
||||
build-type: Simple
|
||||
-- extra-source-files:
|
||||
cabal-version: >=1.10
|
||||
|
||||
library
|
||||
hs-source-dirs: src
|
||||
exposed-modules: Text.Parser.TreeSitter.C
|
||||
build-depends: base >= 4.7 && < 5
|
||||
, haskell-tree-sitter
|
||||
default-language: Haskell2010
|
||||
default-extensions: FlexibleInstances, OverloadedStrings, NoImplicitPrelude, RecordWildCards
|
||||
c-sources: vendor/tree-sitter-c/src/parser.c
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
location: https://github.com/github/semantic-diff
|
@ -1,6 +0,0 @@
|
||||
module Text.Parser.TreeSitter.C where
|
||||
|
||||
import Text.Parser.TreeSitter
|
||||
import Foreign.Ptr
|
||||
|
||||
foreign import ccall unsafe "vendor/tree-sitter-c/src/parser.c tree_sitter_c" tree_sitter_c :: Ptr Language
|
1
languages/c/vendor/tree-sitter-c
vendored
1
languages/c/vendor/tree-sitter-c
vendored
@ -1 +0,0 @@
|
||||
Subproject commit debe919f846e2f28dd4700e0cf39889e5fd5994a
|
@ -45,7 +45,6 @@ library
|
||||
, Info
|
||||
, Interpreter
|
||||
, Language
|
||||
, Language.C
|
||||
, Language.Markdown
|
||||
, Language.Markdown.Syntax
|
||||
, Language.Go
|
||||
@ -116,7 +115,6 @@ library
|
||||
, these
|
||||
, time
|
||||
, haskell-tree-sitter
|
||||
, c
|
||||
, go
|
||||
, ruby
|
||||
, typescript
|
||||
|
@ -10,9 +10,8 @@ import qualified Syntax as S
|
||||
import Term
|
||||
|
||||
-- | A programming language.
|
||||
data Language =
|
||||
C
|
||||
| Go
|
||||
data Language
|
||||
= Go
|
||||
| JavaScript
|
||||
| JSON
|
||||
| Markdown
|
||||
@ -24,8 +23,6 @@ data Language =
|
||||
-- | Returns a Language based on the file extension (including the ".").
|
||||
languageForType :: String -> Maybe Language
|
||||
languageForType mediaType = case mediaType of
|
||||
".h" -> Just C
|
||||
".c" -> Just C
|
||||
".json" -> Just JSON
|
||||
".md" -> Just Markdown
|
||||
".rb" -> Just Ruby
|
||||
|
@ -1,19 +0,0 @@
|
||||
{-# LANGUAGE DataKinds #-}
|
||||
module Language.C where
|
||||
|
||||
import Data.Source
|
||||
import Info
|
||||
import Prologue
|
||||
import qualified Syntax as S
|
||||
import Term
|
||||
|
||||
termAssignment
|
||||
:: Source -- ^ The source of the term.
|
||||
-> Category -- ^ The category for the term.
|
||||
-> [ SyntaxTerm DefaultFields ] -- ^ The child nodes of the term.
|
||||
-> Maybe (S.Syntax (SyntaxTerm DefaultFields)) -- ^ The resulting term, in Maybe.
|
||||
termAssignment _ _ _ = Nothing
|
||||
|
||||
|
||||
categoryForCProductionName :: Text -> Category
|
||||
categoryForCProductionName = Other
|
@ -30,7 +30,6 @@ import Syntax hiding (Go)
|
||||
import Term
|
||||
import qualified Text.Parser.TreeSitter as TS
|
||||
import Text.Parser.TreeSitter.Language (Symbol)
|
||||
import Text.Parser.TreeSitter.C
|
||||
import Text.Parser.TreeSitter.Go
|
||||
import Text.Parser.TreeSitter.Python
|
||||
import Text.Parser.TreeSitter.Ruby
|
||||
@ -58,7 +57,6 @@ data Parser term where
|
||||
parserForLanguage :: Maybe Language -> Parser (SyntaxTerm DefaultFields)
|
||||
parserForLanguage Nothing = LineByLineParser
|
||||
parserForLanguage (Just language) = case language of
|
||||
C -> TreeSitterParser tree_sitter_c
|
||||
Go -> TreeSitterParser tree_sitter_go
|
||||
JSON -> TreeSitterParser tree_sitter_json
|
||||
JavaScript -> TreeSitterParser tree_sitter_typescript
|
||||
|
@ -16,7 +16,6 @@ import Data.Source
|
||||
import Data.Span
|
||||
import qualified Data.Syntax.Assignment as A
|
||||
import Language
|
||||
import qualified Language.C as C
|
||||
import qualified Language.Go as Go
|
||||
import qualified Language.TypeScript as TS
|
||||
import qualified Language.Ruby as Ruby
|
||||
@ -27,7 +26,6 @@ import qualified Syntax as S
|
||||
import Term
|
||||
import Text.Parser.TreeSitter hiding (Language(..))
|
||||
import qualified Text.Parser.TreeSitter as TS
|
||||
import qualified Text.Parser.TreeSitter.C as TS
|
||||
import qualified Text.Parser.TreeSitter.Go as TS
|
||||
import qualified Text.Parser.TreeSitter.Ruby as TS
|
||||
import qualified Text.Parser.TreeSitter.TypeScript as TS
|
||||
@ -112,7 +110,6 @@ assignTerm language source annotation children allChildren =
|
||||
_ -> defaultTermAssignment source (category annotation) children allChildren
|
||||
where assignTermByLanguage :: Source -> Category -> [ SyntaxTerm DefaultFields ] -> Maybe (S.Syntax (SyntaxTerm DefaultFields))
|
||||
assignTermByLanguage = case languageForTSLanguage language of
|
||||
Just C -> C.termAssignment
|
||||
Just Language.Go -> Go.termAssignment
|
||||
Just Ruby -> Ruby.termAssignment
|
||||
Just TypeScript -> TS.termAssignment
|
||||
@ -166,7 +163,6 @@ categoryForLanguageProductionName = withDefaults . byLanguage
|
||||
s -> productionMap s
|
||||
|
||||
byLanguage language = case languageForTSLanguage language of
|
||||
Just C -> C.categoryForCProductionName
|
||||
Just Ruby -> Ruby.categoryForRubyName
|
||||
Just Language.Go -> Go.categoryForGoName
|
||||
Just TypeScript -> TS.categoryForTypeScriptName
|
||||
@ -175,8 +171,7 @@ categoryForLanguageProductionName = withDefaults . byLanguage
|
||||
|
||||
languageForTSLanguage :: Ptr TS.Language -> Maybe Language
|
||||
languageForTSLanguage = flip lookup
|
||||
[ (TS.tree_sitter_c, C)
|
||||
, (TS.tree_sitter_go, Language.Go)
|
||||
[ (TS.tree_sitter_go, Language.Go)
|
||||
, (TS.tree_sitter_ruby, Ruby)
|
||||
, (TS.tree_sitter_typescript, TypeScript)
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user