From 3c978b439896e957fb550acd68c9eaba39f5c83f Mon Sep 17 00:00:00 2001 From: Jim Hester Date: Mon, 7 Dec 2020 09:27:23 -0500 Subject: [PATCH] Add R support --- .gitmodules | 3 ++ tree-sitter-r/ChangeLog.md | 3 ++ tree-sitter-r/Setup.hs | 2 ++ tree-sitter-r/TreeSitter/R.hs | 17 +++++++++++ tree-sitter-r/tree-sitter-r.cabal | 47 ++++++++++++++++++++++++++++++ tree-sitter-r/vendor/tree-sitter-r | 1 + 6 files changed, 73 insertions(+) create mode 100644 tree-sitter-r/ChangeLog.md create mode 100644 tree-sitter-r/Setup.hs create mode 100644 tree-sitter-r/TreeSitter/R.hs create mode 100644 tree-sitter-r/tree-sitter-r.cabal create mode 160000 tree-sitter-r/vendor/tree-sitter-r diff --git a/.gitmodules b/.gitmodules index 6d5ab0a0..a072deb6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/tree-sitter-r/ChangeLog.md b/tree-sitter-r/ChangeLog.md new file mode 100644 index 00000000..3ad546fd --- /dev/null +++ b/tree-sitter-r/ChangeLog.md @@ -0,0 +1,3 @@ +# v0.1.0.0 + +* add tree-sitter-r parser diff --git a/tree-sitter-r/Setup.hs b/tree-sitter-r/Setup.hs new file mode 100644 index 00000000..9a994af6 --- /dev/null +++ b/tree-sitter-r/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/tree-sitter-r/TreeSitter/R.hs b/tree-sitter-r/TreeSitter/R.hs new file mode 100644 index 00000000..f2c5e113 --- /dev/null +++ b/tree-sitter-r/TreeSitter/R.hs @@ -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" diff --git a/tree-sitter-r/tree-sitter-r.cabal b/tree-sitter-r/tree-sitter-r.cabal new file mode 100644 index 00000000..3a367ad7 --- /dev/null +++ b/tree-sitter-r/tree-sitter-r.cabal @@ -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: jim.hester@rstudio.com +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 diff --git a/tree-sitter-r/vendor/tree-sitter-r b/tree-sitter-r/vendor/tree-sitter-r new file mode 160000 index 00000000..440a3088 --- /dev/null +++ b/tree-sitter-r/vendor/tree-sitter-r @@ -0,0 +1 @@ +Subproject commit 440a3088fbaf8aaaf00b6622b5423a990681cc2e