Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: count line of comment #3

Open
qin-nz opened this issue Apr 20, 2020 · 10 comments
Open

Suggestion: count line of comment #3

qin-nz opened this issue Apr 20, 2020 · 10 comments

Comments

@qin-nz
Copy link

qin-nz commented Apr 20, 2020

提个建议啊,你的 code 里面是不是包含了所有非空行的部分?
是否能再对这一部分进行拆分,统计注释的行数。

这里是别人的一个统计程序,但是UI确实不好看,而且种类没有你的全。
image

@hua1995116
Copy link
Owner

主要是注释不太好统计,因为语言不同,需要不通的解析器去解析吧。

@qin-nz
Copy link
Author

qin-nz commented Apr 20, 2020

@hua1995116
Copy link
Owner

确实可以,如果不考虑边界情况的话,逐行解析,blockComment 开头结尾匹配,就是需要维护那个大 的语言 json 。这两天我抽空试试看,或者你有空也可以尝试一下。😃

@qin-nz
Copy link
Author

qin-nz commented Apr 20, 2020

我不会 js /(ㄒoㄒ)/~~

@hua1995116
Copy link
Owner

哈哈哈,那没事,我这两天试一下吧。

@qin-nz
Copy link
Author

qin-nz commented Apr 20, 2020

你可以看看词法解析器这种东西,这样更复杂的东西也可以做了,比如 https://github.com/jimbojw/jslexhttps://github.com/royswastik/lexical-analyzer

以及,如果强行逐行解析的话,要注意这种 hello = "this is // stirng" 这种里面没有注释

@hua1995116
Copy link
Owner

现在只能做个大概的通用的,不同的语言解析不一样呀。单行的做个trim直接匹配开头就行了。

hua1995116 added a commit that referenced this issue May 4, 2020
@hua1995116
Copy link
Owner

已经支持 comments 了

@qin-nz
Copy link
Author

qin-nz commented May 6, 2020

1.4.1 确实实现了 comments,但我貌似发现了2个bug

  • code 数据里面包含了 blank
  • 我在 Windows 上新增1个空行(换行符为LF),但blank和code结果都+2
  • 新增一行代码,blank +1, code+2

@hua1995116
Copy link
Owner

现在考虑的基础版本有点问题,回头我用 LL(1)重写一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants