source: rtems-central/formal/promela/src/src/modules/comment_filter/comment_filter/language.py @ 13ed9da

Last change on this file since 13ed9da was 13ed9da, checked in by Andrew Butterfield <Andrew.Butterfield@…>, on 01/13/23 at 15:36:54

forked from https://github.com/quic/comment-filter/commits/master
commit 9cfb52318e5f71af56b5808e280a9b089b9abc32

  • Property mode set to 100644
File size: 1.3 KB
Line 
1class Lang:
2    def __init__(self, line_comment, comment_bookends, nested_comments):
3        self.line_comment = line_comment
4        self.comment_bookends = comment_bookends
5        self.nested_comments = nested_comments
6        self.string_literal_start = '"'
7        self.string_literal2_start = "'"
8
9c = Lang(
10    line_comment='//',
11    comment_bookends=[('/*', '*/'), (';;', ';;')],
12    nested_comments=False)
13
14haskell = Lang(
15    line_comment='--',
16    comment_bookends=[('{-', '-}')],
17    nested_comments=True)
18
19python = Lang(
20    line_comment='#',
21    comment_bookends=[('"""', '"""'), ("'''", "'''")],
22    nested_comments=False)
23
24ruby = Lang(
25    line_comment='#',
26    comment_bookends=[("=begin", "=end")],
27    nested_comments=False)
28
29lua = Lang(
30    line_comment='--',
31    comment_bookends=[("--[[", "--]]")],
32    nested_comments=False)
33
34perl = Lang(
35    line_comment='#',
36    comment_bookends=[("=pod", "=cut")],
37    nested_comments=False)
38
39java = Lang(
40    line_comment='//',
41    comment_bookends=[('/*', '*/')],
42    nested_comments=True)
43
44go = c
45
46extension_to_lang_map = {
47    '.c': c,
48    '.cc': c,
49    '.cxx': c,
50    '.cpp': c,
51    '.h': c,
52    '.S': c,
53    '.java': java,
54    '.go': go,
55    '.hs': haskell,
56    '.py': python,
57    '.rb': ruby,
58    '.lua': lua,
59    '.pl': perl,
60}
Note: See TracBrowser for help on using the repository browser.