AlexKnauth / syntax-sloc

counts the number of source lines of code in a racket syntax object
MIT License
3 stars 1 forks source link

Multiple line datum #12

Open sorawee opened 3 years ago

sorawee commented 3 years ago

Multiple line datum should be fully counted.

For example:

"abc
def
ghi
jkl
mno"

should be counted as 5 lines. Currently, it counts only 1.

Similarly:

(define |a
  b
  c
  d
  e|
  1)

should be counted as 6 lines. Currently, it counts only 2.

This is probably not fixable for syntax-sloc, due to the limited information of source location in syntax object, but for files, we should be able to use the span information to count the lines properly.

AlexKnauth commented 3 years ago

Source Location in syntax objects does contain span information, but that's span in position, not span in lines, so I'm not sure how that would help.

sorawee commented 3 years ago

If you have the actual file, you can read the file and move by the position span to get to the ending line.

AlexKnauth commented 3 years ago

Maybe an entirely different approach using lexer output instead of syntax objects, but if I make that it would probably be an entirely different repository