gpt4 book ai didi

php - 从各种语言的源代码中删除/剥离所有注释的通用实用程序?

转载 作者:可可西里 更新时间:2023-10-31 22:49:07 26 4
gpt4 key购买 nike

我正在寻找一个命令行工具,可以从输入中删除所有评论文件并返回剥离的输出。支持流行就好了编程语言,如 c、c++、python、php、javascript、html、css 等。它必须是语法感知的,而不是基于正则表达式的,因为后者会捕获源代码字符串中的模式也是如此。有没有这样的工具?

我深知评论是有用的信息,经常留下照原样是个好主意。只是我的重点是不同的用例。

最佳答案

cloc ,一个免费的 Perl 脚本,可以做到这一点。

Remove Comments from Source Code

How can you tell if cloc correctly identifies comments? One way to convince yourself cloc is doing the right thing is to use its --strip-comments option to remove comments and blank lines from files, then compare the stripped-down files to originals.

支持a lot of languages .

关于php - 从各种语言的源代码中删除/剥离所有注释的通用实用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3349156/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com