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,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Asciidoc:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.asciidoc
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = ''.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>//.*?$|////[\s\S]*?////|////.*?$|^.*?////)|(?P<noncomment>[^/]*[^\n]*)', re.DOTALL | re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = ''
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = ''
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Asciidoc.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Asciidoc.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(Asciidoc.keywords_regex()), '', source)
|
|
52
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Asm6502:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.asm6502
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = ''.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>;.*?$)|(?P<noncomment>[^;]*)', re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = ''
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = ''
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Asm6502.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Asm6502.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
|
+
@staticmethod
|
|
49
|
+
def remove_keywords(source: str):
|
|
50
|
+
return re.sub(re.compile(Asm6502.keywords_regex()), '', source)
|
|
51
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Aspnet:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.aspnet
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'Assembly|Control|Implements|Import|Master(?:Type)?|OutputCache|Page|PreviousPageType|Reference|Register'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*[\s\S]*?\*/|<!--[\s\S]*?-->|/\*.*?$|^.*?\*/|<!--.*?$|^.*?-->)|(?P<noncomment>[^/<!]*[^\n]*)', re.DOTALL | re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = ''
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = ''
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Aspnet.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Aspnet.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
|
+
@staticmethod
|
|
49
|
+
def remove_keywords(source: str):
|
|
50
|
+
return re.sub(re.compile(Aspnet.keywords_regex()), '', source)
|
|
51
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class AutoHotKey:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.autohotkey
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'Abort|AboveNormal|Add|ahk_class|ahk_group|ahk_id|ahk_pid|All|Alnum|Alpha|AltSubmit|AltTab|AltTabAndMenu|AltTabMenu|AltTabMenuDismiss|AlwaysOnTop|AutoSize|Background|BackgroundTrans|BelowNormal|between|BitAnd|BitNot|BitOr|BitShiftLeft|BitShiftRight|BitXOr|Bold|Border|Button|ByRef|Checkbox|Checked|CheckedGray|Choose|ChooseString|Close|Color|ComboBox|Contains|ControlList|Count|Date|DateTime|Days|DDL|Default|DeleteAll|Delimiter|Deref|Destroy|Digit|Disable|Disabled|DropDownList|Edit|Eject|Else|Enable|Enabled|Error|Exist|Expand|ExStyle|FileSystem|First|Flash|Float|FloatFast|Focus|Font|for|global|Grid|Group|GroupBox|GuiClose|GuiContextMenu|GuiDropFiles|GuiEscape|GuiSize|Hdr|Hidden|Hide|High|HKCC|HKCR|HKCU|HKEY_CLASSES_ROOT|HKEY_CURRENT_CONFIG|HKEY_CURRENT_USER|HKEY_LOCAL_MACHINE|HKEY_USERS|HKLM|HKU|Hours|HScroll|Icon|IconSmall|ID|IDLast|If|IfEqual|IfExist|IfGreater|IfGreaterOrEqual|IfInString|IfLess|IfLessOrEqual|IfMsgBox|IfNotEqual|IfNotExist|IfNotInString|IfWinActive|IfWinExist|IfWinNotActive|IfWinNotExist|Ignore|ImageList|in|Integer|IntegerFast|Interrupt|is|italic|Join|Label|LastFound|LastFoundExist|Limit|Lines|List|ListBox|ListView|local|Lock|Logoff|Low|Lower|Lowercase|MainWindow|Margin|Maximize|MaximizeBox|MaxSize|Minimize|MinimizeBox|MinMax|MinSize|Minutes|MonthCal|Mouse|Move|Multi|NA|No|NoActivate|NoDefault|NoHide|NoIcon|NoMainWindow|norm|Normal|NoSort|NoSortHdr|NoStandard|Not|NoTab|NoTimers|Number|Off|Ok|On|OwnDialogs|Owner|Parse|Password|Picture|Pixel|Pos|Pow|Priority|ProcessName|Radio|Range|Read|ReadOnly|Realtime|Redraw|REG_BINARY|REG_DWORD|REG_EXPAND_SZ|REG_MULTI_SZ|REG_SZ|Region|Relative|Rename|Report|Resize|Restore|Retry|RGB|Screen|Seconds|Section|Serial|SetLabel|ShiftAltTab|Show|Single|Slider|SortDesc|Standard|static|Status|StatusBar|StatusCD|strike|Style|Submit|SysMenu|Tab2|TabStop|Text|Theme|Tile|ToggleCheck|ToggleEnable|ToolWindow|Top|Topmost|TransColor|Transparent|Tray|TreeView|TryAgain|Type|UnCheck|underline|Unicode|Unlock|UpDown|Upper|Uppercase|UseErrorLevel|Vis|VisFirst|Visible|VScroll|Wait|WaitClose|WantCtrlA|WantF2|WantReturn|While|Wrap|Xdigit|xm|xp|xs|Yes|ym|yp|ys|abs|acos|asc|asin|atan|ceil|chr|class|cos|dllcall|exp|fileexist|Fileopen|floor|il_add|il_create|il_destroy|instr|substr|isfunc|islabel|IsObject|ln|log|lv_add|lv_delete|lv_deletecol|lv_getcount|lv_getnext|lv_gettext|lv_insert|lv_insertcol|lv_modify|lv_modifycol|lv_setimagelist|mod|onmessage|numget|numput|registercallback|regexmatch|regexreplace|round|sin|tan|sqrt|strlen|sb_seticon|sb_setparts|sb_settext|strsplit|tv_add|tv_delete|tv_getchild|tv_getcount|tv_getnext|tv_get|tv_getparent|tv_getprev|tv_getselection|tv_gettext|tv_modify|varsetcapacity|winactive|winexist|__New|__Call|__Get|__Set'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>;.*?$)|(?P<noncomment>[^;]*)', re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?')
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r'\?|\/\/?=?|:=|\|[=|]?|&[=&]?|\+[=+]?|-[=-]?|\*[=*]?|<(?:<=?|>|=)?|>>?=?|[.^!=~]=?|\b(?:AND|NOT|OR)\b')
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(AutoHotKey.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in AutoHotKey.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
|
+
@staticmethod
|
|
49
|
+
def remove_keywords(source: str):
|
|
50
|
+
return re.sub(re.compile(AutoHotKey.keywords_regex()), '', source)
|
|
51
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Autoit:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.autoit
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'Case|Const|Continue(?:Case|Loop)|Default|Dim|Do|Else(?:If)?|End(?:Func|If|Select|Switch|With)|Enum|Exit(?:Loop)?|For|Func|Global|If|In|Local|Next|Null|ReDim|Select|Static|Step|Switch|Then|To|Until|Volatile|WEnd|While|With|True|False'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>;.*?$|#cs[\s\S]*?#ce|#cs.*?$|^.*?#ce)|(?P<noncomment>[^;#]*[^\n]*)',re.DOTALL | re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'\b(?:0x[\da-f]+|\d+(?:\.\d+)?(?:e[+-]?\d+)?)\b')
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r'<[=>]?|[-+*\/=&>]=?|[?^]|\b(?:And|Or|Not)\b')
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Autoit.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Autoit.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
|
+
@staticmethod
|
|
49
|
+
def remove_keywords(source: str):
|
|
50
|
+
return re.sub(re.compile(Autoit.keywords_regex()), '', source)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
class Bash:
|
|
5
|
+
def __init__():
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
@staticmethod
|
|
9
|
+
def file_extension() -> str:
|
|
10
|
+
return extension.bash
|
|
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>#.*?$)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^#\'"]*)', re.DOTALL | re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'\b0x[\dA-Fa-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee]-?\d+)?')
|
|
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(Bash.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Bash.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(Bash.keywords_regex()), '', source)
|
|
52
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Basic:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.basic
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'AS|BEEP|BLOAD|BSAVE|CALL(?: ABSOLUTE)?|CASE|CHAIN|CHDIR|CLEAR|CLOSE|CLS|COM|COMMON|CONST|DATA|DECLARE|DEF(?: FN| SEG|DBL|INT|LNG|SNG|STR)|DIM|DO|DOUBLE|ELSE|ELSEIF|END|ENVIRON|ERASE|ERROR|EXIT|FIELD|FILES|FOR|FUNCTION|GET|GOSUB|GOTO|IF|INPUT|INTEGER|IOCTL|KEY|KILL|LINE INPUT|LOCATE|LOCK|LONG|LOOP|LSET|MKDIR|NAME|NEXT|OFF|ON(?: COM| ERROR| KEY| TIMER)?|OPEN|OPTION BASE|OUT|POKE|PUT|READ|REDIM|REM|RESTORE|RESUME|RETURN|RMDIR|RSET|RUN|SHARED|SINGLE|SELECT CASE|SHELL|SLEEP|STATIC|STEP|STOP|STRING|SUB|SWAP|SYSTEM|THEN|TIMER|TO|TROFF|TRON|TYPE|UNLOCK|UNTIL|USING|VIEW PRINT|WAIT|WEND|WHILE|WRITE|ABS|ACCESS|ACOS|ANGLE|AREA|ARITHMETIC|ARRAY|ASIN|ASK|AT|ATN|BASE|BEGIN|BREAK|CAUSE|CEIL|CHR|CLIP|COLLATE|COLOR|CON|COS|COSH|COT|CSC|DATE|DATUM|DEBUG|DECIMAL|DEF|DEG|DEGREES|DELETE|DET|DEVICE|DISPLAY|DOT|ELAPSED|EPS|ERASABLE|EXLINE|EXP|EXTERNAL|EXTYPE|FILETYPE|FIXED|FP|GO|GRAPH|HANDLER|IDN|IMAGE|IN|INT|INTERNAL|IP|IS|KEYED|LBOUND|LCASE|LEFT|LEN|LENGTH|LET|LINE|LINES|LOG|LOG10|LOG2|LTRIM|MARGIN|MAT|MAX|MAXNUM|MID|MIN|MISSING|MOD|NATIVE|NUL|NUMERIC|OF|OPTION|ORD|ORGANIZATION|OUTIN|OUTPUT|PI|POINT|POINTER|POINTS|POS|PRINT|PROGRAM|PROMPT|RAD|RADIANS|RANDOMIZE|RECORD|RECSIZE|RECTYPE|RELATIVE|REMAINDER|REPEAT|REST|RETRY|REWRITE|RIGHT|RND|ROUND|RTRIM|SAME|SEC|SELECT|SEQUENTIAL|SET|SETTER|SGN|SIN|SINH|SIZE|SKIP|SQR|STANDARD|STATUS|STR|STREAM|STYLE|TAB|TAN|TANH|TEMPLATE|TEXT|THERE|TIME|TIMEOUT|TRACE|TRANSFORM|TRUNCATE|UBOUND|UCASE|USE|VAL|VARIABLE|VIEWPORT|WHEN|WINDOW|WITH|ZER|ZONEWIDTH'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>REM.*?$|\'.*?$)|(?P<noncomment>[^\'R]*[^\n]*)',re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'(?:\b\d+\.?\d*|\B\.\d+)(?:E[+-]?\d+)?')
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r'<[=>]?|>=?|[+\-*\/^=&]|\b(?:AND|EQV|IMP|NOT|OR|XOR)\b')
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Basic.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Basic.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(Basic.keywords_regex()), '', source)
|
|
52
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Batch:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.batch
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'not|cmdextversion|defined|errorlevel|exist|echo|set'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>REM.*?$|::.*?$)|(?P<noncomment>[^:R]*[^\n]*)', re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = ''
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = re.compile(r'\^|==|\b(?:equ|neq|lss|leq|gtr|geq)\b|([*\/%+\-&^|]=?|<<=?|>>=?|[!~_=])')
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Batch.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Batch.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(Batch.keywords_regex()), '', source)
|
|
52
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Bison:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.bison
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = '%\w+'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*[\s\S]*?\*/|/\*.*?$|^.*?\*/)|(?P<noncomment>[^/]*[^\n]*)',re.DOTALL | re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = re.compile(r'(^|[^@])\b(?:0x[\da-f]+|\d+)')
|
|
27
|
+
return pattern
|
|
28
|
+
|
|
29
|
+
@staticmethod
|
|
30
|
+
def operator_regex():
|
|
31
|
+
pattern = ''
|
|
32
|
+
return pattern
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def keywords_regex():
|
|
36
|
+
return re.compile(r'\b(' + '|'.join(Bison.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in Bison.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(Bison.keywords_regex()), '', source)
|
|
52
|
+
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class BrainFuck:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.brainfuck
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = '\S+'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>[^><+\-.,[\]]+)|(?P<noncomment>[><+\-.,[\]])')
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
@staticmethod
|
|
25
|
+
def number_regex():
|
|
26
|
+
pattern = ''
|
|
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(BrainFuck.keywords()) + r')\b')
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
40
|
+
result = []
|
|
41
|
+
for match in BrainFuck.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(BrainFuck.keywords_regex()), '', source)
|
|
52
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Bro:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.bro
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'break|next|continue|alarm|using|of|add|delete|export|print|return|schedule|when|timeout|addr|any|bool|count|double|enum|file|int|interval|pattern|opaque|port|record|set|string|subnet|table|time|vector|for|if|else|in|module|function|load(?:-(?:sigs|plugin))?|unload|prefixes|ifn?def|else|(?:end)?if|DIR|FILENAME))|(?:&?(?:redef|priority|log|optional|default|add_func|delete_func|expire_func|read_expire|write_expire|create_expire|synchronized|persistent|rotate_interval|rotate_size|encrypt|raw_output|mergeable|group|error_handler|type_column'.split('|')
|
|
16
|
+
return keyword
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def comment_regex():
|
|
20
|
+
pattern = re.compile(r'(?P<comment>#.*?$)|(?P<noncomment>[^#]*)',re.MULTILINE)
|
|
21
|
+
return pattern
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def number_regex():
|
|
25
|
+
pattern = re.compile(r'\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?')
|
|
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(Bro.keywords()) + r')\b')
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
39
|
+
result = []
|
|
40
|
+
for match in Bro.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(Bro.keywords_regex()), '', source)
|
|
50
|
+
|
PyReprism/languages/c.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class C:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.c
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = '_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|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|define|defined|elif|else|endif|error|ifdef|ifndef|if|import|include|line|pragma|undef|using|__FILE__|__LINE__|__DATE__|__TIME__|__TIMESTAMP__|__func__|EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|stdin|stdout|stderr'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*.*?\*/|/\*.*?$|^.*?\*/|[{}]+)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^/\'"{}]*)', re.DOTALL | re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def number_regex():
|
|
27
|
+
pattern = re.compile(r'(?:\b0x[\da-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?)[ful]*')
|
|
28
|
+
return pattern
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def operator_regex():
|
|
32
|
+
pattern = re.compile(r'-[>-]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/]')
|
|
33
|
+
return pattern
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def keywords_regex():
|
|
37
|
+
return re.compile(r'\b(' + '|'.join(C.keywords()) + r')\b')
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
41
|
+
result = []
|
|
42
|
+
for match in C.comment_regex().finditer(source_code):
|
|
43
|
+
if match.group('noncomment'):
|
|
44
|
+
result.append(match.group('noncomment'))
|
|
45
|
+
if isList:
|
|
46
|
+
return result
|
|
47
|
+
return ''.join(result)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def remove_keywords(source: str):
|
|
52
|
+
return re.sub(re.compile(C.keywords_regex()), '', source)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from PyReprism.utils import extension
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Clike:
|
|
6
|
+
def __init__():
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
@staticmethod
|
|
10
|
+
def file_extension() -> str:
|
|
11
|
+
return extension.clike
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def keywords() -> list:
|
|
15
|
+
keyword = 'if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue|true|false|class|interface|extends|implements|trait|instanceof|new'.split('|')
|
|
16
|
+
|
|
17
|
+
return keyword
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def comment_regex():
|
|
21
|
+
pattern = re.compile(r'(?P<comment>//.*?$|/\*.*?\*/|/\*.*?$|^.*?\*/|[{}]+)|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^/\'"{}]*)', re.DOTALL | re.MULTILINE)
|
|
22
|
+
return pattern
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def number_regex():
|
|
27
|
+
pattern = re.compile(r'\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?')
|
|
28
|
+
return pattern
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def operator_regex():
|
|
32
|
+
pattern = re.compile(r'--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%')
|
|
33
|
+
return pattern
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def keywords_regex():
|
|
37
|
+
return re.compile(r'\b(' + '|'.join(Clike.keywords()) + r')\b')
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def remove_comments(source_code: str, isList: bool = False) -> str:
|
|
41
|
+
result = []
|
|
42
|
+
for match in Clike.comment_regex().finditer(source_code):
|
|
43
|
+
if match.group('noncomment'):
|
|
44
|
+
result.append(match.group('noncomment'))
|
|
45
|
+
if isList:
|
|
46
|
+
return result
|
|
47
|
+
return ''.join(result)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@staticmethod
|
|
51
|
+
def remove_keywords(source: str):
|
|
52
|
+
return re.sub(re.compile(Clike.keywords_regex()), '', source)
|