Skip to content

Commit

Permalink
feat: support cairo
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagofneto committed Nov 3, 2023
1 parent 39672f9 commit 0297511
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions LANGUAGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ C# (cs,csx)
C++ (cc,cpp,cxx,c++,pcc,ino)
C++ Header (hh,hpp,hxx,inl,ipp)
Cabal (cabal)
Cairo (cairo)
Cassius (cassius)
Ceylon (ceylon)
Clojure (clj,cljc)
Expand Down
28 changes: 28 additions & 0 deletions examples/language/cairo.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
fn main() -> felt252 {
fib(16)
}

fn fib(mut n: felt252) -> felt252 {
let mut a: felt252 = 0;
let mut b: felt252 = 1;
loop {
if n == 0 {
break a;
}
n = n - 1;
let temp = b;
b = a + b;
a = temp;
}
}

#[cfg(test)]
mod tests {
use super::fib;

#[test]
#[available_gas(100000)]
fn it_works() {
assert(fib(16) == 987, 'it works!');
}
}
27 changes: 27 additions & 0 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,33 @@
],
"quotes": []
},
"Cairo": {
"complexitychecks": [
"loop ",
"if ",
"if(",
"match ",
"match(",
"else ",
"|| ",
"&& ",
"!= ",
"== "
],
"extensions": [
"cairo"
],
"line_comment": [
"//"
],
"multi_line": [],
"quotes": [
{
"end": "'",
"start": "'"
}
]
},
"Cassius": {
"complexitychecks": [
"for ",
Expand Down

0 comments on commit 0297511

Please sign in to comment.