summaryrefslogtreecommitdiffstats
path: root/formal/promela/src/src/modules/comment_filter/bin/comments
diff options
context:
space:
mode:
Diffstat (limited to 'formal/promela/src/src/modules/comment_filter/bin/comments')
-rwxr-xr-xformal/promela/src/src/modules/comment_filter/bin/comments25
1 files changed, 25 insertions, 0 deletions
diff --git a/formal/promela/src/src/modules/comment_filter/bin/comments b/formal/promela/src/src/modules/comment_filter/bin/comments
new file mode 100755
index 00000000..0b9c7d5a
--- /dev/null
+++ b/formal/promela/src/src/modules/comment_filter/bin/comments
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import fileinput
+from comment_filter import language
+import comment_filter
+import argparse
+from comment_filter import _version
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--onlycode', help='filter out comments', action='store_true')
+ parser.add_argument('--notokens', help='filter out comment tokens', action='store_true')
+ parser.add_argument('--version', action='version', version=_version.__version__)
+ parser.add_argument('path', help='path to file to parse')
+ args = parser.parse_args()
+
+ _, ext = os.path.splitext(args.path)
+ lang = language.extension_to_lang_map.get(ext, language.c)
+ input_stream = fileinput.input(args.path)
+ keep_tokens = not args.notokens
+ for line in comment_filter.parse_file(lang, input_stream, code_only=args.onlycode, keep_tokens=keep_tokens):
+ sys.stdout.write(line)