add cangjie language support (#1127) (#1128)

* add cangjie language definition

* add test file cangjie.cj

Co-authored-by: Chengxiang Liu <chengxiang@qcraft.ai>
This commit is contained in:
xffish 2024-08-16 19:50:18 +08:00 committed by GitHub
parent 48bd659d6b
commit 3c1536825b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 59 additions and 0 deletions

View file

@ -174,6 +174,15 @@
"multi_line_comments": [["{-", "-}"]],
"extensions": ["cabal"]
},
"Cangjie": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],
"nested": true,
"quotes": [["\\\"", "\\\""],["\\\"\\\"\\\"", "\\\"\\\"\\\""]],
"verbatim_quotes": [["#\\\"", "\\\"#"],["##\\\"", "\\\"##"],["###\\\"", "\\\"###"],
["#'", "'#"],["##'", "'##"],["###'", "'###"]],
"extensions": ["cj"]
},
"Cassius": {
"line_comment": ["//"],
"multi_line_comments": [["/*", "*/"]],

50
tests/data/cangjie.cj Normal file
View file

@ -0,0 +1,50 @@
/* 50 lines 34 code 8 comments 8 blanks */
/* /* we can nest block*/ comments in cangjie */
main(): Unit {
let start: String = "/*"
var x: Int64 = 1
x += 2 // end of line comment */
}
func foo(): Unit {
let esc: String = "\"/*escaped quotes in a string and block comment*/\"";
let next_line: String = """
*/ /*string on new line
continued to another line
bar();
*/"
"""
/* Block comment
// line comment in a block comment
end block comment*/
let late_start: String = // "
##"wow\
that's pretty neat"##
let late_start2: String = /* " */
"*/ still just a string" // but this is a line comment
}
func foobar(): Unit {
let a: Int64 = 4 // /*
let b: Int64 = 5
let c: Int64 = 6 // */
}
/* \
/ comment
\*/
struct Point {
let x: Int64
let y: Int64
let z: Int64
public init(x: Int64, y: Int64, z: Int64) {
this.x = x
this.y = y
this.z = z
}
}