From d9ac9b52e37c4a3cc0fc4dd6c41373358962761a Mon Sep 17 00:00:00 2001 From: AlDanial Date: Sat, 24 Feb 2024 10:59:45 -0800 Subject: [PATCH] add support for Nickel, #812 --- Unix/cloc | 8 +++++++- Unix/t/00_C.t | 5 +++++ cloc | 8 +++++++- tests/inputs/fibonacci.ncl | 14 ++++++++++++++ tests/outputs/fibonacci.ncl.yaml | 21 +++++++++++++++++++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 tests/inputs/fibonacci.ncl create mode 100644 tests/outputs/fibonacci.ncl.yaml diff --git a/Unix/cloc b/Unix/cloc index 478ebbb9..0fa44cd3 100755 --- a/Unix/cloc +++ b/Unix/cloc @@ -29,7 +29,7 @@ # . # # 1}}} -my $VERSION = "2.00"; # odd number == beta; even number == stable +my $VERSION = "2.01"; # odd number == beta; even number == stable my $URL = "github.com/AlDanial/cloc"; # 'https://' pushes header too wide require 5.10.0; # use modules {{{1 @@ -8653,6 +8653,7 @@ sub set_constants { # {{{1 'n' => 'Nemerle' , 'nlogo' => 'NetLogo' , 'nls' => 'NetLogo' , + 'ncl' => 'Nickel' , 'nims' => 'Nim' , 'nimrod' => 'Nim' , 'nimble' => 'Nim' , @@ -10074,6 +10075,10 @@ sub set_constants { # {{{1 'Mustache' => [ [ 'remove_between_general', '{{!', '}}' ], ], + 'Nickel' => [ + [ 'remove_matches' , '^\s*#' ], + [ 'remove_inline' , '#.*$' ], + ], 'Nim' => [ [ 'remove_between_general', '#[', ']#' ], [ 'remove_matches' , '^\s*#' ], @@ -11230,6 +11235,7 @@ sub set_constants { # {{{1 'Nastran' => 1.13, 'Nemerle' => 2.50, 'NetLogo' => 4.00, + 'Nickel' => 2.00, 'Nim' => 2.00, 'Nix' => 2.70, 'Nunjucks' => 1.5 , diff --git a/Unix/t/00_C.t b/Unix/t/00_C.t index 8a817020..e2c05619 100755 --- a/Unix/t/00_C.t +++ b/Unix/t/00_C.t @@ -746,6 +746,11 @@ my @Tests = ( 'ref' => '../tests/outputs/vinos.nlogo.yaml', 'args' => '../tests/inputs/vinos.nlogo', }, + { + 'name' => 'Nickel', + 'ref' => '../tests/outputs/fibonacci.ncl.yaml', + 'args' => '../tests/inputs/fibonacci.ncl', + }, { 'name' => 'Nim', 'ref' => '../tests/outputs/statcsv.nim.yaml', diff --git a/cloc b/cloc index b222bf9b..14faafeb 100755 --- a/cloc +++ b/cloc @@ -29,7 +29,7 @@ # . # # 1}}} -my $VERSION = "2.00"; # odd number == beta; even number == stable +my $VERSION = "2.01"; # odd number == beta; even number == stable my $URL = "github.com/AlDanial/cloc"; # 'https://' pushes header too wide require 5.10.0; # use modules {{{1 @@ -8668,6 +8668,7 @@ sub set_constants { # {{{1 'n' => 'Nemerle' , 'nlogo' => 'NetLogo' , 'nls' => 'NetLogo' , + 'ncl' => 'Nickel' , 'nims' => 'Nim' , 'nimrod' => 'Nim' , 'nimble' => 'Nim' , @@ -10089,6 +10090,10 @@ sub set_constants { # {{{1 'Mustache' => [ [ 'remove_between_general', '{{!', '}}' ], ], + 'Nickel' => [ + [ 'remove_matches' , '^\s*#' ], + [ 'remove_inline' , '#.*$' ], + ], 'Nim' => [ [ 'remove_between_general', '#[', ']#' ], [ 'remove_matches' , '^\s*#' ], @@ -11245,6 +11250,7 @@ sub set_constants { # {{{1 'Nastran' => 1.13, 'Nemerle' => 2.50, 'NetLogo' => 4.00, + 'Nickel' => 2.00, 'Nim' => 2.00, 'Nix' => 2.70, 'Nunjucks' => 1.5 , diff --git a/tests/inputs/fibonacci.ncl b/tests/inputs/fibonacci.ncl new file mode 100644 index 00000000..856bd857 --- /dev/null +++ b/tests/inputs/fibonacci.ncl @@ -0,0 +1,14 @@ +# https://raw.githubusercontent.com/tweag/nickel/master/examples/fibonacci/fibonacci.ncl +# test = 'pass' + +# This is the naive, exponential version of fibonacci: don't call it on a big +# value! +let rec fibonacci = fun n => + if n == 0 then + 0 + else if n == 1 then + 1 + else + fibonacci (n - 1) + fibonacci (n - 2) +in +fibonacci 10 diff --git a/tests/outputs/fibonacci.ncl.yaml b/tests/outputs/fibonacci.ncl.yaml new file mode 100644 index 00000000..c0d121fa --- /dev/null +++ b/tests/outputs/fibonacci.ncl.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.01 + elapsed_seconds : 0.00243306159973145 + n_files : 1 + n_lines : 14 + files_per_second : 411.004801567859 + lines_per_second : 5754.06722195002 + report_file : ../outputs/fibonacci.ncl.yaml +'Nickel' : + nFiles: 1 + blank: 1 + comment: 4 + code: 9 +SUM: + blank: 1 + comment: 4 + code: 9 + nFiles: 1