Skip to content

Commit

Permalink
Add circom language
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed May 6, 2024
1 parent 43d0843 commit c9aaefc
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 54 deletions.
1 change: 1 addition & 0 deletions LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Cairo (cairo)
Cassius (cassius)
Ceylon (ceylon)
Chapel (chpl)
Circom (circom)
Clojure (clj,cljc)
ClojureScript (cljs)
Closure Template (soy)
Expand Down
38 changes: 19 additions & 19 deletions SCC-OUTPUT-REPORT.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<th>453</th>
<th>7424</th>
<th>1516</th>
<th>401033</th>
<th>401573</th>
<th>3929</th>
</tr><tr>
<td>processor/workers_test.go</td>
Expand Down Expand Up @@ -250,16 +250,6 @@
<td>0</td>
<td>2222</td>
<td>35</td>
</tr><tr>
<td>processor/cocomo_test.go</td>
<td></td>
<td>37</td>
<td>8</td>
<td>4</td>
<td>25</td>
<td>6</td>
<td>699</td>
<td>23</td>
</tr><tr>
<td>processor/bloom.go</td>
<td></td>
Expand All @@ -271,15 +261,15 @@
<td>1051</td>
<td>29</td>
</tr><tr>
<td>processor/structs_test.go</td>
<td>processor/cocomo_test.go</td>
<td></td>
<td>32</td>
<td>37</td>
<td>8</td>
<td>1</td>
<td>23</td>
<td>4</td>
<td>517</td>
<td>19</td>
<td>25</td>
<td>6</td>
<td>699</td>
<td>23</td>
</tr><tr>
<td>processor/helpers.go</td>
<td></td>
Expand All @@ -290,6 +280,16 @@
<td>2</td>
<td>544</td>
<td>21</td>
</tr><tr>
<td>processor/structs_test.go</td>
<td></td>
<td>32</td>
<td>8</td>
<td>1</td>
<td>23</td>
<td>4</td>
<td>517</td>
<td>19</td>
</tr><tr>
<td>processor/processor_unix_test.go</td>
<td></td>
Expand Down Expand Up @@ -318,7 +318,7 @@
<td>0</td>
<td>4</td>
<td>0</td>
<td>174545</td>
<td>175085</td>
<td>5</td>
</tr></tbody>
<tfoot><tr>
Expand All @@ -329,7 +329,7 @@
<th>453</th>
<th>7424</th>
<th>1516</th>
<th>401033</th>
<th>401573</th>
<th>3929</th>
</tr>
<tr>
Expand Down
34 changes: 34 additions & 0 deletions examples/language/circom.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 34 lines 23 code 7 comments 4 blanks
pragma circom 2.0.8;

/*
* Sum an array of non-zero values.
*/
function sum(values, size) {
var sum = 0;
for (var i = 0; i < size; i++) {
assert(values[i] != 0);
sum += values[i];
}
log("sum = ", sum);
return sum;
}

/*
* Ensure x is a solution to x^5 - 2x^4 + 5x - 4 = 0.
*/
template Polynomial() {
signal input x;
signal x2;
signal x4;
signal x5;
signal output y;

x2 <== x * x;
x4 <== x2 * x2;
x5 <== x4 * x;
y <== x5 - 2 * x4 + 5 * x - 4; // y = x^5 - 2 * x^4 + 5x - 4.
y === 0; // Ensure that y = 0.
}

component main = Polynomial();
96 changes: 63 additions & 33 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,36 @@
}
]
},
"Circom": {
"complexitychecks": [
"for ",
"for(",
"if ",
"if(",
"switch ",
"while ",
"while(",
"else ",
"else(",
"|| ",
"&& ",
"!= ",
"== "
],
"extensions": [
"circom"
],
"line_comment": [
"//"
],
"multi_line": [
[
"/*",
"*/"
]
],
"quotes": []
},
"Clojure": {
"complexitychecks": [
"(for ",
Expand Down Expand Up @@ -3857,39 +3887,6 @@
}
]
},
"Slang": {
"complexitychecks": [
"for ",
"for(",
"if ",
"if(",
"switch ",
"while ",
"else ",
"|| ",
"&& ",
"!= ",
"== "
],
"extensions": [
"slang"
],
"line_comment": [
"//"
],
"multi_line": [
[
"/*",
"*/"
]
],
"quotes": [
{
"end": "\"",
"start": "\""
}
]
},
"JavaScript": {
"complexitychecks": [
"for ",
Expand Down Expand Up @@ -7342,6 +7339,39 @@
}
]
},
"Slang": {
"complexitychecks": [
"for ",
"for(",
"if ",
"if(",
"switch ",
"while ",
"else ",
"|| ",
"&& ",
"!= ",
"== "
],
"extensions": [
"slang"
],
"line_comment": [
"//"
],
"multi_line": [
[
"/*",
"*/"
]
],
"quotes": [
{
"end": "\"",
"start": "\""
}
]
},
"Smarty Template": {
"complexitychecks": [
"for ",
Expand Down
2 changes: 1 addition & 1 deletion processor/constants.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ else
fi

# Try out specific languages
for i in 'Bosque ' 'Flow9 ' 'Bitbucket Pipeline ' 'Docker ignore ' 'Q# ' 'Futhark ' 'Alloy ' 'Wren ' 'Monkey C ' 'Alchemist ' 'Luna ' 'ignore ' 'XML Schema ' 'Web Services' 'Go ' 'Java ' 'Boo ' 'License ' 'BASH ' 'C Shell ' 'Korn Shell ' 'Makefile ' 'Shell ' 'Zsh ' 'Rakefile ' 'Gemfile ' 'Dockerfile ' 'Yarn ' 'Sieve ' 'F# ' 'Elm ' 'Terraform ' 'Clojure ' 'C# ' 'LLVM IR ' 'HAML ' 'FXML ' 'DM ' 'Nushell ' 'Racket ' 'DOT ' 'YAML ' 'Teal ' 'FSL ' 'INI ' 'Hare ' 'Templ ' 'Cuda ' 'GraphQL ' 'Bicep ' 'Pkl ' 'TypeSpec ' 'LALRPOP ' 'Snakemake ' 'OpenQASM ' 'Typst ' 'ZoKrates ' 'Chapel ' 'Slang '
for i in 'Bosque ' 'Flow9 ' 'Bitbucket Pipeline ' 'Docker ignore ' 'Q# ' 'Futhark ' 'Alloy ' 'Wren ' 'Monkey C ' 'Alchemist ' 'Luna ' 'ignore ' 'XML Schema ' 'Web Services' 'Go ' 'Java ' 'Boo ' 'License ' 'BASH ' 'C Shell ' 'Korn Shell ' 'Makefile ' 'Shell ' 'Zsh ' 'Rakefile ' 'Gemfile ' 'Dockerfile ' 'Yarn ' 'Sieve ' 'F# ' 'Elm ' 'Terraform ' 'Clojure ' 'C# ' 'LLVM IR ' 'HAML ' 'FXML ' 'DM ' 'Nushell ' 'Racket ' 'DOT ' 'YAML ' 'Teal ' 'FSL ' 'INI ' 'Hare ' 'Templ ' 'Cuda ' 'GraphQL ' 'Bicep ' 'Pkl ' 'TypeSpec ' 'LALRPOP ' 'Snakemake ' 'OpenQASM ' 'Typst ' 'ZoKrates ' 'Chapel ' 'Slang ' 'Circom '
do
if ./scc "examples/language/" | grep -q "$i "; then
echo -e "${GREEN}PASSED $i Language Check"
Expand Down

0 comments on commit c9aaefc

Please sign in to comment.