Skip to content

Commit

Permalink
add support for Cadence, #859
Browse files Browse the repository at this point in the history
  • Loading branch information
AlDanial committed Oct 14, 2024
1 parent 2580c5a commit f676ba5
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 12 deletions.
18 changes: 12 additions & 6 deletions Unix/cloc
Original file line number Diff line number Diff line change
Expand Up @@ -8555,6 +8555,7 @@ sub set_constants { # {{{1
'ixx' => 'C++' ,
'tcc' => 'C++' ,
'tpp' => 'C++' ,
'cdc' => 'Cadence' ,
'ccs' => 'CCS' ,
'cfc' => 'ColdFusion CFScript' ,
'cfml' => 'ColdFusion' ,
Expand Down Expand Up @@ -9659,17 +9660,17 @@ sub set_constants { # {{{1
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'Chapel' => [
'C++' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'C++' => [
'C/C++ Header' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'C/C++ Header' => [
'Cadence' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
Expand All @@ -9679,6 +9680,11 @@ sub set_constants { # {{{1
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'Chapel' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'Clean' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
Expand Down Expand Up @@ -10182,7 +10188,7 @@ sub set_constants { # {{{1
[ 'call_regexp_common' , 'C++' ],
],
'Java' => [
[ 'docstring_rm_comments', ],
[ 'docstring_rm_comments', ],
[ 'replace_regex', '\\\\$', ' '],
# Java seems to have more path globs in strings
# than other languages. The variations makes
Expand Down Expand Up @@ -11408,7 +11414,6 @@ sub set_constants { # {{{1
'asa' => 1.29,
'ASP' => 1.29,
'ASP.NET' => 1.29,
'CCS' => 5.33,
'Apex Trigger' => 1.4 ,
'AppleScript' => 4.0 ,
'Arduino Sketch' => 1.00,
Expand All @@ -11429,13 +11434,14 @@ sub set_constants { # {{{1
'BrightScript' => 2.00,
'builder' => 2.00,
'C' => 0.77,
'c set 2' => 0.88,
'C#' => 1.36,
'C# Designer' => 1.36,
'C# Generated' => 1.36,
'Cake Build Script' => 1.36,
'C++' => 1.51,
'Cadence' => 3.00,
'Carbon' => 1.51,
'CCS' => 5.33,
'ColdFusion' => 4.00,
'ColdFusion CFScript' => 4.00,
'Chapel' => 2.96,
Expand Down
5 changes: 5 additions & 0 deletions Unix/t/00_C.t
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ my @Tests = (
'ref' => '../tests/outputs/C++-uppercase.CPP.yaml',
'args' => '../tests/inputs/C++-uppercase.CPP',
},
{
'name' => 'Cadence',
'ref' => '../tests/outputs/cadence_test.cdc.yaml',
'args' => '../tests/inputs/cadence_test.cdc',
},
{
'name' => 'Carbon',
'ref' => '../tests/outputs/variable_length.carbon.yaml',
Expand Down
18 changes: 12 additions & 6 deletions cloc
Original file line number Diff line number Diff line change
Expand Up @@ -8545,6 +8545,7 @@ sub set_constants { # {{{1
'ixx' => 'C++' ,
'tcc' => 'C++' ,
'tpp' => 'C++' ,
'cdc' => 'Cadence' ,
'ccs' => 'CCS' ,
'cfc' => 'ColdFusion CFScript' ,
'cfml' => 'ColdFusion' ,
Expand Down Expand Up @@ -9649,17 +9650,17 @@ sub set_constants { # {{{1
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'Chapel' => [
'C++' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'C++' => [
'C/C++ Header' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'C/C++ Header' => [
'Cadence' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
Expand All @@ -9669,6 +9670,11 @@ sub set_constants { # {{{1
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'Chapel' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
[ 'call_regexp_common' , 'C++' ],
],
'Clean' => [
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
[ 'rm_comments_in_strings', '"', '//', '' ],
Expand Down Expand Up @@ -10172,7 +10178,7 @@ sub set_constants { # {{{1
[ 'call_regexp_common' , 'C++' ],
],
'Java' => [
[ 'docstring_rm_comments', ],
[ 'docstring_rm_comments', ],
[ 'replace_regex', '\\\\$', ' '],
# Java seems to have more path globs in strings
# than other languages. The variations makes
Expand Down Expand Up @@ -11398,7 +11404,6 @@ sub set_constants { # {{{1
'asa' => 1.29,
'ASP' => 1.29,
'ASP.NET' => 1.29,
'CCS' => 5.33,
'Apex Trigger' => 1.4 ,
'AppleScript' => 4.0 ,
'Arduino Sketch' => 1.00,
Expand All @@ -11419,13 +11424,14 @@ sub set_constants { # {{{1
'BrightScript' => 2.00,
'builder' => 2.00,
'C' => 0.77,
'c set 2' => 0.88,
'C#' => 1.36,
'C# Designer' => 1.36,
'C# Generated' => 1.36,
'Cake Build Script' => 1.36,
'C++' => 1.51,
'Cadence' => 3.00,
'Carbon' => 1.51,
'CCS' => 5.33,
'ColdFusion' => 4.00,
'ColdFusion CFScript' => 4.00,
'Chapel' => 2.96,
Expand Down
45 changes: 45 additions & 0 deletions tests/inputs/cadence_test.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* https://cadence-lang.org/docs/testing-framework
*/
// A `setup` function that always runs before the rest of the test cases.
// Can be used to initialize things that would be used across the test cases.
// e.g: initialling a blockchain backend, initializing a contract, etc.
access(all)
fun setup() {
}

// The `beforeEach` function runs before each test case. Can be used to perform
// some state cleanup before each test case, among other things.
access(all)
fun beforeEach() {
}

// The `afterEach` function runs after each test case. Can be used to perform
// some state cleanup after each test case, among other things.
access(all)
fun afterEach() {
}

// Valid test functions start with the 'test' prefix.
access(all)
fun testSomething() {
}

access(all)
fun testAnotherThing() {
}

access(all)
fun testMoreThings() {
}

// Test functions cannot have any arguments or return values.
access(all)
fun testInvalidSignature(message: String): Bool {
}

// A `tearDown` function that always runs at the end of all test cases.
// e.g: Can be used to stop the blockchain back-end used for tests, etc. or any cleanup.
access(all)
fun tearDown() {
}

21 changes: 21 additions & 0 deletions tests/outputs/cadence_test.cdc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# github.com/AlDanial/cloc
header :
cloc_url : github.com/AlDanial/cloc
cloc_version : 2.03
elapsed_seconds : 0.00456786155700684
n_files : 1
n_lines : 45
files_per_second : 218.920820502114
lines_per_second : 9851.43692259512
report_file : ../outputs/cadence_test.cdc.yaml
'Cadence' :
nFiles: 1
blank: 8
comment: 13
code: 24
SUM:
blank: 8
comment: 13
code: 24
nFiles: 1

0 comments on commit f676ba5

Please sign in to comment.