diff --git a/LANGUAGES.md b/LANGUAGES.md index 4c61a098d..bb1bdf157 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -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) diff --git a/examples/language/cairo.cairo b/examples/language/cairo.cairo new file mode 100644 index 000000000..bf218399a --- /dev/null +++ b/examples/language/cairo.cairo @@ -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!'); + } +} diff --git a/languages.json b/languages.json index ba3eca661..8809e43ca 100644 --- a/languages.json +++ b/languages.json @@ -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 ",