From cc1bbcc9f4d68e70933d748fb42dc3530b7147e8 Mon Sep 17 00:00:00 2001 From: zzq Date: Thu, 7 Dec 2023 21:35:31 +0800 Subject: [PATCH] add slint support --- README.md | 1 + Unix/AUTHORS | 1 + Unix/cloc | 8 ++++++++ Unix/t/00_C.t | 5 +++++ cloc | 8 ++++++++ tests/inputs/Slint-helloworld.slint | 24 +++++++++++++++++++++++ tests/outputs/Slint-helloworld.slint.yaml | 20 +++++++++++++++++++ 7 files changed, 67 insertions(+) create mode 100644 tests/inputs/Slint-helloworld.slint create mode 100644 tests/outputs/Slint-helloworld.slint.yaml diff --git a/README.md b/README.md index d41d4b04..99c5ae24 100644 --- a/README.md +++ b/README.md @@ -1345,6 +1345,7 @@ yacc (y, yacc) YAML (clang-format, clang-tidy, gemrc, glide.lock, mir, reek, rviz, sublime-syntax, syntax, yaml, yaml-tmlanguage, yml, yml.mysql) Zig (zig) zsh (zsh) +Slint (slint) The above list can be customized by reading language definitions from a diff --git a/Unix/AUTHORS b/Unix/AUTHORS index b47b6636..653cbf10 100644 --- a/Unix/AUTHORS +++ b/Unix/AUTHORS @@ -28,3 +28,4 @@ https://github.com/kaelig https://github.com/mwiley https://github.com/michalmuskala https://github.com/Inventitech +https://github.com/zhangzqs \ No newline at end of file diff --git a/Unix/cloc b/Unix/cloc index 97a7763c..af1a26f2 100755 --- a/Unix/cloc +++ b/Unix/cloc @@ -9048,6 +9048,7 @@ sub set_constants { # {{{1 'yml' => 'YAML' , 'zig' => 'Zig' , 'zsh' => 'zsh' , + 'slint' => 'Slint' , ); # 1}}} %{$rh_Language_by_Script} = ( # {{{1 @@ -10742,6 +10743,11 @@ sub set_constants { # {{{1 [ 'remove_matches' , '^\s*#' ], [ 'remove_inline' , '#.*$' ], ], + 'Slint' => [ + [ 'rm_comments_in_strings', '"', '/*', '*/' ], + [ 'rm_comments_in_strings', '"', '//', '' ], + [ 'call_regexp_common' , 'C++' ], + ], ); # 1}}} %{$rh_EOL_continuation_re} = ( # {{{1 @@ -10814,6 +10820,7 @@ sub set_constants { # {{{1 'Vyper' => '\\\\$' , 'X++' => '\\\\$' , 'zsh' => '\\\\$' , + 'Slint' => '\\\\$' , ); # 1}}} %{$rh_Not_Code_Extension} = ( # {{{1 @@ -11323,6 +11330,7 @@ sub set_constants { # {{{1 'Verilog-SystemVerilog/Coq' => 1.00, 'MATLAB/Mathematica/Objective-C/MUMPS/Mercury' => 1.00, 'IDL/Qt Project/Prolog/ProGuard' => 1.00, + 'Slint' => 1.00, ); # 1}}} %{$rh_Known_Binary_Archives} = ( # {{{1 diff --git a/Unix/t/00_C.t b/Unix/t/00_C.t index 9c2f298e..d7ab4e70 100755 --- a/Unix/t/00_C.t +++ b/Unix/t/00_C.t @@ -1321,6 +1321,11 @@ my @Tests = ( 'ref' => '../tests/outputs/zir_sema.zig.yaml', 'args' => '../tests/inputs/zir_sema.zig', }, + { + 'name' => 'Slint', + 'ref' => '../tests/outputs/Slint-helloworld.slint.yaml', + 'args' => '../tests/inputs/Slint-helloworld.slint', + }, ); my $Verbose = 0; diff --git a/cloc b/cloc index 4e9af084..115c8a04 100755 --- a/cloc +++ b/cloc @@ -9063,6 +9063,7 @@ sub set_constants { # {{{1 'yml' => 'YAML' , 'zig' => 'Zig' , 'zsh' => 'zsh' , + 'slint' => 'Slint' , ); # 1}}} %{$rh_Language_by_Script} = ( # {{{1 @@ -10757,6 +10758,11 @@ sub set_constants { # {{{1 [ 'remove_matches' , '^\s*#' ], [ 'remove_inline' , '#.*$' ], ], + 'Slint' => [ + [ 'rm_comments_in_strings', '"', '/*', '*/' ], + [ 'rm_comments_in_strings', '"', '//', '' ], + [ 'call_regexp_common' , 'C++' ], + ], ); # 1}}} %{$rh_EOL_continuation_re} = ( # {{{1 @@ -10829,6 +10835,7 @@ sub set_constants { # {{{1 'Vyper' => '\\\\$' , 'X++' => '\\\\$' , 'zsh' => '\\\\$' , + 'Slint' => '\\\\$' , ); # 1}}} %{$rh_Not_Code_Extension} = ( # {{{1 @@ -11338,6 +11345,7 @@ sub set_constants { # {{{1 'Verilog-SystemVerilog/Coq' => 1.00, 'MATLAB/Mathematica/Objective-C/MUMPS/Mercury' => 1.00, 'IDL/Qt Project/Prolog/ProGuard' => 1.00, + 'Slint' => 1.00, ); # 1}}} %{$rh_Known_Binary_Archives} = ( # {{{1 diff --git a/tests/inputs/Slint-helloworld.slint b/tests/inputs/Slint-helloworld.slint new file mode 100644 index 00000000..0ac82fbd --- /dev/null +++ b/tests/inputs/Slint-helloworld.slint @@ -0,0 +1,24 @@ +component MyButton inherits Text { + color: black; + // ... +} + +export component MyApp inherits Window { + preferred-width: 200px; + preferred-height: 100px; + Rectangle { + width: 200px; + height: 100px; + background: green; + + }/* */ + MyButton { + x:0;y:0; // hello + text: "hello"; + } + MyButton { // world + y:0; + x: 50px; + text: "world"; + } +} \ No newline at end of file diff --git a/tests/outputs/Slint-helloworld.slint.yaml b/tests/outputs/Slint-helloworld.slint.yaml new file mode 100644 index 00000000..49d5b6a9 --- /dev/null +++ b/tests/outputs/Slint-helloworld.slint.yaml @@ -0,0 +1,20 @@ +--- +# github.com/AlDanial/cloc +header : + cloc_url : github.com/AlDanial/cloc + cloc_version : 1.99 + elapsed_seconds : 0.00504088401794434 + n_files : 1 + n_lines : 24 + files_per_second : 198.377902852008 + lines_per_second : 4761.06966844819 +'Slint' : + nFiles: 1 + blank: 2 + comment: 1 + code: 21 +SUM: + blank: 2 + comment: 1 + code: 21 + nFiles: 1 \ No newline at end of file