Skip to content

Commit fe41615

Browse files
committed
add support for Yang, #836
also some clean-ups; no longer need negative values for --fmt
1 parent 64005f3 commit fe41615

File tree

5 files changed

+173
-37
lines changed

5 files changed

+173
-37
lines changed

Unix/cloc

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -616,12 +616,8 @@ Usage: $script [options] <file(s)/dir(s)/git hash(es)> | <set 1> <set 2> | <repo
616616
printed with
617617
perl -MEncode -e 'print join(\"\\n\", Encode->encodings(\":all\")), \"\\n\"'
618618
--fmt=<N> Alternate text output format where <N> is a number
619-
from 1 to 5, or -1 to -5. 'total lines' means the
620-
sum of code, comment, and blank lines. Negative
621-
values are the same as the positive values but retain,
622-
instead of deleting, the intermediate JSON file that
623-
is written. The JSON file name is randomly generated
624-
unless --out/--report-file is given. The formats are:
619+
from 1 to 5. 'total lines' means the sum of code,
620+
comment, and blank lines. The formats are:
625621
1: by language (same as cloc default output)
626622
2: by language with an extra column for total lines
627623
3: by file with language
@@ -9171,6 +9167,7 @@ sub set_constants { # {{{1
91719167
'clang-format'=> 'YAML' ,
91729168
'yaml' => 'YAML' ,
91739169
'yml' => 'YAML' ,
9170+
'yang' => 'Yang' ,
91749171
'zig' => 'Zig' ,
91759172
'zsh' => 'zsh' ,
91769173
);
@@ -10011,6 +10008,7 @@ sub set_constants { # {{{1
1001110008
[ 'rm_comments_in_strings', '"', '//', '' ],
1001210009
[ 'call_regexp_common' , 'C++' ],
1001310010
],
10011+
'lex' => [ [ 'call_regexp_common' , 'C' ], ],
1001410012
'LFE' => [
1001510013
[ 'remove_matches' , '^\s*;' ],
1001610014
[ 'remove_between_general', '#|', '|#' ],
@@ -10720,6 +10718,14 @@ sub set_constants { # {{{1
1072010718
[ 'rm_comments_in_strings', '"', '//', '' ],
1072110719
[ 'call_regexp_common' , 'C++' ],
1072210720
],
10721+
'Velocity Template Language' => [
10722+
[ 'remove_html_comments', ],
10723+
[ 'call_regexp_common' , 'HTML' ],
10724+
[ 'remove_jsp_comments' , ],
10725+
[ 'remove_matches' , '^\s*##' ],
10726+
[ 'remove_between_general', '#**', '*#' ],
10727+
[ 'add_newlines' , ],
10728+
],
1072310729
'Verilog-SystemVerilog/Coq' => [ ['die'] ], # never called
1072410730
'Verilog-SystemVerilog' => [
1072510731
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
@@ -10765,13 +10771,15 @@ sub set_constants { # {{{1
1076510771
[ 'remove_html_comments', ],
1076610772
[ 'call_regexp_common' , 'HTML' ],
1076710773
],
10768-
'Velocity Template Language' => [
10774+
'Visual Studio Module' => [
10775+
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
10776+
[ 'rm_comments_in_strings', '"', '//', '' ],
10777+
[ 'call_regexp_common' , 'C++' ],
10778+
],
10779+
'Visual Studio Solution' => [
10780+
[ 'remove_matches' , '^\s*#' ],
1076910781
[ 'remove_html_comments', ],
1077010782
[ 'call_regexp_common' , 'HTML' ],
10771-
[ 'remove_jsp_comments' , ],
10772-
[ 'remove_matches' , '^\s*##' ],
10773-
[ 'remove_between_general', '#**', '*#' ],
10774-
[ 'add_newlines' , ],
1077510783
],
1077610784
'Vuejs Component' => [
1077710785
[ 'remove_html_comments', ],
@@ -10800,7 +10808,6 @@ sub set_constants { # {{{1
1080010808
[ 'remove_matches' , '^\s*#' ],
1080110809
[ 'remove_inline' , '#.*$' ],
1080210810
],
10803-
'lex' => [ [ 'call_regexp_common' , 'C' ], ],
1080410811
'XAML' => [ [ 'remove_html_comments', ],
1080510812
[ 'call_regexp_common' , 'HTML' ], ],
1080610813
'xBase Header' => [
@@ -10915,16 +10922,11 @@ sub set_constants { # {{{1
1091510922
[ 'call_regexp_common' , 'HTML' ], ],
1091610923
'MSBuild script' => [ [ 'remove_html_comments', ],
1091710924
[ 'call_regexp_common' , 'HTML' ], ],
10918-
'Visual Studio Module' => [
10925+
'Yang' => [
1091910926
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
1092010927
[ 'rm_comments_in_strings', '"', '//', '' ],
1092110928
[ 'call_regexp_common' , 'C++' ],
1092210929
],
10923-
'Visual Studio Solution' => [
10924-
[ 'remove_matches' , '^\s*#' ],
10925-
[ 'remove_html_comments', ],
10926-
[ 'call_regexp_common' , 'HTML' ],
10927-
],
1092810930
'Zig' => [
1092910931
[ 'remove_matches' , '^\s*//' ],
1093010932
[ 'remove_inline' , '//.*$' ],
@@ -11510,6 +11512,7 @@ sub set_constants { # {{{1
1151011512
'Luau' => 4.50,
1151111513
'OpenCL' => 1.50,
1151211514
'Xtend' => 2.00,
11515+
'Yang' => 3.00,
1151311516
'Zig' => 2.50,
1151411517
# aggregates; value is meaningless
1151511518
'C#/Smalltalk' => 1.00,

Unix/t/00_C.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1366,6 +1366,11 @@ my @Tests = (
13661366
'ref' => '../tests/outputs/Xtend.xtend.yaml',
13671367
'args' => '../tests/inputs/Xtend.xtend',
13681368
},
1369+
{
1370+
'name' => 'Yang',
1371+
'ref' => '../tests/outputs/bbf-device.yang.yaml',
1372+
'args' => '../tests/inputs/bbf-device.yang',
1373+
},
13691374
{
13701375
'name' => 'Zig',
13711376
'ref' => '../tests/outputs/zir_sema.zig.yaml',

cloc

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,8 @@ Usage: $script [options] <file(s)/dir(s)/git hash(es)> | <set 1> <set 2> | <repo
641641
printed with
642642
perl -MEncode -e 'print join(\"\\n\", Encode->encodings(\":all\")), \"\\n\"'
643643
--fmt=<N> Alternate text output format where <N> is a number
644-
from 1 to 5, or -1 to -5. 'total lines' means the
645-
sum of code, comment, and blank lines. Negative
646-
values are the same as the positive values but retain,
647-
instead of deleting, the intermediate JSON file that
648-
is written. The JSON file name is randomly generated
649-
unless --out/--report-file is given. The formats are:
644+
from 1 to 5. 'total lines' means the sum of code,
645+
comment, and blank lines. The formats are:
650646
1: by language (same as cloc default output)
651647
2: by language with an extra column for total lines
652648
3: by file with language
@@ -6847,7 +6843,7 @@ sub write_file { # {{{1
68476843
$OUT->close;
68486844

68496845
if (can_read($file)) {
6850-
print "Wrote $file" unless $opt_quiet or $opt_fmt > 0;
6846+
print "Wrote $file" unless $opt_quiet;
68516847
print ", $CLOC_XSL" if $opt_xsl and $opt_xsl eq $CLOC_XSL;
68526848
print "\n" unless $opt_quiet;
68536849
}
@@ -9186,6 +9182,7 @@ sub set_constants { # {{{1
91869182
'clang-format'=> 'YAML' ,
91879183
'yaml' => 'YAML' ,
91889184
'yml' => 'YAML' ,
9185+
'yang' => 'Yang' ,
91899186
'zig' => 'Zig' ,
91909187
'zsh' => 'zsh' ,
91919188
);
@@ -10026,6 +10023,7 @@ sub set_constants { # {{{1
1002610023
[ 'rm_comments_in_strings', '"', '//', '' ],
1002710024
[ 'call_regexp_common' , 'C++' ],
1002810025
],
10026+
'lex' => [ [ 'call_regexp_common' , 'C' ], ],
1002910027
'LFE' => [
1003010028
[ 'remove_matches' , '^\s*;' ],
1003110029
[ 'remove_between_general', '#|', '|#' ],
@@ -10735,6 +10733,14 @@ sub set_constants { # {{{1
1073510733
[ 'rm_comments_in_strings', '"', '//', '' ],
1073610734
[ 'call_regexp_common' , 'C++' ],
1073710735
],
10736+
'Velocity Template Language' => [
10737+
[ 'remove_html_comments', ],
10738+
[ 'call_regexp_common' , 'HTML' ],
10739+
[ 'remove_jsp_comments' , ],
10740+
[ 'remove_matches' , '^\s*##' ],
10741+
[ 'remove_between_general', '#**', '*#' ],
10742+
[ 'add_newlines' , ],
10743+
],
1073810744
'Verilog-SystemVerilog/Coq' => [ ['die'] ], # never called
1073910745
'Verilog-SystemVerilog' => [
1074010746
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
@@ -10780,13 +10786,15 @@ sub set_constants { # {{{1
1078010786
[ 'remove_html_comments', ],
1078110787
[ 'call_regexp_common' , 'HTML' ],
1078210788
],
10783-
'Velocity Template Language' => [
10789+
'Visual Studio Module' => [
10790+
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
10791+
[ 'rm_comments_in_strings', '"', '//', '' ],
10792+
[ 'call_regexp_common' , 'C++' ],
10793+
],
10794+
'Visual Studio Solution' => [
10795+
[ 'remove_matches' , '^\s*#' ],
1078410796
[ 'remove_html_comments', ],
1078510797
[ 'call_regexp_common' , 'HTML' ],
10786-
[ 'remove_jsp_comments' , ],
10787-
[ 'remove_matches' , '^\s*##' ],
10788-
[ 'remove_between_general', '#**', '*#' ],
10789-
[ 'add_newlines' , ],
1079010798
],
1079110799
'Vuejs Component' => [
1079210800
[ 'remove_html_comments', ],
@@ -10815,7 +10823,6 @@ sub set_constants { # {{{1
1081510823
[ 'remove_matches' , '^\s*#' ],
1081610824
[ 'remove_inline' , '#.*$' ],
1081710825
],
10818-
'lex' => [ [ 'call_regexp_common' , 'C' ], ],
1081910826
'XAML' => [ [ 'remove_html_comments', ],
1082010827
[ 'call_regexp_common' , 'HTML' ], ],
1082110828
'xBase Header' => [
@@ -10930,16 +10937,11 @@ sub set_constants { # {{{1
1093010937
[ 'call_regexp_common' , 'HTML' ], ],
1093110938
'MSBuild script' => [ [ 'remove_html_comments', ],
1093210939
[ 'call_regexp_common' , 'HTML' ], ],
10933-
'Visual Studio Module' => [
10940+
'Yang' => [
1093410941
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
1093510942
[ 'rm_comments_in_strings', '"', '//', '' ],
1093610943
[ 'call_regexp_common' , 'C++' ],
1093710944
],
10938-
'Visual Studio Solution' => [
10939-
[ 'remove_matches' , '^\s*#' ],
10940-
[ 'remove_html_comments', ],
10941-
[ 'call_regexp_common' , 'HTML' ],
10942-
],
1094310945
'Zig' => [
1094410946
[ 'remove_matches' , '^\s*//' ],
1094510947
[ 'remove_inline' , '//.*$' ],
@@ -11525,6 +11527,7 @@ sub set_constants { # {{{1
1152511527
'Luau' => 4.50,
1152611528
'OpenCL' => 1.50,
1152711529
'Xtend' => 2.00,
11530+
'Yang' => 3.00,
1152811531
'Zig' => 2.50,
1152911532
# aggregates; value is meaningless
1153011533
'C#/Smalltalk' => 1.00,

tests/inputs/bbf-device.yang

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// fragment of
2+
// https://github.com/BroadbandForum/yang/raw/eaac2c3904365d3c7b17100c7d5120ed06a56b74/standard/common/bbf-device.yang
3+
module bbf-device {
4+
yang-version 1.1;
5+
namespace "urn:bbf:yang:bbf-device";
6+
prefix bbf-dvc;
7+
8+
import ietf-yang-types {
9+
prefix yang;
10+
}
11+
import ietf-inet-types {
12+
prefix inet;
13+
}
14+
import bbf-yang-types {
15+
prefix bbf-yang;
16+
}
17+
import bbf-device-types {
18+
prefix bbf-dvct;
19+
}
20+
import bbf-node-types {
21+
prefix bbf-nodet;
22+
}
23+
24+
organization
25+
"Broadband Forum <https://www.broadband-forum.org>
26+
Common YANG Work Area";
27+
contact
28+
"Comments or questions about this Broadband Forum YANG module
29+
should be directed to <mailto:[email protected]>.
30+
31+
Editor: Nick Hancock, ADTRAN
32+
33+
Editor: Ludwig Pauwels, Nokia
34+
35+
PS Leader: Joey Boyd, ADTRAN
36+
37+
WA Director: Joey Boyd, ADTRAN
38+
39+
WA Director: Sven Ooghe, Nokia";
40+
41+
description
42+
"This module contains a collection of YANG definitions for
43+
supporting the Broadband Forum requirements on managing physical
44+
devices.";
45+
46+
revision 2022-03-01 {
47+
description
48+
"Amendment 5.
49+
* Approval Date: 2022-03-01.
50+
* Publication Date: 2022-03-01.";
51+
reference
52+
"TR-383a5: Common YANG Modules
53+
<https://www.broadband-forum.org/technical/download/
54+
TR-383_Amendment-5.pdf>";
55+
}
56+
57+
// Features
58+
59+
feature reports-device-powering-state {
60+
description
61+
"Indicates the support for reporting the device powering
62+
state.";
63+
}
64+
65+
// Device Properties
66+
67+
grouping device-alias {
68+
description
69+
"Alias information for the device.";
70+
leaf alias {
71+
type bbf-yang:string-ascii64;
72+
description
73+
"The alias that can be used to identify a device.";
74+
}
75+
}
76+
77+
// Device hardware information
78+
79+
80+
// Device Management Information
81+
82+
grouping device-management-info {
83+
description
84+
"Data nodes relating to management plane information needed to
85+
reach and communicate with the device.";
86+
leaf ip-address {
87+
type inet:host;
88+
description
89+
"The IP address or DNS domain name of the device.";
90+
}
91+
leaf port {
92+
type inet:port-number;
93+
description
94+
"The port number used on the device for
95+
management.";
96+
}
97+
leaf admin-state {
98+
type bbf-nodet:admin-state;
99+
description
100+
"The administrative state of the device.";
101+
}
102+
}
103+
104+
}

tests/outputs/bbf-device.yang.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.01
6+
elapsed_seconds : 0.0034480094909668
7+
n_files : 1
8+
n_lines : 104
9+
files_per_second : 290.022403540313
10+
lines_per_second : 30162.3299681925
11+
report_file : ../outputs/bbf-device.yang.yaml
12+
'Yang' :
13+
nFiles: 1
14+
blank: 18
15+
comment: 6
16+
code: 80
17+
SUM:
18+
blank: 18
19+
comment: 6
20+
code: 80
21+
nFiles: 1

0 commit comments

Comments
 (0)