Skip to content

Commit a960adc

Browse files
authored
Merge pull request #414 from tiagofneto/cairo
Add support for Cairo
2 parents 39672f9 + 0297511 commit a960adc

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

LANGUAGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ C# (cs,csx)
3737
C++ (cc,cpp,cxx,c++,pcc,ino)
3838
C++ Header (hh,hpp,hxx,inl,ipp)
3939
Cabal (cabal)
40+
Cairo (cairo)
4041
Cassius (cassius)
4142
Ceylon (ceylon)
4243
Clojure (clj,cljc)

examples/language/cairo.cairo

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
fn main() -> felt252 {
2+
fib(16)
3+
}
4+
5+
fn fib(mut n: felt252) -> felt252 {
6+
let mut a: felt252 = 0;
7+
let mut b: felt252 = 1;
8+
loop {
9+
if n == 0 {
10+
break a;
11+
}
12+
n = n - 1;
13+
let temp = b;
14+
b = a + b;
15+
a = temp;
16+
}
17+
}
18+
19+
#[cfg(test)]
20+
mod tests {
21+
use super::fib;
22+
23+
#[test]
24+
#[available_gas(100000)]
25+
fn it_works() {
26+
assert(fib(16) == 987, 'it works!');
27+
}
28+
}

languages.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,33 @@
12541254
],
12551255
"quotes": []
12561256
},
1257+
"Cairo": {
1258+
"complexitychecks": [
1259+
"loop ",
1260+
"if ",
1261+
"if(",
1262+
"match ",
1263+
"match(",
1264+
"else ",
1265+
"|| ",
1266+
"&& ",
1267+
"!= ",
1268+
"== "
1269+
],
1270+
"extensions": [
1271+
"cairo"
1272+
],
1273+
"line_comment": [
1274+
"//"
1275+
],
1276+
"multi_line": [],
1277+
"quotes": [
1278+
{
1279+
"end": "'",
1280+
"start": "'"
1281+
}
1282+
]
1283+
},
12571284
"Cassius": {
12581285
"complexitychecks": [
12591286
"for ",

0 commit comments

Comments
 (0)