From b6872f55d0082332b6514c539fb842ab796ef152 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 11 Apr 2017 09:21:59 -0400 Subject: [PATCH 01/10] Sort the imports. --- languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs b/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs index 4c6febd98..8694617e8 100644 --- a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs +++ b/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs @@ -1,6 +1,6 @@ module Text.Parser.TreeSitter.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 From c4233a7a34d5d056d38db7d2d269cc8ba88994af Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 11 Apr 2017 09:22:08 -0400 Subject: [PATCH 02/10] Export tree_sitter_ruby explicitly. --- languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs b/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs index 8694617e8..05938f8de 100644 --- a/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs +++ b/languages/ruby/src/Text/Parser/TreeSitter/Ruby.hs @@ -1,4 +1,6 @@ -module Text.Parser.TreeSitter.Ruby where +module Text.Parser.TreeSitter.Ruby +( tree_sitter_ruby +) where import Foreign.Ptr import Text.Parser.TreeSitter From 7e3698c7bbbf7421d09c10237303ca5e7add66f0 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 11 Apr 2017 11:50:17 -0400 Subject: [PATCH 03/10] Bump haskell-tree-sitter for TH grammar datatypes. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index e76073e4c..8b9b6681f 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit e76073e4c6ccb75af73f86ac9fe5fc5496e4d44f +Subproject commit 8b9b6681f0f167e4f52b217ab3421f1eacb736fd From bacba50ec52a2b4cf850b509e3ea5285ec606167 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Tue, 11 Apr 2017 11:50:59 -0400 Subject: [PATCH 04/10] Define the Grammar datatype using TemplateHaskell. --- semantic-diff.cabal | 1 + src/Language/Ruby/Syntax.hs | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 6d46614d3..d4d26dc69 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -108,6 +108,7 @@ library , regex-compat , semigroups , split + , template-haskell , text >= 1.2.1.3 , text-icu , these 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)) From 83dd7c15c2127f2f109b9220e5dd9ba86974316e Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 12 Apr 2017 10:13:07 -0400 Subject: [PATCH 05/10] Bump haskell-tree-sitter for better templated production datatypes. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 8b9b6681f..09d779494 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 8b9b6681f0f167e4f52b217ab3421f1eacb736fd +Subproject commit 09d7794946b1df524c34a3836723d20e532b2c54 From 99b574cdd1e1955c0b9e5c1db5966a61af81744b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 12 Apr 2017 10:44:07 -0400 Subject: [PATCH 06/10] Bump haskell-tree-sitter for inclusion of the symbol in `Node`. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 09d779494..24b4e445e 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 09d7794946b1df524c34a3836723d20e532b2c54 +Subproject commit 24b4e445ede6d8c1df55a1de0d20cf00a888f931 From be9c4a42ff65acca190b8dd3887add442e9c3c1f Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 12 Apr 2017 10:51:31 -0400 Subject: [PATCH 07/10] Add a typescript syntax module & grammar datatype. --- semantic-diff.cabal | 3 ++- src/Language/TypeScript/Syntax.hs | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/Language/TypeScript/Syntax.hs diff --git a/semantic-diff.cabal b/semantic-diff.cabal index d4d26dc69..981e79603 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -44,11 +44,12 @@ library , Language , Language.C , Language.JavaScript - , Language.TypeScript , Language.Markdown , Language.Go , Language.Ruby , Language.Ruby.Syntax + , Language.TypeScript + , Language.TypeScript.Syntax , Parser , Patch , Paths_semantic_diff 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 From eb8d0e3c1981623b809946ac0180b00cec3c3ba9 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 12 Apr 2017 10:53:04 -0400 Subject: [PATCH 08/10] Add a go syntax module & grammar datatype. --- semantic-diff.cabal | 1 + src/Language/Go/Syntax.hs | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/Language/Go/Syntax.hs diff --git a/semantic-diff.cabal b/semantic-diff.cabal index 981e79603..3b92de595 100644 --- a/semantic-diff.cabal +++ b/semantic-diff.cabal @@ -46,6 +46,7 @@ library , Language.JavaScript , Language.Markdown , Language.Go + , Language.Go.Syntax , Language.Ruby , Language.Ruby.Syntax , Language.TypeScript 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 From fb2c8930b0e89f5672f8e130077e68340364c84b Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 12 Apr 2017 11:49:30 -0400 Subject: [PATCH 09/10] Bump haskell-tree-sitter for better constructor naming. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 24b4e445e..0e6cc1486 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 24b4e445ede6d8c1df55a1de0d20cf00a888f931 +Subproject commit 0e6cc14863dd35ec301ac7b68c8ff8bd9168f588 From 9d6a8b438d4d010ce14e6e68fde8b0b9d413615a Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Wed, 12 Apr 2017 12:45:49 -0400 Subject: [PATCH 10/10] Bump haskell-tree-sitter for its bump of tree-sitter to master. --- vendor/haskell-tree-sitter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/haskell-tree-sitter b/vendor/haskell-tree-sitter index 0e6cc1486..3a5fe6203 160000 --- a/vendor/haskell-tree-sitter +++ b/vendor/haskell-tree-sitter @@ -1 +1 @@ -Subproject commit 0e6cc14863dd35ec301ac7b68c8ff8bd9168f588 +Subproject commit 3a5fe620364de5688857bc5f7f10f59ae7207a04