Skip to content

Commit

Permalink
Add R support
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhester committed Dec 7, 2020
1 parent 8a5a2b1 commit 3c978b4
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
[submodule "tree-sitter-ocaml/vendor/tree-sitter-ocaml"]
path = tree-sitter-ocaml/vendor/tree-sitter-ocaml
url = https://github.com/tree-sitter/tree-sitter-ocaml
[submodule "tree-sitter-r/vendor/tree-sitter-r"]
path = tree-sitter-r/vendor/tree-sitter-r
url = https://github.com/r-lib/tree-sitter-r
3 changes: 3 additions & 0 deletions tree-sitter-r/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# v0.1.0.0

* add tree-sitter-r parser
2 changes: 2 additions & 0 deletions tree-sitter-r/Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
17 changes: 17 additions & 0 deletions tree-sitter-r/TreeSitter/R.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module TreeSitter.R
( tree_sitter_r
, getNodeTypesPath
, getTestCorpusDir
) where

import Foreign.Ptr
import TreeSitter.Language
import Paths_tree_sitter_r

foreign import ccall unsafe "vendor/tree-sitter-r/src/parser.c tree_sitter_r" tree_sitter_r :: Ptr Language

getNodeTypesPath :: IO FilePath
getNodeTypesPath = getDataFileName "vendor/tree-sitter-r/src/node-types.json"

getTestCorpusDir :: IO FilePath
getTestCorpusDir = getDataFileName "vendor/tree-sitter-r/corpus"
47 changes: 47 additions & 0 deletions tree-sitter-r/tree-sitter-r.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
cabal-version: 2.4
name: tree-sitter-r
version: 0.1.0.0
synopsis: Tree-sitter grammar/parser for R
description: This package provides a parser for R suitable for use with the tree-sitter package.
license: BSD-3-Clause
homepage: https://github.com/tree-sitter/haskell-tree-sitter/tree/master/tree-sitter-r
maintainer: [email protected]
copyright: 2020 GitHub, RStudio
category: Tree-sitter, R
build-type: Simple
data-files: vendor/tree-sitter-r/src/node-types.json
extra-source-files: ChangeLog.md

common common
default-language: Haskell2010
ghc-options:
-Weverything
-Wno-all-missed-specialisations
-Wno-implicit-prelude
-Wno-missed-specialisations
-Wno-missing-import-lists
-Wno-missing-local-signatures
-Wno-monomorphism-restriction
-Wno-name-shadowing
-Wno-safe
-Wno-unsafe
if (impl(ghc >= 8.6))
ghc-options: -Wno-star-is-type
if (impl(ghc >= 8.8))
ghc-options: -Wno-missing-deriving-strategies

library
import: common
exposed-modules: TreeSitter.R
autogen-modules: Paths_tree_sitter_r
other-modules: Paths_tree_sitter_r
build-depends: base >= 4.12 && < 5
, tree-sitter ^>= 0.9.0.0
Include-dirs: vendor/tree-sitter-r/src
install-includes: tree_sitter/parser.h
c-sources: vendor/tree-sitter-r/src/parser.c
extra-libraries: stdc++

source-repository head
type: git
location: https://github.com/tree-sitter/haskell-tree-sitter
1 change: 1 addition & 0 deletions tree-sitter-r/vendor/tree-sitter-r
Submodule tree-sitter-r added at 440a30

0 comments on commit 3c978b4

Please sign in to comment.