Repository navigation
Lexing defects found by comparing Tokei with each language's own lexer; fixes available #1394
mbackschat
started this conversation in
Ideas
Replies: 1 comment
|
Also related: open PR #1351 adds Go backtick strings. The fork reads them too, as raw strings without escapes that may span lines, as the Go specification defines them. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi, and thanks for Tokei. I maintain Locmetry, a line counter that embeds Tokei. Issues are disabled here, so I'm posting this as a discussion.
We checked Tokei 15.0.0's counts against each language's own lexer or parser on public repositories: the TypeScript scanner,
javac, the Kotlin compiler's lexer,rustc_lexer, CPython'stokenize, Roslyn and others. Where they disagreed, we traced the cause to a language definition or to the engine. Some examples:--inside a string starts a comment.'"'open a string in C, C++, Java, Rust, Zig and others.r##"…"##, Swift#"…"#, C#"""…""", C++R"x(…)x".//comments of JSON with Comments (VS Code settings,tsconfig.json) count as code..ppfiles count as Puppet, MATLAB and Mercury.mfiles as Objective-C, and Verilog.vfiles as Coq.The full list, with each defect's effect, is in tokei-defects.md. Each fix is a commit with a regression fixture in our fork, and its README cites the specification behind every declaration. Some fixes add new
languages.jsonfields; the README lists them too. The fork is faster than 15.0.0, or within 10% of it, on each of 69 public repositories we use as benchmarks. For the few languages where 15.0.0 declares no strings, upstream is given the fork's quotes, so the comparison measures only the engine; reading those strings costs extra time.Open PR #1389 addresses the character-literal case; our approach is in the fork if it helps compare.
I'd be glad to send pull requests for whichever of these you'd like upstream: one per defect or per language, small and each with its fixture. If none fit the project's direction, that's fine too. Just let me know what would be useful.
All reactions