Skip to content

Commit

Permalink
Add Cairo language support (#18)
Browse files Browse the repository at this point in the history
* Add Cairo

* Fix expected stats

* Remove nested and important syntax fields
  • Loading branch information
0xNeshi authored Jul 23, 2024
1 parent d91a200 commit b203bf3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ Bitbake
BrightScript
C
Cabal
Cairo
Cassius
Ceylon
CHeader
Expand Down
12 changes: 5 additions & 7 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@
"multi_line_comments": [["{-", "-}"]],
"extensions": ["cabal"]
},
"Cairo": {
"line_comment": ["//"],
"extensions": ["cairo"],
"quotes": [["\\\"", "\\\""], ["'", "'"]]
},
"Cassius": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
Expand Down Expand Up @@ -1480,13 +1485,6 @@
"extensions": ["smk", "rules"],
"filenames": ["snakefile"]
},
"Snakemake": {
"line_comment": ["#"],
"doc_quotes": [["\\\"\\\"\\\"", "\\\"\\\"\\\""], ["'''", "'''"]],
"quotes": [["\\\"", "\\\""], ["'", "'"]],
"extensions": ["smk", "rules"],
"filenames": ["snakefile"]
},
"Solidity": {
"name": "Solidity",
"line_comment": ["//"],
Expand Down
51 changes: 51 additions & 0 deletions tests/data/cairo.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//! 51 lines 32 code 13 comments 6 blanks
//! ```rust
//! fn main () {
//! // Comment
//!
//! println!("Hello World!");
//! }
//! ```

/// The main function
fn main() {
let x: ByteArray = "\"/*##\"\"##\'\'";
// comment
loop {
if x.len() >= 2 && x[0] == '*' && x[1] == '/' { // found the */
break;
}
}
}

fn foo<T, +Drop<T>>(name: T) {
let this_ends = 'a "\'test/"*.';
call1();
call2();
let this_does_not = // a // nested // comment " //
///"*/another /*test
call3();
//*/";
}

fn call1() {}
fn call2() {}
fn call3() {}

fn foobar() {
let does_not_start: ByteArray = // "
"until here,
test/*
test"; // a quote: "
let also_doesnt_start =
/// " */
'until here,
test,'; // another quote: "
}

fn foo2() {
let a = 4; // ///
let b = '5';
let c = 6; // ///
}

0 comments on commit b203bf3

Please sign in to comment.