diff --git a/Unix/cloc b/Unix/cloc index d9a4b9f5..7022edf7 100755 --- a/Unix/cloc +++ b/Unix/cloc @@ -9229,15 +9229,16 @@ sub set_constants { # {{{1 'sp' => 'SparForte' , 'sol' => 'Solidity' , 'p4' => 'P4' , - 'pwn' => 'Pawn' , - 'pawn' => 'Pawn' , 'ses' => 'Patran Command Language' , 'pcl' => 'Patran Command Language' , + 'pwn' => 'Pawn' , + 'pawn' => 'Pawn' , 'pek' => 'Pek' , 'peg' => 'PEG' , 'pegjs' => 'peg.js' , 'peggy' => 'peggy' , 'pest' => 'Pest' , + 'pkl' => 'Pkl' , 'prisma' => 'Prisma Schema' , 'tspeg' => 'tspeg' , 'jspeg' => 'tspeg' , @@ -10611,16 +10612,16 @@ sub set_constants { # {{{1 [ 'rm_comments_in_strings', '"', '//', '' ], [ 'call_regexp_common' , 'C++' ], ], - 'Pawn' => [ - [ 'rm_comments_in_strings', '"', '/*', '*/' ], - [ 'rm_comments_in_strings', '"', '//', '' ], - [ 'call_regexp_common' , 'C++' ], - ], 'Patran Command Language'=> [ [ 'remove_matches' , '^\s*#' ], [ 'remove_matches' , '^\s*\$#' ], [ 'call_regexp_common' , 'C' ], ], + 'Pawn' => [ + [ 'rm_comments_in_strings', '"', '/*', '*/' ], + [ 'rm_comments_in_strings', '"', '//', '' ], + [ 'call_regexp_common' , 'C++' ], + ], 'Perl' => [ [ 'remove_below' , '^__(END|DATA)__'], [ 'remove_matches' , '^\s*#' ], [ 'remove_below_above' , '^=head1', '^=cut' ], @@ -10650,6 +10651,14 @@ sub set_constants { # {{{1 [ 'remove_inline' , '//.*$' ], ], 'Perl/Prolog' => [ [ 'die' , ], ], # never called + 'Pig Latin' => [ + [ 'remove_matches' , '^\s*--' ], + [ 'remove_inline' , '--.*$' ], + [ 'call_regexp_common' , 'C' ], + ], + 'Pkl' => [ + [ 'call_regexp_common' , 'C++' ], + ], 'PL/I' => [ [ 'call_regexp_common' , 'C' ], ], @@ -10660,11 +10669,6 @@ sub set_constants { # {{{1 [ 'remove_between_general', "/'", "'/" ], [ 'remove_matches' , "^\\s*'" ], ], - 'Pig Latin' => [ - [ 'remove_matches' , '^\s*--' ], - [ 'remove_inline' , '--.*$' ], - [ 'call_regexp_common' , 'C' ], - ], 'Prisma Schema' => [ [ 'remove_matches' , '^\s*//' ], ], @@ -11768,6 +11772,7 @@ sub set_constants { # {{{1 'Pest' => 2.00, 'tspeg' => 3.00, 'Pig Latin' => 1.00, + 'Pkl' => 3.00, 'PL/I' => 1.38, 'PL/M' => 1.13, 'PlantUML' => 2.00, diff --git a/Unix/t/00_C.t b/Unix/t/00_C.t index 6c715677..70807939 100755 --- a/Unix/t/00_C.t +++ b/Unix/t/00_C.t @@ -914,6 +914,11 @@ my @Tests = ( 'ref' => '../tests/outputs/script1-hadoop.pig.yaml', 'args' => '../tests/inputs/script1-hadoop.pig', }, + { + 'name' => 'Pkl', + 'ref' => '../tests/outputs/fib_class.pkl.yaml', + 'args' => '../tests/inputs/fib_class.pkl', + }, { 'name' => 'PL/I', 'ref' => '../tests/outputs/hello.pl1.yaml', diff --git a/cloc b/cloc index d7bb58c0..24c3e9b4 100755 --- a/cloc +++ b/cloc @@ -9219,15 +9219,16 @@ sub set_constants { # {{{1 'sp' => 'SparForte' , 'sol' => 'Solidity' , 'p4' => 'P4' , - 'pwn' => 'Pawn' , - 'pawn' => 'Pawn' , 'ses' => 'Patran Command Language' , 'pcl' => 'Patran Command Language' , + 'pwn' => 'Pawn' , + 'pawn' => 'Pawn' , 'pek' => 'Pek' , 'peg' => 'PEG' , 'pegjs' => 'peg.js' , 'peggy' => 'peggy' , 'pest' => 'Pest' , + 'pkl' => 'Pkl' , 'prisma' => 'Prisma Schema' , 'tspeg' => 'tspeg' , 'jspeg' => 'tspeg' , @@ -10601,16 +10602,16 @@ sub set_constants { # {{{1 [ 'rm_comments_in_strings', '"', '//', '' ], [ 'call_regexp_common' , 'C++' ], ], - 'Pawn' => [ - [ 'rm_comments_in_strings', '"', '/*', '*/' ], - [ 'rm_comments_in_strings', '"', '//', '' ], - [ 'call_regexp_common' , 'C++' ], - ], 'Patran Command Language'=> [ [ 'remove_matches' , '^\s*#' ], [ 'remove_matches' , '^\s*\$#' ], [ 'call_regexp_common' , 'C' ], ], + 'Pawn' => [ + [ 'rm_comments_in_strings', '"', '/*', '*/' ], + [ 'rm_comments_in_strings', '"', '//', '' ], + [ 'call_regexp_common' , 'C++' ], + ], 'Perl' => [ [ 'remove_below' , '^__(END|DATA)__'], [ 'remove_matches' , '^\s*#' ], [ 'remove_below_above' , '^=head1', '^=cut' ], @@ -10640,6 +10641,14 @@ sub set_constants { # {{{1 [ 'remove_inline' , '//.*$' ], ], 'Perl/Prolog' => [ [ 'die' , ], ], # never called + 'Pig Latin' => [ + [ 'remove_matches' , '^\s*--' ], + [ 'remove_inline' , '--.*$' ], + [ 'call_regexp_common' , 'C' ], + ], + 'Pkl' => [ + [ 'call_regexp_common' , 'C++' ], + ], 'PL/I' => [ [ 'call_regexp_common' , 'C' ], ], @@ -10650,11 +10659,6 @@ sub set_constants { # {{{1 [ 'remove_between_general', "/'", "'/" ], [ 'remove_matches' , "^\\s*'" ], ], - 'Pig Latin' => [ - [ 'remove_matches' , '^\s*--' ], - [ 'remove_inline' , '--.*$' ], - [ 'call_regexp_common' , 'C' ], - ], 'Prisma Schema' => [ [ 'remove_matches' , '^\s*//' ], ], @@ -11758,6 +11762,7 @@ sub set_constants { # {{{1 'Pest' => 2.00, 'tspeg' => 3.00, 'Pig Latin' => 1.00, + 'Pkl' => 3.00, 'PL/I' => 1.38, 'PL/M' => 1.13, 'PlantUML' => 2.00, diff --git a/tests/inputs/fib_class.pkl b/tests/inputs/fib_class.pkl new file mode 100644 index 00000000..9a9bb834 --- /dev/null +++ b/tests/inputs/fib_class.pkl @@ -0,0 +1,25 @@ +/* + +https://raw.githubusercontent.com/apple/pkl/refs/heads/main/bench/src/jmh/resources/org/pkl/core/fib_class.pkl +*/ + +//===----------------------------------------------------------------------===// +// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//===----------------------------------------------------------------------===// + +class Fibonacci { + function fib(n) = if (n < 2) n else fib(n - 1) + fib(n - 2) +} +result = new Fibonacci {}.fib(35) diff --git a/tests/outputs/fib_class.pkl.yaml b/tests/outputs/fib_class.pkl.yaml new file mode 100644 index 00000000..76f8383d --- /dev/null +++ b/tests/outputs/fib_class.pkl.yaml @@ -0,0 +1,21 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 2.03 + elapsed_seconds : 0.00434088706970215 + n_files : 1 + n_lines : 25 + files_per_second : 230.367660789806 + lines_per_second : 5759.19151974515 + report_file : ../outputs/fib_class.pkl.yaml +'Pkl' : + nFiles: 1 + blank: 3 + comment: 18 + code: 4 +SUM: + blank: 3 + comment: 18 + code: 4 + nFiles: 1