-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #494 from Frodan/circom
Circom
- Loading branch information
Showing
12 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ SUPPORTED_TS_LANGUAGES = \ | |
c \ | ||
cairo \ | ||
clojure \ | ||
circom \ | ||
cpp \ | ||
c-sharp \ | ||
dart \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 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 | ||
# | ||
.circom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
semgrep-grammars/src/tree-sitter-circom/LICENSE | ||
semgrep-grammars/src/tree-sitter-circom/grammar.js | ||
semgrep-grammars/src/semgrep-circom/grammar.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Git URLs of publicly-accessible projects to be used for parsing stats, | ||
# one per line. | ||
# | ||
https://github.com/iden3/circomlib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../src/semgrep-circom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Makefile.common |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
semgrep-circom | ||
Extends the standard circom grammar with semgrep pattern constructs. | ||
*/ | ||
|
||
const base_grammar = require('tree-sitter-circom/grammar'); | ||
|
||
module.exports = grammar(base_grammar, { | ||
name: 'circom', | ||
|
||
conflicts: ($, previous) => previous.concat([ | ||
]), | ||
|
||
/* | ||
Support for semgrep ellipsis ('...') and metavariables ('$FOO'), | ||
if they're not already part of the base grammar. | ||
*/ | ||
rules: { | ||
|
||
source_file: ($, previous) => { | ||
return choice( | ||
previous, | ||
repeat1($._statement), | ||
$._expression, | ||
); | ||
}, | ||
|
||
_expression: ($, previous) => { | ||
return choice( | ||
previous, | ||
$.ellipsis, | ||
$.deep_ellipsis | ||
); | ||
}, | ||
|
||
expression_statement: ($, previous) => { | ||
return choice( | ||
previous, | ||
prec.right(100, seq($.ellipsis, ';')), // expression ellipsis | ||
prec.right(100, $.ellipsis), // statement ellipsis | ||
); | ||
}, | ||
|
||
for_statement: ($, previous) => { | ||
return choice( | ||
previous, | ||
seq('for', '(', $.ellipsis, ')', $._statement) | ||
); | ||
}, | ||
|
||
ellipsis: $ => '...', | ||
|
||
deep_ellipsis: $ => seq( | ||
'<...', $._expression, '...>' | ||
), | ||
|
||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../prep.common |
Empty file.
Submodule tree-sitter-circom
added at
659e30