diff --git a/.gitmodules b/.gitmodules index 2c1358b5..ab3224c8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -139,3 +139,6 @@ [submodule "lang/semgrep-grammars/src/tree-sitter-gosu"] path = lang/semgrep-grammars/src/tree-sitter-gosu url = git@github.com:tarides/tree-sitter-gosu.git +[submodule "lang/semgrep-grammars/src/tree-sitter-scala"] + path = lang/semgrep-grammars/src/tree-sitter-scala + url = https://github.com/tree-sitter/tree-sitter-scala.git diff --git a/lang/Makefile b/lang/Makefile index 06c987d8..369f549a 100644 --- a/lang/Makefile +++ b/lang/Makefile @@ -52,6 +52,7 @@ SUPPORTED_TS_LANGUAGES = \ requirements \ ruby \ rust \ + scala \ sfapex \ sml \ solidity \ @@ -107,6 +108,7 @@ SUPPORTED_DIALECTS = \ r \ ruby \ rust \ + scala \ solidity \ sqlite \ swift \ @@ -150,6 +152,7 @@ STAT_LANGUAGES2 = \ r \ ruby \ rust \ + scala \ solidity \ tsx \ typescript diff --git a/lang/scala/Makefile b/lang/scala/Makefile new file mode 120000 index 00000000..16641521 --- /dev/null +++ b/lang/scala/Makefile @@ -0,0 +1 @@ +../Makefile.common \ No newline at end of file diff --git a/lang/scala/extensions.txt b/lang/scala/extensions.txt new file mode 100644 index 00000000..0f49d20a --- /dev/null +++ b/lang/scala/extensions.txt @@ -0,0 +1,6 @@ +# File extensions for the target language, one per line. This is used for +# collecting parsing stats from the repos specified in 'projects.txt'. e.g.: +# +# .h +# .c +# diff --git a/lang/scala/fyi.list b/lang/scala/fyi.list new file mode 100644 index 00000000..0bc6ab56 --- /dev/null +++ b/lang/scala/fyi.list @@ -0,0 +1,3 @@ +semgrep-grammars/src/tree-sitter-scala/LICENSE +semgrep-grammars/src/tree-sitter-scala/grammar.js +semgrep-grammars/src/semgrep-scala/grammar.js diff --git a/lang/scala/projects.txt b/lang/scala/projects.txt new file mode 100644 index 00000000..5f8b20ca --- /dev/null +++ b/lang/scala/projects.txt @@ -0,0 +1,3 @@ +# Git URLs of publicly-accessible projects to be used for parsing stats, +# one per line. +# diff --git a/lang/semgrep-grammars/lang/scala b/lang/semgrep-grammars/lang/scala new file mode 120000 index 00000000..07fa06d1 --- /dev/null +++ b/lang/semgrep-grammars/lang/scala @@ -0,0 +1 @@ +../src/semgrep-scala \ No newline at end of file diff --git a/lang/semgrep-grammars/src/semgrep-scala/Makefile b/lang/semgrep-grammars/src/semgrep-scala/Makefile new file mode 120000 index 00000000..16641521 --- /dev/null +++ b/lang/semgrep-grammars/src/semgrep-scala/Makefile @@ -0,0 +1 @@ +../Makefile.common \ No newline at end of file diff --git a/lang/semgrep-grammars/src/semgrep-scala/grammar.js b/lang/semgrep-grammars/src/semgrep-scala/grammar.js new file mode 100644 index 00000000..38453415 --- /dev/null +++ b/lang/semgrep-grammars/src/semgrep-scala/grammar.js @@ -0,0 +1,29 @@ +/* + semgrep-scala + + Extends the standard scala grammar with semgrep pattern constructs. +*/ + +const base_grammar = require('tree-sitter-scala/grammar'); + +module.exports = grammar(base_grammar, { + name: 'scala', + + conflicts: ($, previous) => previous.concat([ + ]), + + /* + Support for semgrep ellipsis ('...') and metavariables ('$FOO'), + if they're not already part of the base grammar. + */ + rules: { + /* + semgrep_ellipsis: $ => '...', + + _expression: ($, previous) => choice( + $.semgrep_ellipsis, + ...previous.members + ), + */ + } +}); diff --git a/lang/semgrep-grammars/src/semgrep-scala/prep b/lang/semgrep-grammars/src/semgrep-scala/prep new file mode 120000 index 00000000..df68f30a --- /dev/null +++ b/lang/semgrep-grammars/src/semgrep-scala/prep @@ -0,0 +1 @@ +../prep.common \ No newline at end of file diff --git a/lang/semgrep-grammars/src/semgrep-scala/test/corpus/semgrep.txt b/lang/semgrep-grammars/src/semgrep-scala/test/corpus/semgrep.txt new file mode 100644 index 00000000..e69de29b diff --git a/lang/semgrep-grammars/src/tree-sitter-scala b/lang/semgrep-grammars/src/tree-sitter-scala new file mode 160000 index 00000000..97aead18 --- /dev/null +++ b/lang/semgrep-grammars/src/tree-sitter-scala @@ -0,0 +1 @@ +Subproject commit 97aead18d97708190a51d4f551ea9b05b60641c9