Add support for Cairo language (#1193)

This commit is contained in:
Erik Schierboom 2024-11-16 11:41:46 +01:00 committed by GitHub
parent 563f15395d
commit 480125cf5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 59 additions and 0 deletions

View File

@ -192,6 +192,14 @@
"multi_line_comments": [["{-", "-}"]],
"extensions": ["cabal"]
},
"Cairo": {
"line_comment": ["//"],
"extensions": ["cairo"],
"quotes": [
["\\\"", "\\\""],
["'", "'"]
]
},
"Cangjie": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],

51
tests/data/cairo.cairo Normal file
View File

@ -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; // ///
}