Closed bennn closed 8 years ago
Can I commit test files to a new folder in this repo?
The way DrRacket gets the #lang
line is in drracket/private/module-language-tools.rkt. It gets an input port (L176), calls read-language
on that port (L199), gets the current line, column, and position after the read (L213). After that it gets the text up to that point (L215).
That can't be the whole story though, otherwise #|#lang scribble/manual|# #!racket
would throw it off, and it doesn't.
Re: test files in a separate folder: Yes that's a good idea.
Current strategy:
read-language
, get the end position (like Dr. Racket)read-string
up to the end positionregexp-match-positions*
to get the end of the last #lang
or #!
If I were a user, I would expect raco sloc --lang racket .
to only report #lang racket
files, and not #lang typed/racket
or #lang racket/base
. I might expect raco sloc --lang .*racket.* .
, or maybe raco sloc --lang #px".*racket.*" .
to do that, but not raco sloc --lang racket .
.
I can put the ^
and $
back. But then --lang racket
won't capture things like #lang sweet-exp racket
.
(We could add a second option that enables the old behavior. "old" = current = the pregexp on the command line is matched as-is against the string following #lang
or #!
)
You wouldn't have to use ^
and $
, you could use regexp-match-exact?
instead, and it would make more sense for a short string like a #lang
line.
Ok.
Are you alright with --lang racket
not matching #lang sweet-exp racket
?
Yes. If someone wants to use this feature, then they probably would be expecting this and they would be ready to write "racket|sweet-exp racket"
.
regexp-match-exact
lang-file-sloc/filter
returns 0 on failureWhat's .raco-sloc.rkt.swp
?
argh I did git add .
It's a vim-generated swapfile. Can I add *.swp
and *.swo
to the .gitignore
?
Yes you can add those to the .gitignore
.
Removed the unnecessary macro & unused imports.
Did you address this: https://github.com/AlexKnauth/syntax-sloc/pull/3#discussion_r64140555 ? Otherwise it will report the SLOC as 0 instead of N/A.
I hadn't. That's fixed now.
I just moved most of the #lang
-file-related stuff, incliding your read-#lang
function, to this repository:
https://github.com/AlexKnauth/lang-file
Add
--lang <PREGEXP>
command line option to limit search to files whose#lang
matches the regular expression."Works", but:
manually parses the#lang
line from a path stringno tests; should we make a reposyntax-sloc-test
with static files to count lines for?Will write docs once we agree on a design.Examples: