summaryrefslogtreecommitdiffstats
path: root/formal/promela/src/src/modules/comment_filter/comment_filter/language.py
blob: a934810e258d739920bd5d08507c54cffb42df0c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class Lang:
    def __init__(self, line_comment, comment_bookends, nested_comments):
        self.line_comment = line_comment
        self.comment_bookends = comment_bookends
        self.nested_comments = nested_comments
        self.string_literal_start = '"'
        self.string_literal2_start = "'"

c = Lang(
    line_comment='//',
    comment_bookends=[('/*', '*/'), (';;', ';;')],
    nested_comments=False)

haskell = Lang(
    line_comment='--',
    comment_bookends=[('{-', '-}')],
    nested_comments=True)

python = Lang(
    line_comment='#',
    comment_bookends=[('"""', '"""'), ("'''", "'''")],
    nested_comments=False)

ruby = Lang(
    line_comment='#',
    comment_bookends=[("=begin", "=end")],
    nested_comments=False)

lua = Lang(
    line_comment='--',
    comment_bookends=[("--[[", "--]]")],
    nested_comments=False)

perl = Lang(
    line_comment='#',
    comment_bookends=[("=pod", "=cut")],
    nested_comments=False)

java = Lang(
    line_comment='//',
    comment_bookends=[('/*', '*/')],
    nested_comments=True)

go = c

extension_to_lang_map = {
    '.c': c,
    '.cc': c,
    '.cxx': c,
    '.cpp': c,
    '.h': c,
    '.S': c,
    '.java': java,
    '.go': go,
    '.hs': haskell,
    '.py': python,
    '.rb': ruby,
    '.lua': lua,
    '.pl': perl,
}