PyReprism 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyReprism/__init__.py +0 -0
- PyReprism/languages/__init__.py +147 -0
- PyReprism/languages/_base.py +30 -0
- PyReprism/languages/abap.py +52 -0
- PyReprism/languages/actionscript.py +52 -0
- PyReprism/languages/ada.py +53 -0
- PyReprism/languages/apacheconf.py +52 -0
- PyReprism/languages/apl.py +52 -0
- PyReprism/languages/applescript.py +52 -0
- PyReprism/languages/arduino.py +52 -0
- PyReprism/languages/arff.py +52 -0
- PyReprism/languages/asciidoc.py +52 -0
- PyReprism/languages/asm6502.py +51 -0
- PyReprism/languages/aspnet.py +51 -0
- PyReprism/languages/autohotkey.py +51 -0
- PyReprism/languages/autoit.py +50 -0
- PyReprism/languages/bash.py +52 -0
- PyReprism/languages/basic.py +52 -0
- PyReprism/languages/batch.py +52 -0
- PyReprism/languages/bison.py +52 -0
- PyReprism/languages/brainfuck.py +52 -0
- PyReprism/languages/bro.py +50 -0
- PyReprism/languages/c.py +52 -0
- PyReprism/languages/clike.py +52 -0
- PyReprism/languages/clojure.py +50 -0
- PyReprism/languages/coffeescript.py +50 -0
- PyReprism/languages/cpp.py +52 -0
- PyReprism/languages/crystal.py +50 -0
- PyReprism/languages/csharp.py +53 -0
- PyReprism/languages/csp.py +50 -0
- PyReprism/languages/css.py +50 -0
- PyReprism/languages/css_extras.py +50 -0
- PyReprism/languages/d.py +50 -0
- PyReprism/languages/dart.py +52 -0
- PyReprism/languages/diff.py +49 -0
- PyReprism/languages/django.py +55 -0
- PyReprism/languages/docker.py +50 -0
- PyReprism/languages/eiffel.py +49 -0
- PyReprism/languages/elixir.py +50 -0
- PyReprism/languages/erb.py +0 -0
- PyReprism/languages/erlang.py +50 -0
- PyReprism/languages/flow.py +0 -0
- PyReprism/languages/fortran.py +49 -0
- PyReprism/languages/fsharp.py +49 -0
- PyReprism/languages/gedcom.py +0 -0
- PyReprism/languages/gherkin.py +0 -0
- PyReprism/languages/git.py +0 -0
- PyReprism/languages/glsl.py +0 -0
- PyReprism/languages/go.py +53 -0
- PyReprism/languages/graphql.py +50 -0
- PyReprism/languages/groovy.py +53 -0
- PyReprism/languages/haml.py +50 -0
- PyReprism/languages/handlebars.py +0 -0
- PyReprism/languages/haskell.py +53 -0
- PyReprism/languages/haxe.py +0 -0
- PyReprism/languages/hpkp.py +0 -0
- PyReprism/languages/hsts.py +0 -0
- PyReprism/languages/html.py +50 -0
- PyReprism/languages/ichigojam.py +0 -0
- PyReprism/languages/icon.py +0 -0
- PyReprism/languages/inform7.py +0 -0
- PyReprism/languages/ini.py +41 -0
- PyReprism/languages/io.py +0 -0
- PyReprism/languages/j.py +50 -0
- PyReprism/languages/java.py +53 -0
- PyReprism/languages/javascript.py +53 -0
- PyReprism/languages/jolie.py +50 -0
- PyReprism/languages/json.py +50 -0
- PyReprism/languages/jsx.py +53 -0
- PyReprism/languages/julia.py +53 -0
- PyReprism/languages/keyman.py +0 -0
- PyReprism/languages/kotlin.py +53 -0
- PyReprism/languages/latex.py +50 -0
- PyReprism/languages/less.py +50 -0
- PyReprism/languages/liquid.py +49 -0
- PyReprism/languages/livescript.py +49 -0
- PyReprism/languages/lolcode.py +0 -0
- PyReprism/languages/lua.py +0 -0
- PyReprism/languages/makefile.py +50 -0
- PyReprism/languages/markdown.py +31 -0
- PyReprism/languages/markup.py +50 -0
- PyReprism/languages/markup_templating.py +0 -0
- PyReprism/languages/matlab.py +51 -0
- PyReprism/languages/mel.py +0 -0
- PyReprism/languages/mizar.py +0 -0
- PyReprism/languages/monkey.py +0 -0
- PyReprism/languages/n4js.py +50 -0
- PyReprism/languages/nasm.py +0 -0
- PyReprism/languages/nginx.py +50 -0
- PyReprism/languages/nim.py +0 -0
- PyReprism/languages/nix.py +0 -0
- PyReprism/languages/nsis.py +0 -0
- PyReprism/languages/objectivec.py +49 -0
- PyReprism/languages/ocaml.py +51 -0
- PyReprism/languages/opencl.py +0 -0
- PyReprism/languages/oz.py +0 -0
- PyReprism/languages/parigp.py +0 -0
- PyReprism/languages/parser.py +0 -0
- PyReprism/languages/pascal.py +49 -0
- PyReprism/languages/perl.py +53 -0
- PyReprism/languages/php.py +50 -0
- PyReprism/languages/php_extras.py +0 -0
- PyReprism/languages/plsql.py +0 -0
- PyReprism/languages/powershell.py +0 -0
- PyReprism/languages/processing.py +0 -0
- PyReprism/languages/prolog.py +51 -0
- PyReprism/languages/properties.py +0 -0
- PyReprism/languages/protobuf.py +0 -0
- PyReprism/languages/pug.py +0 -0
- PyReprism/languages/puppet.py +0 -0
- PyReprism/languages/pure.py +0 -0
- PyReprism/languages/python.py +54 -0
- PyReprism/languages/q.py +0 -0
- PyReprism/languages/qore.py +0 -0
- PyReprism/languages/r.py +0 -0
- PyReprism/languages/reason.py +0 -0
- PyReprism/languages/renpy.py +0 -0
- PyReprism/languages/rest.py +0 -0
- PyReprism/languages/rip.py +0 -0
- PyReprism/languages/roboconf.py +0 -0
- PyReprism/languages/ruby.py +50 -0
- PyReprism/languages/rust.py +52 -0
- PyReprism/languages/sas.py +0 -0
- PyReprism/languages/sass.py +0 -0
- PyReprism/languages/scala.py +53 -0
- PyReprism/languages/scheme.py +51 -0
- PyReprism/languages/scss.py +50 -0
- PyReprism/languages/smalltalk.py +51 -0
- PyReprism/languages/smarty.py +0 -0
- PyReprism/languages/soy.py +0 -0
- PyReprism/languages/stylus.py +52 -0
- PyReprism/languages/swift.py +52 -0
- PyReprism/languages/tcl.py +0 -0
- PyReprism/languages/textile.py +0 -0
- PyReprism/languages/tsx.py +52 -0
- PyReprism/languages/twig.py +0 -0
- PyReprism/languages/typescript.py +52 -0
- PyReprism/languages/vbnet.py +51 -0
- PyReprism/languages/velocity.py +52 -0
- PyReprism/languages/verilog.py +0 -0
- PyReprism/languages/vhdl.py +0 -0
- PyReprism/languages/vim.py +52 -0
- PyReprism/languages/visual_basic.py +52 -0
- PyReprism/languages/wasam.py +0 -0
- PyReprism/languages/xeora.py +0 -0
- PyReprism/languages/xojo.py +0 -0
- PyReprism/languages/yaml.py +53 -0
- PyReprism/utils/__init__.py +0 -0
- PyReprism/utils/extension.py +149 -0
- PyReprism/utils/normalizer.py +18 -0
- pyreprism-0.0.1.dist-info/METADATA +94 -0
- pyreprism-0.0.1.dist-info/RECORD +154 -0
- pyreprism-0.0.1.dist-info/WHEEL +4 -0
- pyreprism-0.0.1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class MarkDown:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def comment():
|
|
10
|
+
|
|
11
|
+
return re.compile(r'(?P<multilinecomment><!--.*?-->)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^/\'"]*)', re.DOTALL | re.MULTILINE)
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def remove_comments(source: str):
|
|
15
|
+
return re.sub(MarkDown.comment, '', source)
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def file_extension():
|
|
19
|
+
return extension.markdown
|
|
20
|
+
|
|
21
|
+
@staticmethod
|
|
22
|
+
def keywords() -> list:
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def remove_keywords(source: str):
|
|
27
|
+
keywords = MarkDown.keywords()
|
|
28
|
+
pattern = r'\b(' + '|'.join(keywords) + r')\b'
|
|
29
|
+
|
|
30
|
+
return re.sub(re.compile(pattern), '', source)
|
|
31
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class MarkUp:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.markup
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = ''.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<multilinecomment><!--.*?-->)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^/\'"]*)', re.DOTALL | re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = ''
|
|
26
|
+
return pattern
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def operator_regex():
|
|
30
|
+
pattern = ''
|
|
31
|
+
return pattern
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def keywords_regex():
|
|
35
|
+
return re.compile(r'\b(' + '|'.join(MarkUp.keywords()) + r')\b', re.IGNORECASE)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in MarkUp.comment_regex().finditer(source_code):
|
|
41
|
+
if match.group('noncomment'):
|
|
42
|
+
result.append(match.group('noncomment'))
|
|
43
|
+
if isList:
|
|
44
|
+
return result
|
|
45
|
+
return ''.join(result)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def remove_keywords(source: str):
|
|
50
|
+
return re.sub(re.compile(MarkUp.keywords_regex()), '', source)
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class MatLab:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.matlab
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = 'break|case|catch|continue|else|elseif|end|for|function|if|inf|NaN|otherwise|parfor|pause|pi|return|switch|try|while'.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>%\{[\s\S]*?\}%|%.*?$)|(?P<noncomment>[^%]*)', re.MULTILINE
|
|
21
|
+
)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'(?:\b\d+\.?\d*|\B\.\d+)(?:[eE][+-]?\d+)?(?:[ij])?|\b[ij]\b', re.IGNORECASE)
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r"\.?[*^\/\\']|[+\-:@]|[<>=~]=?|&&?|\|\|?")
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(MatLab.keywords()) + r')\b', re.IGNORECASE)
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in MatLab.comment_regex().finditer(source_code):
|
|
42
|
+
if match.group('noncomment'):
|
|
43
|
+
result.append(match.group('noncomment'))
|
|
44
|
+
if isList:
|
|
45
|
+
return result
|
|
46
|
+
return ''.join(result)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def remove_keywords(source: str):
|
|
51
|
+
return re.sub(re.compile(MatLab.keywords_regex()), '', source)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class N4js:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.n4js
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = ''.split('|')
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>/\*[\s\S]*?\*/|/\*.*?$|^.*?\*/)|(?P<noncomment>[^/*]*[^\n]*)',re.DOTALL | re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = re.compile(r'')
|
|
26
|
+
return pattern
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def operator_regex():
|
|
30
|
+
pattern = re.compile(r'')
|
|
31
|
+
return pattern
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def keywords_regex():
|
|
35
|
+
return re.compile(r'\b(' + '|'.join(N4js.keywords()) + r')\b')
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in N4js.comment_regex().finditer(source_code):
|
|
41
|
+
if match.group('noncomment'):
|
|
42
|
+
result.append(match.group('noncomment'))
|
|
43
|
+
if isList:
|
|
44
|
+
return result
|
|
45
|
+
return ''.join(result)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def remove_keywords(source: str):
|
|
49
|
+
return re.sub(re.compile(N4js.keywords_regex()), '', source)
|
|
50
|
+
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Nginx:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.nginx
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = ''.split('|')
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>#.*?$)|(?P<noncomment>[^#\n]*[^\n]*)', re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = re.compile(r'')
|
|
26
|
+
return pattern
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def operator_regex():
|
|
30
|
+
pattern = re.compile(r'')
|
|
31
|
+
return pattern
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def keywords_regex():
|
|
35
|
+
return re.compile(r'\b(' + '|'.join(Nginx.keywords()) + r')\b')
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in Nginx.comment_regex().finditer(source_code):
|
|
41
|
+
if match.group('noncomment'):
|
|
42
|
+
result.append(match.group('noncomment'))
|
|
43
|
+
if isList:
|
|
44
|
+
return result
|
|
45
|
+
return ''.join(result)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def remove_keywords(source: str):
|
|
49
|
+
return re.sub(re.compile(Nginx.keywords_regex()), '', source)
|
|
50
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class ObjectiveC:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.objectivec
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = 'asm|typeof|inline|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while|in|self|super)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector'.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*[\s\S]*?\*/)|(?P<noncomment>[^/]*[^\n]*)',re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = re.compile(r'(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*', re.IGNORECASE)
|
|
26
|
+
return pattern
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def operator_regex():
|
|
30
|
+
pattern = re.compile(r'-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]')
|
|
31
|
+
return pattern
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def keywords_regex():
|
|
35
|
+
return re.compile(r'\b(' + '|'.join(ObjectiveC.keywords()) + r')\b', re.IGNORECASE)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in ObjectiveC.comment_regex().finditer(source_code):
|
|
41
|
+
if match.group('noncomment'):
|
|
42
|
+
result.append(match.group('noncomment'))
|
|
43
|
+
if isList:
|
|
44
|
+
return result
|
|
45
|
+
return ''.join(result)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def remove_keywords(source: str):
|
|
49
|
+
return re.sub(re.compile(ObjectiveC.keywords_regex()), '', source)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class Ocaml:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.ocaml
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = ''.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>(\(\*[\s\S]*?\*\)|;.*?$|;;.*?$))|(?P<noncomment>[^;(*]*[^\n]*)',re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'')
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r'')
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Ocaml.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Ocaml.comment_regex().finditer(source_code):
|
|
42
|
+
if match.group('noncomment'):
|
|
43
|
+
result.append(match.group('noncomment'))
|
|
44
|
+
if isList:
|
|
45
|
+
return result
|
|
46
|
+
return ''.join(result)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def remove_keywords(source: str):
|
|
51
|
+
return re.sub(re.compile(Ocaml.keywords_regex()), '', source)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class Pascal:
|
|
5
|
+
def __init__(self):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.pascal
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = 'absolute|array|asm|begin|case|const|constructor|destructor|do|downto|else|end|file|for|function|goto|if|implementation|inherited|inline|interface|label|nil|object|of|operator|packed|procedure|program|record|reintroduce|repeat|self|set|string|then|to|type|unit|until|uses|var|while|with|dispose|exit|false|new|true|class|dispinterface|except|exports|finalization|finally|initialization|inline|library|on|out|packed|property|raise|resourcestring|threadvar|try|absolute|abstract|alias|assembler|bitpacked|break|cdecl|continue|cppdecl|cvar|default|deprecated|dynamic|enumerator|experimental|export|external|far|far16|forward|generic|helper|implements|index|interrupt|iochecks|local|message|name|near|nodefault|noreturn|nostackframe|oldfpccall|otherwise|overload|override|pascal|platform|private|protected|public|published|read|register|reintroduce|result|safecall|saveregisters|softfloat|specialize|static|stdcall|stored|strict|unaligned|unimplemented|varargs|virtual|write'.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
return re.compile(r'(?P<comment>#.*?$)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^#\'"]*)', re.DOTALL | re.MULTILINE)
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def number_regex():
|
|
24
|
+
pattern = re.compile(r'(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b', re.IGNORECASE)
|
|
25
|
+
return pattern
|
|
26
|
+
|
|
27
|
+
@staticmethod
|
|
28
|
+
def operator_regex():
|
|
29
|
+
pattern = re.compile(r'[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b')
|
|
30
|
+
return pattern
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def keywords_regex():
|
|
34
|
+
return re.compile(r'\b(' + '|'.join(Pascal.keywords()) + r')\b', re.IGNORECASE)
|
|
35
|
+
|
|
36
|
+
@staticmethod
|
|
37
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
38
|
+
result = []
|
|
39
|
+
for match in Pascal.comment_regex().finditer(source_code):
|
|
40
|
+
if match.group('noncomment'):
|
|
41
|
+
result.append(match.group('noncomment'))
|
|
42
|
+
if isList:
|
|
43
|
+
return result
|
|
44
|
+
return ''.join(result)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def remove_keywords(source: str):
|
|
49
|
+
return re.sub(re.compile(Pascal.keywords_regex()), '', source)
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class Perl:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.perl
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = 'any|break|continue|default|delete|die|do|else|elsif|eval|for|foreach|given|goto|if|last|local|my|next|our|package|print|redo|require|say|state|sub|switch|undef|unless|until|use|when|while'.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>#.*?$|[{}]+)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^#\'"{}]*)', re.DOTALL | re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = re.compile(r'\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0b[01](?:_?[01])*|(?:\d(?:_?\d)*)?\.?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)\b', re.IGNORECASE)
|
|
26
|
+
return pattern
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def operator_regex():
|
|
30
|
+
pattern = re.compile(r'-[rwxoRWXOezsfdlpSbctugkTBMAC]\b|\+[+=]?|-[-=>]?|\*\*?=?|\/\/?=?|=[=~>]?|~[~=]?|\|\|?=?|&&?=?|<(?:=>?|<=?)?|>>?=?|![~=]?|[%^]=?|\.(?:=|\.\.?)?|[\\?]|\bx(?:=|\b)|\b(?:lt|gt|le|ge|eq|ne|cmp|not|and|or|xor)\b')
|
|
31
|
+
return pattern
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def keywords_regex():
|
|
35
|
+
return re.compile(r'\b(' + '|'.join(Perl.keywords()) + r')\b', re.IGNORECASE)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in Perl.comment_regex().finditer(source_code):
|
|
41
|
+
if match.group('noncomment'):
|
|
42
|
+
result.append(match.group('noncomment'))
|
|
43
|
+
if isList:
|
|
44
|
+
return result
|
|
45
|
+
return ''.join(result)
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def remove_keywords(source: str):
|
|
49
|
+
return re.sub(re.compile(Perl.keywords_regex()), '', source)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class PHP:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.php
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = 'and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|private|protected|parent|throw|null|echo|print|trait|namespace|final|yield|goto|instanceof|finally|try|catch'.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>#.*?$|//.*?$|[{}]+)|(?P<multilinecomment>/\*.*?\*/)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^#/\'"{}]*)', re.DOTALL | re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = re.compile(r'(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b', re.IGNORECASE)
|
|
26
|
+
return pattern
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def operator_regex():
|
|
30
|
+
pattern = re.compile(r'[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b')
|
|
31
|
+
return pattern
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def keywords_regex():
|
|
35
|
+
return re.compile(r'\b(' + '|'.join(PHP.keywords()) + r')\b', re.IGNORECASE)
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in PHP.comment_regex().finditer(source_code):
|
|
41
|
+
if match.group('noncomment'):
|
|
42
|
+
result.append(match.group('noncomment'))
|
|
43
|
+
if isList:
|
|
44
|
+
return result
|
|
45
|
+
return ''.join(result)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@staticmethod
|
|
49
|
+
def remove_keywords(source: str):
|
|
50
|
+
return re.sub(re.compile(PHP.keywords_regex()), '', source)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class Prolog:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.prolog
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = ''.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>%.*?$|/\*[\s\S]*?\*/|/\*.*?$|^.*?\*/)|(?P<noncomment>[^%\n/*]*[^\n]*)', re.MULTILINE | re.DOTALL)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'')
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r'')
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Prolog.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Prolog.comment_regex().finditer(source_code):
|
|
42
|
+
if match.group('noncomment'):
|
|
43
|
+
result.append(match.group('noncomment'))
|
|
44
|
+
if isList:
|
|
45
|
+
return result
|
|
46
|
+
return ''.join(result)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@staticmethod
|
|
50
|
+
def remove_keywords(source: str):
|
|
51
|
+
return re.sub(re.compile(Prolog.keywords_regex()), '', source)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class Python:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.python
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def keywords() -> list:
|
|
14
|
+
keyword = 'as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|nonlocal|pass|print|raise|return|try|while|with|yield|__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|case|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|match|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip|True|False|None'.split('|')
|
|
15
|
+
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
# return re.compile(r'(?P<comment>#.*?$)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^#\'"]*)', re.DOTALL | re.MULTILINE)
|
|
21
|
+
# pattern = re.compile(r'(?P<comment>#.*?$|"""[\s\S]*?"""|\'\'\'[\s\S]*?\'\'\')|(?P<noncomment>[^\n]*?(?=\n|$))', re.MULTILINE)
|
|
22
|
+
pattern = re.compile(r'(?P<comment>#.*?$)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|[^#\'"]+)',re.DOTALL | re.MULTILINE)
|
|
23
|
+
return pattern
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def number_regex():
|
|
27
|
+
pattern = re.compile(r'(?:\b(?=\d)|\B(?=\.))(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b', re.IGNORECASE)
|
|
28
|
+
return pattern
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def operator_regex():
|
|
32
|
+
pattern = re.compile(r'[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b')
|
|
33
|
+
return pattern
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def keywords_regex():
|
|
37
|
+
return re.compile(r'\b(' + '|'.join(Python.keywords()) + r')\b')
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
41
|
+
return Python.comment_regex().sub(lambda match: match.group('noncomment') if match.group('noncomment') else '', source_code).strip()
|
|
42
|
+
result = []
|
|
43
|
+
for match in Python.comment_regex().finditer(source_code):
|
|
44
|
+
if match.group('noncomment'):
|
|
45
|
+
result.append(match.group('noncomment'))
|
|
46
|
+
if isList:
|
|
47
|
+
return result
|
|
48
|
+
return ''.join(result)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@staticmethod
|
|
52
|
+
def remove_keywords(source: str):
|
|
53
|
+
return re.sub(re.compile(Python.keywords_regex()), '', source)
|
|
54
|
+
|
PyReprism/languages/q.py
ADDED
|
File without changes
|
|
File without changes
|
PyReprism/languages/r.py
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|