diff --git a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs b/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs index 4c6febd98..05938f8de 100644 --- a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs +++ b/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs @@ -1,6 +1,8 @@ -module Text.Parser.TreeSitter.Ruby where +module Text.Parser.TreeSitter.Ruby +( tree_sitter_ruby +) where -import Text.Parser.TreeSitter import Foreign.Ptr +import Text.Parser.TreeSitter foreign import ccall unsafe "vendor/tree-sitter-ruby/src/parser.c tree_sitter_ruby" tree_sitter_ruby :: Ptr Language diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 0b861da5f..601df4dfe 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -44,11 +44,13 @@ library , Language , Language.C , Language.JavaScript - , Language.TypeScript , Language.Markdown , Language.Go + , Language.Go.Syntax , Language.Ruby , Language.Ruby.Syntax + , Language.TypeScript + , Language.TypeScript.Syntax , Parser , Patch , Paths_semantic_diff @@ -108,6 +110,7 @@ library , regex-compat , semigroups , split + , template-haskell , text >= 1.2.1.3 , text-icu , these diff --git a/src/Language/Go/Syntax.hs b/src/Language/Go/Syntax.hs new file mode 100644 index 000000000..6a966aa49 --- /dev/null +++ b/src/Language/Go/Syntax.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module Language.Go.Syntax where + +import Language.Haskell.TH +import Text.Parser.TreeSitter.Go +import Text.Parser.TreeSitter.Language + +-- | Statically-known rules corresponding to symbols in the grammar. +mkSymbolDatatype (mkName "Grammar") tree_sitter_go diff --git a/src/Language/Ruby/Syntax.hs b/src/Language/Ruby/Syntax.hs index 2723fbc46..89dd213c7 100644 --- a/src/Language/Ruby/Syntax.hs +++ b/src/Language/Ruby/Syntax.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DataKinds, TemplateHaskell #-} module Language.Ruby.Syntax where import Control.Monad.Free.Freer @@ -9,7 +9,10 @@ import qualified Data.Syntax.Comment as Comment import qualified Data.Syntax.Declaration as Declaration import qualified Data.Syntax.Literal as Literal import qualified Data.Syntax.Statement as Statement +import Language.Haskell.TH import Prologue +import Text.Parser.TreeSitter.Language +import Text.Parser.TreeSitter.Ruby -- | The type of Ruby syntax. type Syntax = Union @@ -29,8 +32,8 @@ type Program = Freer -- | Statically-known rules corresponding to symbols in the grammar. -data Grammar = Program | Uninterpreted | BeginBlock | EndBlock | Undef | Alias | Comment | True' | False' | Return | Yield | Break | Next | Redo | Retry | IfModifier | UnlessModifier | WhileModifier | UntilModifier | RescueModifier | While | Until | For | Do | Case | When | Pattern | If | Unless | Elsif | Else | Begin | Ensure | Rescue | Exceptions | ExceptionVariable | ElementReference | ScopeResolution | Call | MethodCall | ArgumentList | ArgumentListWithParens | SplatArgument | HashSplatArgument | BlockArgument | Class | Constant | Method | Identifier - deriving (Enum, Eq, Ord, Show) +mkSymbolDatatype (mkName "Grammar") tree_sitter_ruby + -- | Assignment from AST in Ruby’s grammar onto a program in Ruby’s syntax. assignment :: Assignment Grammar (Program Syntax (Maybe a)) diff --git a/src/Language/TypeScript/Syntax.hs b/src/Language/TypeScript/Syntax.hs new file mode 100644 index 000000000..4c8f60191 --- /dev/null +++ b/src/Language/TypeScript/Syntax.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell #-} +module Language.TypeScript.Syntax where + +import Language.Haskell.TH +import Text.Parser.TreeSitter.Language +import Text.Parser.TreeSitter.TypeScript + +-- | Statically-known rules corresponding to symbols in the grammar. +mkSymbolDatatype (mkName "Grammar") tree_sitter_typescript diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index e76073e4c..3a5fe6203 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit e76073e4c6ccb75af73f86ac9fe5fc5496e4d44f +Subproject commit 3a5fe620364de5688857bc5f7f10f59ae7207a04