Skip to content

Add OCaml support #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@
[submodule "tree-sitter-c-sharp/vendor/tree-sitter-c-sharp"]
path = tree-sitter-c-sharp/vendor/tree-sitter-c-sharp
url = https://github.com/tree-sitter/tree-sitter-c-sharp
[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
3 changes: 3 additions & 0 deletions tree-sitter-ocaml/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# v0.1.0.0

* add tree-sitter-ocaml parser
2 changes: 2 additions & 0 deletions tree-sitter-ocaml/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-ocaml/TreeSitter/OCaml.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module TreeSitter.OCaml
( tree_sitter_ocaml
, getNodeTypesPath
, getTestCorpusDir
) where

import Foreign.Ptr
import TreeSitter.Language
import Paths_tree_sitter_ocaml

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

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

getTestCorpusDir :: IO FilePath
getTestCorpusDir = getDataFileName "vendor/tree-sitter-ocaml/corpus"
49 changes: 49 additions & 0 deletions tree-sitter-ocaml/tree-sitter-ocaml.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cabal-version: 2.4
name: tree-sitter-ocaml
version: 0.1.0.0
synopsis: Tree-sitter grammar/parser for OCaml
description: This package provides a parser for OCaml 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-ocaml
maintainer: rewinfrey@github.com
copyright: 2020 GitHub, Anton Kochkov
category: Tree-sitter, OCaml
build-type: Simple
data-files: vendor/tree-sitter-ocaml/src/node-types.json
, vendor/tree-sitter-ocaml/corpus/*.txt
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.OCaml
autogen-modules: Paths_tree_sitter_ocaml
other-modules: Paths_tree_sitter_ocaml
build-depends: base >= 4.12 && <4.14
, tree-sitter ^>= 0.9.0.0
Include-dirs: vendor/tree-sitter-ocaml/src
install-includes: tree_sitter/parser.h
c-sources: vendor/tree-sitter-ocaml/src/parser.c
, vendor/tree-sitter-ocaml/src/scanner.cc
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-ocaml/vendor/tree-sitter-ocaml
Submodule tree-sitter-ocaml added at 6b15a4