XAMPPRocky / tokei

Count your code, quickly.
Other
11.38k stars 542 forks source link

Add vlang to supported languages. #889

Open rawhuul opened 2 years ago

rawhuul commented 2 years ago

V programming language, is a statically typed ready for development language. Many projects do use it. It would be great to support it. Thanks <3

rawhuul commented 2 years ago

Adding this V specs to langauges.toml leads to following warning, which doesn't happen with normal build

"V": {
      "line_comment": ["//"],
      "multi_line_comments": [["/*", "*/"]],
      "quotes": [
        ["\\\"", "\\\""],
        ["'", "'"]
      ],
      "extensions": ["v"]
    },

Build after adding V specs:

tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.58.1 ❯ cargo build
warning: unreachable pattern
    --> /home/basic/tokei/target/debug/build/tokei-82b1a624d7bb49bc/out/language_type.rs:5134:17
     |
5134 |                 | "v" => Some(V),
     |                 ^^^^^
     |
     = note: `#[warn(unreachable_patterns)]` on by default

warning: `tokei` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.58.1 ❯ 

Normal build from master branch:

tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.58.1 ❯ cd ~/Downloads/tokei/
tokei on  master is 📦 v12.1.2 via 🦀 v1.58.1 ❯ cargo build
   Compiling libc v0.2.112
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.0.1
   Compiling memchr v2.4.1
   Compiling proc-macro2 v1.0.36
   Compiling unicode-xid v0.2.2
   Compiling version_check v0.9.4
   Compiling syn v1.0.85
   Compiling lazy_static v1.4.0
   Compiling regex-syntax v0.6.25
   Compiling crossbeam-utils v0.8.6
   Compiling siphasher v0.3.9
   Compiling ppv-lite86 v0.2.16
   Compiling log v0.4.14
   Compiling serde_derive v1.0.133
   Compiling serde v1.0.133
   Compiling scopeguard v1.1.0
   Compiling ucd-trie v0.1.3
   Compiling maplit v1.0.2
   Compiling once_cell v1.9.0
   Compiling unic-char-range v0.9.0
   Compiling fnv v1.0.7
   Compiling unic-common v0.9.0
   Compiling same-file v1.0.6
   Compiling bitflags v1.3.2
   Compiling serde_json v1.0.75
   Compiling crossbeam-epoch v0.9.6
   Compiling encoding_rs v0.8.30
   Compiling ryu v1.0.9
   Compiling itoa v1.0.1
   Compiling deunicode v0.4.3
   Compiling parking_lot_core v0.8.5
   Compiling rayon-core v1.9.1
   Compiling percent-encoding v2.1.0
   Compiling arrayvec v0.4.12
   Compiling humansize v1.1.1
   Compiling smallvec v1.8.0
   Compiling hashbrown v0.11.2
   Compiling termcolor v1.1.2
   Compiling nodrop v0.1.14
   Compiling either v1.6.1
   Compiling bytecount v0.6.2
   Compiling humantime v2.1.0
   Compiling strsim v0.10.0
   Compiling itoa v0.4.8
   Compiling instant v0.1.12
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling memoffset v0.6.5
   Compiling indexmap v1.8.0
   Compiling rayon v1.5.1
   Compiling uncased v0.9.6
   Compiling lock_api v0.4.5
   Compiling pest v2.1.3
   Compiling unic-char-property v0.9.0
   Compiling thread_local v1.1.3
   Compiling unic-ucd-version v0.9.0
   Compiling walkdir v2.3.2
   Compiling slug v0.1.4
   Compiling unic-ucd-segment v0.9.0
   Compiling pest_meta v2.1.3
   Compiling aho-corasick v0.7.18
   Compiling bstr v0.2.17
   Compiling grep-matcher v0.1.5
   Compiling os_str_bytes v6.0.0
   Compiling getrandom v0.2.4
   Compiling num_cpus v1.13.1
   Compiling atty v0.2.14
   Compiling terminal_size v0.1.17
   Compiling memmap2 v0.3.1
   Compiling dirs-sys v0.3.6
   Compiling term_size v0.3.2
   Compiling quote v1.0.14
   Compiling crossbeam-channel v0.5.2
   Compiling unic-segment v0.9.0
   Compiling num-format v0.4.0
   Compiling regex v1.5.4
   Compiling encoding_rs_io v0.1.7
   Compiling rand_core v0.6.3
   Compiling colored v2.0.0
   Compiling textwrap v0.14.2
   Compiling parking_lot v0.11.2
   Compiling dirs v4.0.0
   Compiling phf_shared v0.10.0
   Compiling grep-searcher v0.1.8
   Compiling rand_chacha v0.3.1
   Compiling clap v3.0.10
   Compiling parse-zoneinfo v0.3.0
   Compiling globset v0.4.8
   Compiling env_logger v0.8.4
   Compiling crossbeam-deque v0.8.1
   Compiling phf v0.10.1
   Compiling chrono v0.4.19
   Compiling rand v0.8.4
   Compiling pest_generator v2.1.3
   Compiling ignore v0.4.18
   Compiling derive_arbitrary v1.0.2
   Compiling phf_generator v0.10.0
   Compiling pest_derive v2.1.0
   Compiling globwalk v0.8.1
   Compiling phf_codegen v0.10.0
   Compiling arbitrary v1.0.3
   Compiling chrono-tz-build v0.0.2
   Compiling chrono-tz v0.6.1
   Compiling toml v0.5.8
   Compiling dashmap v5.0.0
   Compiling tera v1.15.0
   Compiling tokei v12.1.2 (/home/basic/Downloads/tokei)
    Finished dev [unoptimized + debuginfo] target(s) in 1m 08s
tokei on  master is 📦 v12.1.2 via 🦀 v1.58.1 took 1m8s ❯ 

Moreover, here are result of normal tokei from my distro repository and one I compiled with V lang specs:

Here, ~/v is source of vlang and doesn't report any V files.

tokei on  master is 📦 v12.1.2 via 🦀 v1.58.1 took 1m8s ❯ tokei ~/v
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Batch                   3          356          288           10           58
 C                      16        36682        35097          642          943
 C Header               36        62574        47852         9573         5149
 Coq                  2021       289808       253932        12652        23224
 CSS                     4          957          903            9           45
 Dockerfile              5           65           44            4           17
 GLSL                    7         2261         1577          324          360
 Go                      1           68           63            0            5
 JavaScript              4          380          344           12           24
 JSON                    4          249          249            0            0
 Makefile                2           78           61            0           17
 Objective-C             4          165          114           28           23
 Python                  3           92           70            2           20
 Shell                   5          144           93            8           43
 SQL                     1          122           46           38           38
 SVG                    10        11278        11268            0           10
 Plain Text             50         1481            0         1180          301
 TOML                   12          303          209           40           54
 XML                     1            9            9            0            0
 YAML                   24         2400         1976          222          202
-------------------------------------------------------------------------------
 HTML                   19          260          219            0           41
 |- CSS                  2           41           40            0            1
 |- JavaScript           3           35           34            0            1
 (Total)                            336          293            0           43
-------------------------------------------------------------------------------
 Markdown              112        12258            0         9685         2573
 |- BASH                 6           72           65            0            7
 |- C                    2           89           73            9            7
 |- HTML                 3           66           66            0            0
 |- JSON                 1           43           43            0            0
 |- PowerShell           1           18           18            0            0
 |- Shell                1            7            7            0            0
 (Total)                          12553          272         9694         2587
===============================================================================
 Total                2344       421990       354414        34429        33147
===============================================================================
tokei on  master is 📦 v12.1.2 via 🦀 v1.58.1 ❯ 

It's my build with V spec in languages.json:

tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.60.0-nightly took 7s ❯ ./target/debug/tokei ~/v
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Batch                   3          356          288           10           58
 C                      16        36682        35097          642          943
 C Header               36        62574        47852         9573         5149
 Coq                  2021       289808       253932        12652        23224
 CSS                     4          957          903            9           45
 Dockerfile              5           65           44            4           17
 GLSL                    7         2261         1577          324          360
 Go                      1           68           63            0            5
 JavaScript              4          380          344           12           24
 JSON                    4          249          249            0            0
 Makefile                2           78           61            0           17
 Objective-C             4          165          114           28           23
 Python                  3           92           70            2           20
 Shell                   5          144           93            8           43
 SQL                     1          122           46           38           38
 SVG                    10        11278        11268            0           10
 Plain Text             50         1481            0         1180          301
 TOML                   12          303          209           40           54
 XML                     1            9            9            0            0
 YAML                   24         2400         1976          222          202
-------------------------------------------------------------------------------
 HTML                   19          260          219            0           41
 |- CSS                  2           41           40            0            1
 |- JavaScript           3           35           34            0            1
 (Total)                            336          293            0           43
-------------------------------------------------------------------------------
 Markdown              112         7625            0         5541         2084
 |- BASH                 6           72           65            0            7
 |- C                    2           89           73            9            7
 |- HTML                 3           66           66            0            0
 |- JSON                 1           43           43            0            0
 |- PowerShell           1           18           18            0            0
 |- Shell                1            7            7            0            0
 |- V                   37         4792         3781          533          478
 (Total)                          12712         4053         6083         2576
===============================================================================
 Total                2344       417357       354414        30285        32658
===============================================================================
tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.60.0-nightly ❯ 

It does report V but in Markdown section and if you look at vlang src, github says source code contains 99% of vlang but this stats doesn't satisfy it at all.

rawhuul commented 2 years ago

Sorry, I did changed my toolchain in between, but results are same with stable compiler too.

tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.58.1 ❯ cargo build
   Compiling tokei v12.1.2 (/home/basic/tokei)
warning: unreachable pattern
    --> /home/basic/tokei/target/debug/build/tokei-82b1a624d7bb49bc/out/language_type.rs:5134:17
     |
5134 |                 | "v" => Some(V),
     |                 ^^^^^
     |
     = note: `#[warn(unreachable_patterns)]` on by default

warning: `tokei` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 4.29s
tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.58.1 took 4s ❯ ./target/debug/tokei ~/v
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 Batch                   3          356          288           10           58
 C                      16        36682        35097          642          943
 C Header               36        62574        47852         9573         5149
 Coq                  2021       289808       253932        12652        23224
 CSS                     4          957          903            9           45
 Dockerfile              5           65           44            4           17
 GLSL                    7         2261         1577          324          360
 Go                      1           68           63            0            5
 JavaScript              4          380          344           12           24
 JSON                    4          249          249            0            0
 Makefile                2           78           61            0           17
 Objective-C             4          165          114           28           23
 Python                  3           92           70            2           20
 Shell                   5          144           93            8           43
 SQL                     1          122           46           38           38
 SVG                    10        11278        11268            0           10
 Plain Text             50         1481            0         1180          301
 TOML                   12          303          209           40           54
 XML                     1            9            9            0            0
 YAML                   24         2400         1976          222          202
-------------------------------------------------------------------------------
 HTML                   19          260          219            0           41
 |- CSS                  2           41           40            0            1
 |- JavaScript           3           35           34            0            1
 (Total)                            336          293            0           43
-------------------------------------------------------------------------------
 Markdown              112         7625            0         5541         2084
 |- BASH                 6           72           65            0            7
 |- C                    2           89           73            9            7
 |- HTML                 3           66           66            0            0
 |- JSON                 1           43           43            0            0
 |- PowerShell           1           18           18            0            0
 |- Shell                1            7            7            0            0
 |- V                   37         4792         3781          533          478
 (Total)                          12712         4053         6083         2576
===============================================================================
 Total                2344       417357       354414        30285        32658
===============================================================================
tokei on  master [!] is 📦 v12.1.2 via 🦀 v1.58.1 ❯ 
CosmicHorrorDev commented 2 years ago

Both the warning and the output from the project you posted are because the v extension is currently assigned to Coq. I don't believe there are any ways to deal with conflicts like this in tokei at the moment

rawhuul commented 2 years ago

Cool, sounds reasonable. But cloc and scc does support it. Like Verilog and Coq, both have same extension *.v but scc makes decision on keywords check, you can see here, they also do use language.json.