From f2d3b140325277b4f7da7e8762b53043e157a874 Mon Sep 17 00:00:00 2001 From: Ayman Nadeem Date: Wed, 29 Jan 2020 15:51:09 -0500 Subject: [PATCH] add Java grammar --- semantic-java/src/Language/Java.hs | 4 ++-- semantic-java/src/Language/Java/AST.hs | 2 +- semantic-java/src/Language/Java/Grammar.hs | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 semantic-java/src/Language/Java/Grammar.hs diff --git a/semantic-java/src/Language/Java.hs b/semantic-java/src/Language/Java.hs index a37798d53..293a16fd5 100644 --- a/semantic-java/src/Language/Java.hs +++ b/semantic-java/src/Language/Java.hs @@ -1,14 +1,14 @@ -- | Semantic functionality for Java programs. module Language.Java ( Term(..) -, TreeSitter.Java.tree_sitter_java +, Language.Java.Grammar.tree_sitter_java ) where import Data.Proxy import qualified Language.Java.AST as Java import qualified Language.Java.Tags as JavaTags import qualified Tags.Tagging.Precise as Tags -import qualified TreeSitter.Java (tree_sitter_java) +import qualified Language.Java.Grammar (tree_sitter_java) import qualified AST.Unmarshal as TS newtype Term a = Term { getTerm :: Java.Program a } diff --git a/semantic-java/src/Language/Java/AST.hs b/semantic-java/src/Language/Java/AST.hs index 90f2fe90b..274843883 100644 --- a/semantic-java/src/Language/Java/AST.hs +++ b/semantic-java/src/Language/Java/AST.hs @@ -15,7 +15,7 @@ module Language.Java.AST ) where import AST.GenerateSyntax -import qualified TreeSitter.Java as Grammar +import qualified Language.Java.Grammar as Grammar import AST.Token astDeclarationsForLanguage Grammar.tree_sitter_java "../../../vendor/tree-sitter-java/src/node-types.json" \ No newline at end of file diff --git a/semantic-java/src/Language/Java/Grammar.hs b/semantic-java/src/Language/Java/Grammar.hs new file mode 100644 index 000000000..6cd1c44eb --- /dev/null +++ b/semantic-java/src/Language/Java/Grammar.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TemplateHaskell #-} +module Language.Java.Grammar +( tree_sitter_java +, Grammar(..) +) where + +import Language.Haskell.TH +import TreeSitter.Java.Internal +import TreeSitter.Language + +-- Regenerate template haskell code when these files change: +addDependentFileRelative "../../../vendor/tree-sitter-java/src/parser.c" + +-- | Statically-known rules corresponding to symbols in the grammar. +mkSymbolDatatype (mkName "Grammar") tree_sitter_java