Skip to content

Commit e6fe89b

Browse files
Merge pull request #30 from augmentable-dev/add-lisps
add Common Lisp and Emacs Lisp
2 parents 9d81e12 + 653b65c commit e6fe89b

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

pkg/comments/comments.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ var HashStyleCommentOptions *lege.ParseOptions = &lege.ParseOptions{
3737
},
3838
}
3939

40+
// LispStyleCommentOptions ..
41+
var LispStyleCommentOptions *lege.ParseOptions = &lege.ParseOptions{
42+
Boundaries: []lege.Boundary{
43+
{
44+
Start: ";",
45+
End: "\n",
46+
},
47+
},
48+
}
49+
4050
// Language is a source language (i.e. "Go")
4151
type Language string
4252

@@ -57,6 +67,8 @@ var LanguageParseOptions map[Language]*lege.ParseOptions = map[Language]*lege.Pa
5767
"Objective-C": CStyleCommentOptions,
5868
"Groovy": CStyleCommentOptions,
5969
"Swift": CStyleCommentOptions,
70+
"Common Lisp": LispStyleCommentOptions,
71+
"Emacs Lisp": LispStyleCommentOptions,
6072
}
6173

6274
// Comments is a list of comments

pkg/comments/comments_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package comments
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestJSFiles(t *testing.T) {
8+
var comments Comments
9+
err := SearchDir("testdata/javascript", func(comment *Comment) {
10+
comments = append(comments, comment)
11+
})
12+
if err != nil {
13+
t.Fatal(err)
14+
}
15+
16+
if len(comments) != 2 {
17+
t.Fail()
18+
}
19+
}
20+
21+
func TestLispFiles(t *testing.T) {
22+
var comments Comments
23+
err := SearchDir("testdata/lisp", func(comment *Comment) {
24+
comments = append(comments, comment)
25+
})
26+
if err != nil {
27+
t.Fatal(err)
28+
}
29+
30+
if len(comments) != 1 {
31+
t.Fail()
32+
}
33+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// this is a js comment
2+
3+
function helloWorld() {
4+
return "hello world"
5+
}
6+
7+
/* this is a block comment
8+
that spans multiple lines
9+
*/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
; Comment
2+
(+ 1 1)

0 commit comments

Comments
 (0)