PyReprism 0.0.1__tar.gz

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.
Files changed (159) hide show
  1. pyreprism-0.0.1/.flake8 +6 -0
  2. pyreprism-0.0.1/.gitignore +166 -0
  3. pyreprism-0.0.1/.readthedocs.yaml +0 -0
  4. pyreprism-0.0.1/LICENSE +21 -0
  5. pyreprism-0.0.1/PKG-INFO +94 -0
  6. pyreprism-0.0.1/README.md +47 -0
  7. pyreprism-0.0.1/pyproject.toml +48 -0
  8. pyreprism-0.0.1/pytest.ini +4 -0
  9. pyreprism-0.0.1/requirements.txt +3 -0
  10. pyreprism-0.0.1/src/PyReprism/__init__.py +0 -0
  11. pyreprism-0.0.1/src/PyReprism/languages/__init__.py +147 -0
  12. pyreprism-0.0.1/src/PyReprism/languages/_base.py +30 -0
  13. pyreprism-0.0.1/src/PyReprism/languages/abap.py +52 -0
  14. pyreprism-0.0.1/src/PyReprism/languages/actionscript.py +52 -0
  15. pyreprism-0.0.1/src/PyReprism/languages/ada.py +53 -0
  16. pyreprism-0.0.1/src/PyReprism/languages/apacheconf.py +52 -0
  17. pyreprism-0.0.1/src/PyReprism/languages/apl.py +52 -0
  18. pyreprism-0.0.1/src/PyReprism/languages/applescript.py +52 -0
  19. pyreprism-0.0.1/src/PyReprism/languages/arduino.py +52 -0
  20. pyreprism-0.0.1/src/PyReprism/languages/arff.py +52 -0
  21. pyreprism-0.0.1/src/PyReprism/languages/asciidoc.py +52 -0
  22. pyreprism-0.0.1/src/PyReprism/languages/asm6502.py +51 -0
  23. pyreprism-0.0.1/src/PyReprism/languages/aspnet.py +51 -0
  24. pyreprism-0.0.1/src/PyReprism/languages/autohotkey.py +51 -0
  25. pyreprism-0.0.1/src/PyReprism/languages/autoit.py +50 -0
  26. pyreprism-0.0.1/src/PyReprism/languages/bash.py +52 -0
  27. pyreprism-0.0.1/src/PyReprism/languages/basic.py +52 -0
  28. pyreprism-0.0.1/src/PyReprism/languages/batch.py +52 -0
  29. pyreprism-0.0.1/src/PyReprism/languages/bison.py +52 -0
  30. pyreprism-0.0.1/src/PyReprism/languages/brainfuck.py +52 -0
  31. pyreprism-0.0.1/src/PyReprism/languages/bro.py +50 -0
  32. pyreprism-0.0.1/src/PyReprism/languages/c.py +52 -0
  33. pyreprism-0.0.1/src/PyReprism/languages/clike.py +52 -0
  34. pyreprism-0.0.1/src/PyReprism/languages/clojure.py +50 -0
  35. pyreprism-0.0.1/src/PyReprism/languages/coffeescript.py +50 -0
  36. pyreprism-0.0.1/src/PyReprism/languages/cpp.py +52 -0
  37. pyreprism-0.0.1/src/PyReprism/languages/crystal.py +50 -0
  38. pyreprism-0.0.1/src/PyReprism/languages/csharp.py +53 -0
  39. pyreprism-0.0.1/src/PyReprism/languages/csp.py +50 -0
  40. pyreprism-0.0.1/src/PyReprism/languages/css.py +50 -0
  41. pyreprism-0.0.1/src/PyReprism/languages/css_extras.py +50 -0
  42. pyreprism-0.0.1/src/PyReprism/languages/d.py +50 -0
  43. pyreprism-0.0.1/src/PyReprism/languages/dart.py +52 -0
  44. pyreprism-0.0.1/src/PyReprism/languages/diff.py +49 -0
  45. pyreprism-0.0.1/src/PyReprism/languages/django.py +55 -0
  46. pyreprism-0.0.1/src/PyReprism/languages/docker.py +50 -0
  47. pyreprism-0.0.1/src/PyReprism/languages/eiffel.py +49 -0
  48. pyreprism-0.0.1/src/PyReprism/languages/elixir.py +50 -0
  49. pyreprism-0.0.1/src/PyReprism/languages/erb.py +0 -0
  50. pyreprism-0.0.1/src/PyReprism/languages/erlang.py +50 -0
  51. pyreprism-0.0.1/src/PyReprism/languages/flow.py +0 -0
  52. pyreprism-0.0.1/src/PyReprism/languages/fortran.py +49 -0
  53. pyreprism-0.0.1/src/PyReprism/languages/fsharp.py +49 -0
  54. pyreprism-0.0.1/src/PyReprism/languages/gedcom.py +0 -0
  55. pyreprism-0.0.1/src/PyReprism/languages/gherkin.py +0 -0
  56. pyreprism-0.0.1/src/PyReprism/languages/git.py +0 -0
  57. pyreprism-0.0.1/src/PyReprism/languages/glsl.py +0 -0
  58. pyreprism-0.0.1/src/PyReprism/languages/go.py +53 -0
  59. pyreprism-0.0.1/src/PyReprism/languages/graphql.py +50 -0
  60. pyreprism-0.0.1/src/PyReprism/languages/groovy.py +53 -0
  61. pyreprism-0.0.1/src/PyReprism/languages/haml.py +50 -0
  62. pyreprism-0.0.1/src/PyReprism/languages/handlebars.py +0 -0
  63. pyreprism-0.0.1/src/PyReprism/languages/haskell.py +53 -0
  64. pyreprism-0.0.1/src/PyReprism/languages/haxe.py +0 -0
  65. pyreprism-0.0.1/src/PyReprism/languages/hpkp.py +0 -0
  66. pyreprism-0.0.1/src/PyReprism/languages/hsts.py +0 -0
  67. pyreprism-0.0.1/src/PyReprism/languages/html.py +50 -0
  68. pyreprism-0.0.1/src/PyReprism/languages/ichigojam.py +0 -0
  69. pyreprism-0.0.1/src/PyReprism/languages/icon.py +0 -0
  70. pyreprism-0.0.1/src/PyReprism/languages/inform7.py +0 -0
  71. pyreprism-0.0.1/src/PyReprism/languages/ini.py +41 -0
  72. pyreprism-0.0.1/src/PyReprism/languages/io.py +0 -0
  73. pyreprism-0.0.1/src/PyReprism/languages/j.py +50 -0
  74. pyreprism-0.0.1/src/PyReprism/languages/java.py +53 -0
  75. pyreprism-0.0.1/src/PyReprism/languages/javascript.py +53 -0
  76. pyreprism-0.0.1/src/PyReprism/languages/jolie.py +50 -0
  77. pyreprism-0.0.1/src/PyReprism/languages/json.py +50 -0
  78. pyreprism-0.0.1/src/PyReprism/languages/jsx.py +53 -0
  79. pyreprism-0.0.1/src/PyReprism/languages/julia.py +53 -0
  80. pyreprism-0.0.1/src/PyReprism/languages/keyman.py +0 -0
  81. pyreprism-0.0.1/src/PyReprism/languages/kotlin.py +53 -0
  82. pyreprism-0.0.1/src/PyReprism/languages/latex.py +50 -0
  83. pyreprism-0.0.1/src/PyReprism/languages/less.py +50 -0
  84. pyreprism-0.0.1/src/PyReprism/languages/liquid.py +49 -0
  85. pyreprism-0.0.1/src/PyReprism/languages/livescript.py +49 -0
  86. pyreprism-0.0.1/src/PyReprism/languages/lolcode.py +0 -0
  87. pyreprism-0.0.1/src/PyReprism/languages/lua.py +0 -0
  88. pyreprism-0.0.1/src/PyReprism/languages/makefile.py +50 -0
  89. pyreprism-0.0.1/src/PyReprism/languages/markdown.py +31 -0
  90. pyreprism-0.0.1/src/PyReprism/languages/markup.py +50 -0
  91. pyreprism-0.0.1/src/PyReprism/languages/markup_templating.py +0 -0
  92. pyreprism-0.0.1/src/PyReprism/languages/matlab.py +51 -0
  93. pyreprism-0.0.1/src/PyReprism/languages/mel.py +0 -0
  94. pyreprism-0.0.1/src/PyReprism/languages/mizar.py +0 -0
  95. pyreprism-0.0.1/src/PyReprism/languages/monkey.py +0 -0
  96. pyreprism-0.0.1/src/PyReprism/languages/n4js.py +50 -0
  97. pyreprism-0.0.1/src/PyReprism/languages/nasm.py +0 -0
  98. pyreprism-0.0.1/src/PyReprism/languages/nginx.py +50 -0
  99. pyreprism-0.0.1/src/PyReprism/languages/nim.py +0 -0
  100. pyreprism-0.0.1/src/PyReprism/languages/nix.py +0 -0
  101. pyreprism-0.0.1/src/PyReprism/languages/nsis.py +0 -0
  102. pyreprism-0.0.1/src/PyReprism/languages/objectivec.py +49 -0
  103. pyreprism-0.0.1/src/PyReprism/languages/ocaml.py +51 -0
  104. pyreprism-0.0.1/src/PyReprism/languages/opencl.py +0 -0
  105. pyreprism-0.0.1/src/PyReprism/languages/oz.py +0 -0
  106. pyreprism-0.0.1/src/PyReprism/languages/parigp.py +0 -0
  107. pyreprism-0.0.1/src/PyReprism/languages/parser.py +0 -0
  108. pyreprism-0.0.1/src/PyReprism/languages/pascal.py +49 -0
  109. pyreprism-0.0.1/src/PyReprism/languages/perl.py +53 -0
  110. pyreprism-0.0.1/src/PyReprism/languages/php.py +50 -0
  111. pyreprism-0.0.1/src/PyReprism/languages/php_extras.py +0 -0
  112. pyreprism-0.0.1/src/PyReprism/languages/plsql.py +0 -0
  113. pyreprism-0.0.1/src/PyReprism/languages/powershell.py +0 -0
  114. pyreprism-0.0.1/src/PyReprism/languages/processing.py +0 -0
  115. pyreprism-0.0.1/src/PyReprism/languages/prolog.py +51 -0
  116. pyreprism-0.0.1/src/PyReprism/languages/properties.py +0 -0
  117. pyreprism-0.0.1/src/PyReprism/languages/protobuf.py +0 -0
  118. pyreprism-0.0.1/src/PyReprism/languages/pug.py +0 -0
  119. pyreprism-0.0.1/src/PyReprism/languages/puppet.py +0 -0
  120. pyreprism-0.0.1/src/PyReprism/languages/pure.py +0 -0
  121. pyreprism-0.0.1/src/PyReprism/languages/python.py +54 -0
  122. pyreprism-0.0.1/src/PyReprism/languages/q.py +0 -0
  123. pyreprism-0.0.1/src/PyReprism/languages/qore.py +0 -0
  124. pyreprism-0.0.1/src/PyReprism/languages/r.py +0 -0
  125. pyreprism-0.0.1/src/PyReprism/languages/reason.py +0 -0
  126. pyreprism-0.0.1/src/PyReprism/languages/renpy.py +0 -0
  127. pyreprism-0.0.1/src/PyReprism/languages/rest.py +0 -0
  128. pyreprism-0.0.1/src/PyReprism/languages/rip.py +0 -0
  129. pyreprism-0.0.1/src/PyReprism/languages/roboconf.py +0 -0
  130. pyreprism-0.0.1/src/PyReprism/languages/ruby.py +50 -0
  131. pyreprism-0.0.1/src/PyReprism/languages/rust.py +52 -0
  132. pyreprism-0.0.1/src/PyReprism/languages/sas.py +0 -0
  133. pyreprism-0.0.1/src/PyReprism/languages/sass.py +0 -0
  134. pyreprism-0.0.1/src/PyReprism/languages/scala.py +53 -0
  135. pyreprism-0.0.1/src/PyReprism/languages/scheme.py +51 -0
  136. pyreprism-0.0.1/src/PyReprism/languages/scss.py +50 -0
  137. pyreprism-0.0.1/src/PyReprism/languages/smalltalk.py +51 -0
  138. pyreprism-0.0.1/src/PyReprism/languages/smarty.py +0 -0
  139. pyreprism-0.0.1/src/PyReprism/languages/soy.py +0 -0
  140. pyreprism-0.0.1/src/PyReprism/languages/stylus.py +52 -0
  141. pyreprism-0.0.1/src/PyReprism/languages/swift.py +52 -0
  142. pyreprism-0.0.1/src/PyReprism/languages/tcl.py +0 -0
  143. pyreprism-0.0.1/src/PyReprism/languages/textile.py +0 -0
  144. pyreprism-0.0.1/src/PyReprism/languages/tsx.py +52 -0
  145. pyreprism-0.0.1/src/PyReprism/languages/twig.py +0 -0
  146. pyreprism-0.0.1/src/PyReprism/languages/typescript.py +52 -0
  147. pyreprism-0.0.1/src/PyReprism/languages/vbnet.py +51 -0
  148. pyreprism-0.0.1/src/PyReprism/languages/velocity.py +52 -0
  149. pyreprism-0.0.1/src/PyReprism/languages/verilog.py +0 -0
  150. pyreprism-0.0.1/src/PyReprism/languages/vhdl.py +0 -0
  151. pyreprism-0.0.1/src/PyReprism/languages/vim.py +52 -0
  152. pyreprism-0.0.1/src/PyReprism/languages/visual_basic.py +52 -0
  153. pyreprism-0.0.1/src/PyReprism/languages/wasam.py +0 -0
  154. pyreprism-0.0.1/src/PyReprism/languages/xeora.py +0 -0
  155. pyreprism-0.0.1/src/PyReprism/languages/xojo.py +0 -0
  156. pyreprism-0.0.1/src/PyReprism/languages/yaml.py +53 -0
  157. pyreprism-0.0.1/src/PyReprism/utils/__init__.py +0 -0
  158. pyreprism-0.0.1/src/PyReprism/utils/extension.py +149 -0
  159. pyreprism-0.0.1/src/PyReprism/utils/normalizer.py +18 -0
@@ -0,0 +1,6 @@
1
+ [flake8]
2
+ show-source = True
3
+ count = True
4
+ statistics = True
5
+ max-line-length = 150
6
+ exclude = .github,venv,build,dist,docs,test-repos,.venv,tmp.py
@@ -0,0 +1,166 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ .pypirc
6
+
7
+ # C extensions
8
+ *.so
9
+
10
+ # Distribution / packaging
11
+ .Python
12
+ build/
13
+ develop-eggs/
14
+ dist/
15
+ downloads/
16
+ eggs/
17
+ .eggs/
18
+ lib/
19
+ lib64/
20
+ parts/
21
+ sdist/
22
+ var/
23
+ wheels/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+ cover/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+ local_settings.py
62
+ db.sqlite3
63
+ db.sqlite3-journal
64
+
65
+ # Flask stuff:
66
+ instance/
67
+ .webassets-cache
68
+
69
+ # Scrapy stuff:
70
+ .scrapy
71
+
72
+ # Sphinx documentation
73
+ docs/_build/
74
+
75
+ # PyBuilder
76
+ .pybuilder/
77
+ target/
78
+
79
+ # Jupyter Notebook
80
+ .ipynb_checkpoints
81
+
82
+ # IPython
83
+ profile_default/
84
+ ipython_config.py
85
+
86
+ # pyenv
87
+ # For a library or package, you might want to ignore these files since the code is
88
+ # intended to run in multiple environments; otherwise, check them in:
89
+ # .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # poetry
99
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
100
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
101
+ # commonly ignored for libraries.
102
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
103
+ #poetry.lock
104
+
105
+ # pdm
106
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
107
+ #pdm.lock
108
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
+ # in version control.
110
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
+ .pdm.toml
112
+ .pdm-python
113
+ .pdm-build/
114
+
115
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116
+ __pypackages__/
117
+
118
+ # Celery stuff
119
+ celerybeat-schedule
120
+ celerybeat.pid
121
+
122
+ # SageMath parsed files
123
+ *.sage.py
124
+
125
+ # Environments
126
+ .env
127
+ .venv
128
+ env/
129
+ venv/
130
+ ENV/
131
+ env.bak/
132
+ venv.bak/
133
+
134
+ # Spyder project settings
135
+ .spyderproject
136
+ .spyproject
137
+
138
+ # Rope project settings
139
+ .ropeproject
140
+
141
+ # mkdocs documentation
142
+ /site
143
+
144
+ # mypy
145
+ .mypy_cache/
146
+ .dmypy.json
147
+ dmypy.json
148
+
149
+ # Pyre type checker
150
+ .pyre/
151
+
152
+ # pytype static type analyzer
153
+ .pytype/
154
+
155
+ # Cython debug symbols
156
+ cython_debug/
157
+
158
+ # PyCharm
159
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
161
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
162
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
163
+ #.idea/
164
+
165
+ # others
166
+ __test__.py
File without changes
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 UNLV EVOL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.3
2
+ Name: PyReprism
3
+ Version: 0.0.1
4
+ Summary: Framework for Source Code Preprocessing
5
+ Project-URL: Homepage, https://github.com/unlv-evol/PyReprism
6
+ Project-URL: Issues, https://github.com/unlv-evol/PyReprism/issues
7
+ Author-email: UNLV EVOL LAB <ogenrwot@unlv.nevada.edu>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2024 UNLV EVOL
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ License-File: LICENSE
30
+ Classifier: Development Status :: 4 - Beta
31
+ Classifier: Environment :: Console
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Operating System :: OS Independent
36
+ Classifier: Programming Language :: Python :: 3.6
37
+ Classifier: Programming Language :: Python :: 3.7
38
+ Classifier: Programming Language :: Python :: 3.8
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Requires-Python: >=3.6
42
+ Provides-Extra: dev
43
+ Requires-Dist: flake8; extra == 'dev'
44
+ Requires-Dist: pytest; extra == 'dev'
45
+ Requires-Dist: pytest-cov; extra == 'dev'
46
+ Description-Content-Type: text/markdown
47
+
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
49
+
50
+ # PyReprism
51
+
52
+ PyReprism is a suite of essential methods designed for common preprocessing tasks in code clone detection research.
53
+
54
+ ## Install
55
+ ```shell
56
+ pip install PyReprism
57
+ ```
58
+ ## Quick Usage
59
+ ```python
60
+
61
+ from PyReprism.languages import Python
62
+
63
+ source = """
64
+ # single line comment
65
+ x = 5 + 6
66
+ '''
67
+ multiline
68
+ comment
69
+ '''
70
+ print(x)
71
+ """
72
+
73
+ source =''.join(Python.remove_comments(source))
74
+ ```
75
+ Read the [docs]() for more usage examples.
76
+
77
+ ## How to Contribute
78
+
79
+ ```shell
80
+ git clone https://github.com/unlv-evol/PyReprism.git
81
+ cd PyReprism
82
+ ```
83
+ **(Optional)** It is suggested to make use of virtualenv. Therefore, before installing the requirements run:
84
+
85
+ ```
86
+ python3 -m venv venv
87
+ source venv/bin/activate
88
+ ```
89
+
90
+ Then, install the requirements:
91
+
92
+ ```
93
+ pip install -r requirements.txt
94
+ ```
@@ -0,0 +1,47 @@
1
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
2
+
3
+ # PyReprism
4
+
5
+ PyReprism is a suite of essential methods designed for common preprocessing tasks in code clone detection research.
6
+
7
+ ## Install
8
+ ```shell
9
+ pip install PyReprism
10
+ ```
11
+ ## Quick Usage
12
+ ```python
13
+
14
+ from PyReprism.languages import Python
15
+
16
+ source = """
17
+ # single line comment
18
+ x = 5 + 6
19
+ '''
20
+ multiline
21
+ comment
22
+ '''
23
+ print(x)
24
+ """
25
+
26
+ source =''.join(Python.remove_comments(source))
27
+ ```
28
+ Read the [docs]() for more usage examples.
29
+
30
+ ## How to Contribute
31
+
32
+ ```shell
33
+ git clone https://github.com/unlv-evol/PyReprism.git
34
+ cd PyReprism
35
+ ```
36
+ **(Optional)** It is suggested to make use of virtualenv. Therefore, before installing the requirements run:
37
+
38
+ ```
39
+ python3 -m venv venv
40
+ source venv/bin/activate
41
+ ```
42
+
43
+ Then, install the requirements:
44
+
45
+ ```
46
+ pip install -r requirements.txt
47
+ ```
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "PyReprism"
7
+ version = "0.0.1"
8
+ authors = [
9
+ { name= "UNLV EVOL LAB", email="ogenrwot@unlv.nevada.edu" },
10
+ ]
11
+ license={file="LICENSE" }
12
+ python_requires = ">=3.5"
13
+ description = "Framework for Source Code Preprocessing"
14
+ readme = "README.md"
15
+ requires-python = ">=3.6"
16
+ classifiers = [
17
+ "Environment :: Console",
18
+ "Development Status :: 4 - Beta",
19
+ "Intended Audience :: Developers",
20
+ "Intended Audience :: Science/Research",
21
+ "Programming Language :: Python :: 3.6",
22
+ "Programming Language :: Python :: 3.7",
23
+ "Programming Language :: Python :: 3.8",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Programming Language :: Python :: 3.10",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Operating System :: OS Independent",
28
+ ]
29
+
30
+ [tool.hatch.build.targets.wheel]
31
+ packages = ["src/PyReprism"]
32
+
33
+ [tool.hatch.build]
34
+ exclude = [
35
+ "docs",
36
+ "tests",
37
+ "venv"
38
+ ]
39
+ [project.optional-dependencies]
40
+ dev = [
41
+ "flake8",
42
+ "pytest",
43
+ "pytest-cov",
44
+ ]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/unlv-evol/PyReprism"
48
+ Issues = "https://github.com/unlv-evol/PyReprism/issues"
@@ -0,0 +1,4 @@
1
+ [pytest]
2
+ testpaths = src/tests
3
+ addopts = --cov=src/PyReprism --cov-report=html --cov-report=term
4
+ ; --cov-fail-under=80
@@ -0,0 +1,3 @@
1
+ pytest
2
+ flake8
3
+ pytest-cov
File without changes
@@ -0,0 +1,147 @@
1
+ from .python import *
2
+ from .java import *
3
+ from .c import *
4
+ from .csharp import *
5
+ from .bash import *
6
+ from .markup import *
7
+ from .perl import *
8
+ from .php import *
9
+ from .ruby import *
10
+ from .rust import *
11
+ from .abap import *
12
+ from .actionscript import *
13
+ from .ada import *
14
+ from .apacheconf import *
15
+ from .apl import *
16
+ from .applescript import *
17
+ from .arduino import *
18
+ from .arff import *
19
+ from .asciidoc import *
20
+ from .asm6502 import *
21
+ from .aspnet import *
22
+ from .autohotkey import *
23
+ from .autoit import *
24
+ from .bash import *
25
+ from .basic import *
26
+ from .batch import *
27
+ from .bison import *
28
+ from .brainfuck import *
29
+ from .bro import *
30
+ from .clike import *
31
+ from .clojure import *
32
+ from .coffeescript import *
33
+ from .cpp import *
34
+ from .crystal import *
35
+ from .csp import *
36
+ from .css_extras import *
37
+ from .css import *
38
+ from .d import *
39
+ from .dart import *
40
+ from .diff import *
41
+ from .django import *
42
+ from .docker import *
43
+ from .eiffel import *
44
+ from .elixir import *
45
+ from .erb import *
46
+ from .erlang import *
47
+ from .flow import *
48
+ from .fortran import *
49
+ from .fsharp import *
50
+ from .gedcom import *
51
+ from .gherkin import *
52
+ from .git import *
53
+ from .glsl import *
54
+ from .go import *
55
+ from .graphql import *
56
+ from .groovy import *
57
+ from .haml import *
58
+ from .handlebars import *
59
+ from .haskell import *
60
+ from .haxe import *
61
+ from .hpkp import *
62
+ from .hsts import *
63
+ from .ichigojam import *
64
+ from .icon import *
65
+ from .inform7 import *
66
+ from .ini import *
67
+ from .io import *
68
+ from .j import *
69
+ from .javascript import *
70
+ from .jolie import *
71
+ from .json import *
72
+ from .jsx import *
73
+ from .julia import *
74
+ from .keyman import *
75
+ from .kotlin import *
76
+ from .latex import *
77
+ from .less import *
78
+ from .liquid import *
79
+ from .livescript import *
80
+ from .lolcode import *
81
+ from .lua import *
82
+ from .makefile import *
83
+ from .markdown import *
84
+ from .markup_templating import *
85
+ from .markup import *
86
+ from .matlab import *
87
+ from .mel import *
88
+ from .mizar import *
89
+ from .monkey import *
90
+ from .n4js import *
91
+ from .nasm import *
92
+ from .nginx import *
93
+ from .nim import *
94
+ from .nix import *
95
+ from .nsis import *
96
+ from .objectivec import *
97
+ from .ocaml import *
98
+ from .opencl import *
99
+ from .oz import *
100
+ from .parigp import *
101
+ from .parser import *
102
+ from .pascal import *
103
+ from .perl import *
104
+ from .php_extras import *
105
+ from .plsql import *
106
+ from .powershell import *
107
+ from .processing import *
108
+ from .prolog import *
109
+ from .properties import *
110
+ from .protobuf import *
111
+ from .pug import *
112
+ from .puppet import *
113
+ from .pure import *
114
+ from .q import *
115
+ from .qore import *
116
+ from .r import *
117
+ from .r import *
118
+ from .reason import *
119
+ from .renpy import *
120
+ from .rest import *
121
+ from .rip import *
122
+ from .roboconf import *
123
+ from .sas import *
124
+ from .sass import *
125
+ from .scala import *
126
+ from .scheme import *
127
+ from .scss import *
128
+ from .smalltalk import *
129
+ from .smarty import *
130
+ from .soy import *
131
+ from .stylus import *
132
+ from .swift import *
133
+ from .tcl import *
134
+ from .textile import *
135
+ from .tsx import *
136
+ from .twig import *
137
+ from .typescript import *
138
+ from .vbnet import *
139
+ from .velocity import *
140
+ from .verilog import *
141
+ from .vhdl import *
142
+ from .vim import *
143
+ from .visual_basic import *
144
+ from .wasam import *
145
+ from .xeora import *
146
+ from .xojo import *
147
+ from .yaml import *
@@ -0,0 +1,30 @@
1
+ from abc import ABC, abstractmethod
2
+
3
+ class Base(ABC):
4
+
5
+ @staticmethod
6
+ @abstractmethod
7
+ def comments():
8
+ pass
9
+
10
+ @staticmethod
11
+ @abstractmethod
12
+ def remove_comments(source: str):
13
+ pass
14
+
15
+ @staticmethod
16
+ @abstractmethod
17
+ def keywords() -> list:
18
+ pass
19
+
20
+ @staticmethod
21
+ @abstractmethod
22
+ def remove_keywords():
23
+ pass
24
+
25
+ @staticmethod
26
+ @abstractmethod
27
+ def file_extension() -> str:
28
+ pass
29
+
30
+
@@ -0,0 +1,52 @@
1
+ import re
2
+ from PyReprism.utils import extension
3
+
4
+
5
+ class Abap:
6
+ def __init__():
7
+ pass
8
+
9
+ @staticmethod
10
+ def file_extension() -> str:
11
+ return extension.abap
12
+
13
+ @staticmethod
14
+ def keywords() -> list:
15
+ keyword = 'SCIENTIFIC_WITH_LEADING_ZERO|SCALE_PRESERVING_SCIENTIFIC|RMC_COMMUNICATION_FAILURE|END-ENHANCEMENT-SECTION|MULTIPLY-CORRESPONDING|SUBTRACT-CORRESPONDING|VERIFICATION-MESSAGE|DIVIDE-CORRESPONDING|ENHANCEMENT-SECTION|CURRENCY_CONVERSION|RMC_SYSTEM_FAILURE|START-OF-SELECTION|MOVE-CORRESPONDING|RMC_INVALID_STATUS|CUSTOMER-FUNCTION|END-OF-DEFINITION|ENHANCEMENT-POINT|SYSTEM-EXCEPTIONS|ADD-CORRESPONDING|SCALE_PRESERVING|SELECTION-SCREEN|CURSOR-SELECTION|END-OF-SELECTION|LOAD-OF-PROGRAM|SCROLL-BOUNDARY|SELECTION-TABLE|EXCEPTION-TABLE|IMPLEMENTATIONS|PARAMETER-TABLE|RIGHT-JUSTIFIED|UNIT_CONVERSION|AUTHORITY-CHECK|LIST-PROCESSING|SIGN_AS_POSTFIX|COL_BACKGROUND|IMPLEMENTATION|INTERFACE-POOL|TRANSFORMATION|IDENTIFICATION|ENDENHANCEMENT|LINE-SELECTION|INITIALIZATION|LEFT-JUSTIFIED|SELECT-OPTIONS|SELECTION-SETS|COMMUNICATION|CORRESPONDING|DECIMAL_SHIFT|PRINT-CONTROL|VALUE-REQUEST|CHAIN-REQUEST|FUNCTION-POOL|FIELD-SYMBOLS|FUNCTIONALITY|INVERTED-DATE|SELECTION-SET|CLASS-METHODS|OUTPUT-LENGTH|CLASS-CODING|COL_NEGATIVE|ERRORMESSAGE|FIELD-GROUPS|HELP-REQUEST|NO-EXTENSION|NO-TOPOFPAGE|REDEFINITION|DISPLAY-MODE|ENDINTERFACE|EXIT-COMMAND|FIELD-SYMBOL|NO-SCROLLING|SHORTDUMP-ID|ACCESSPOLICY|CLASS-EVENTS|COL_POSITIVE|DECLARATIONS|ENHANCEMENTS|FILTER-TABLE|SWITCHSTATES|SYNTAX-CHECK|TRANSPORTING|ASYNCHRONOUS|SYNTAX-TRACE|TOKENIZATION|USER-COMMAND|WITH-HEADING|ABAP-SOURCE|BREAK-POINT|CHAIN-INPUT|COMPRESSION|FIXED-POINT|NEW-SECTION|NON-UNICODE|OCCURRENCES|RESPONSIBLE|SYSTEM-CALL|TRACE-TABLE|ABBREVIATED|CHAR-TO-HEX|END-OF-FILE|ENDFUNCTION|ENVIRONMENT|ASSOCIATION|COL_HEADING|EDITOR-CALL|END-OF-PAGE|ENGINEERING|IMPLEMENTED|INTENSIFIED|RADIOBUTTON|SYSTEM-EXIT|TOP-OF-PAGE|TRANSACTION|APPLICATION|CONCATENATE|DESTINATION|ENHANCEMENT|IMMEDIATELY|NO-GROUPING|PRECOMPILED|REPLACEMENT|TITLE-LINES|ACTIVATION|BYTE-ORDER|CLASS-POOL|CONNECTION|CONVERSION|DEFINITION|DEPARTMENT|EXPIRATION|INHERITING|MESSAGE-ID|NO-HEADING|PERFORMING|QUEUE-ONLY|RIGHTSPACE|SCIENTIFIC|STATUSINFO|STRUCTURES|SYNCPOINTS|WITH-TITLE|ATTRIBUTES|BOUNDARIES|CLASS-DATA|COL_NORMAL|DD\/MM\/YYYY|DESCENDING|INTERFACES|LINE-COUNT|MM\/DD\/YYYY|NON-UNIQUE|PRESERVING|SELECTIONS|STATEMENTS|SUBROUTINE|TRUNCATION|TYPE-POOLS|ARITHMETIC|BACKGROUND|ENDPROVIDE|EXCEPTIONS|IDENTIFIER|INDEX-LINE|OBLIGATORY|PARAMETERS|PERCENTAGE|PUSHBUTTON|RESOLUTION|COMPONENTS|DEALLOCATE|DISCONNECT|DUPLICATES|FIRST-LINE|HEAD-LINES|NO-DISPLAY|OCCURRENCE|RESPECTING|RETURNCODE|SUBMATCHES|TRACE-FILE|ASCENDING|BYPASSING|ENDMODULE|EXCEPTION|EXCLUDING|EXPORTING|INCREMENT|MATCHCODE|PARAMETER|PARTIALLY|PREFERRED|REFERENCE|REPLACING|RETURNING|SELECTION|SEPARATED|SPECIFIED|STATEMENT|TIMESTAMP|TYPE-POOL|ACCEPTING|APPENDAGE|ASSIGNING|COL_GROUP|COMPARING|CONSTANTS|DANGEROUS|IMPORTING|INSTANCES|LEFTSPACE|LOG-POINT|QUICKINFO|READ-ONLY|SCROLLING|SQLSCRIPT|STEP-LOOP|TOP-LINES|TRANSLATE|APPENDING|AUTHORITY|CHARACTER|COMPONENT|CONDITION|DIRECTORY|DUPLICATE|MESSAGING|RECEIVING|SUBSCREEN|ACCORDING|COL_TOTAL|END-LINES|ENDMETHOD|ENDSELECT|EXPANDING|EXTENSION|INCLUDING|INFOTYPES|INTERFACE|INTERVALS|LINE-SIZE|PF-STATUS|PROCEDURE|PROTECTED|REQUESTED|RESUMABLE|RIGHTPLUS|SAP-SPOOL|SECONDARY|STRUCTURE|SUBSTRING|TABLEVIEW|NUMOFCHAR|ADJACENT|ANALYSIS|ASSIGNED|BACKWARD|CHANNELS|CHECKBOX|CONTINUE|CRITICAL|DATAINFO|DD\/MM\/YY|DURATION|ENCODING|ENDCLASS|FUNCTION|LEFTPLUS|LINEFEED|MM\/DD\/YY|OVERFLOW|RECEIVED|SKIPPING|SORTABLE|STANDARD|SUBTRACT|SUPPRESS|TABSTRIP|TITLEBAR|TRUNCATE|UNASSIGN|WHENEVER|ANALYZER|COALESCE|COMMENTS|CONDENSE|DECIMALS|DEFERRED|ENDWHILE|EXPLICIT|KEYWORDS|MESSAGES|POSITION|PRIORITY|RECEIVER|RENAMING|TIMEZONE|TRAILING|ALLOCATE|CENTERED|CIRCULAR|CONTROLS|CURRENCY|DELETING|DESCRIBE|DISTANCE|ENDCATCH|EXPONENT|EXTENDED|GENERATE|IGNORING|INCLUDES|INTERNAL|MAJOR-ID|MODIFIER|NEW-LINE|OPTIONAL|PROPERTY|ROLLBACK|STARTING|SUPPLIED|ABSTRACT|CHANGING|CONTEXTS|CREATING|CUSTOMER|DATABASE|DAYLIGHT|DEFINING|DISTINCT|DIVISION|ENABLING|ENDCHAIN|ESCAPING|HARMLESS|IMPLICIT|INACTIVE|LANGUAGE|MINOR-ID|MULTIPLY|NEW-PAGE|NO-TITLE|POS_HIGH|SEPARATE|TEXTPOOL|TRANSFER|SELECTOR|DBMAXLEN|ITERATOR|SELECTOR|ARCHIVE|BIT-XOR|BYTE-CO|COLLECT|COMMENT|CURRENT|DEFAULT|DISPLAY|ENDFORM|EXTRACT|LEADING|LISTBOX|LOCATOR|MEMBERS|METHODS|NESTING|POS_LOW|PROCESS|PROVIDE|RAISING|RESERVE|SECONDS|SUMMARY|VISIBLE|BETWEEN|BIT-AND|BYTE-CS|CLEANUP|COMPUTE|CONTROL|CONVERT|DATASET|ENDCASE|FORWARD|HEADERS|HOTSPOT|INCLUDE|INVERSE|KEEPING|NO-ZERO|OBJECTS|OVERLAY|PADDING|PATTERN|PROGRAM|REFRESH|SECTION|SUMMING|TESTING|VERSION|WINDOWS|WITHOUT|BIT-NOT|BYTE-CA|BYTE-NA|CASTING|CONTEXT|COUNTRY|DYNAMIC|ENABLED|ENDLOOP|EXECUTE|FRIENDS|HANDLER|HEADING|INITIAL|\*-INPUT|LOGFILE|MAXIMUM|MINIMUM|NO-GAPS|NO-SIGN|PRAGMAS|PRIMARY|PRIVATE|REDUCED|REPLACE|REQUEST|RESULTS|UNICODE|WARNING|ALIASES|BYTE-CN|BYTE-NS|CALLING|COL_KEY|COLUMNS|CONNECT|ENDEXEC|ENTRIES|EXCLUDE|FILTERS|FURTHER|HELP-ID|LOGICAL|MAPPING|MESSAGE|NAMETAB|OPTIONS|PACKAGE|PERFORM|RECEIVE|STATICS|VARYING|BINDING|CHARLEN|GREATER|XSTRLEN|ACCEPT|APPEND|DETAIL|ELSEIF|ENDING|ENDTRY|FORMAT|FRAMES|GIVING|HASHED|HEADER|IMPORT|INSERT|MARGIN|MODULE|NATIVE|OBJECT|OFFSET|REMOTE|RESUME|SAVING|SIMPLE|SUBMIT|TABBED|TOKENS|UNIQUE|UNPACK|UPDATE|WINDOW|YELLOW|ACTUAL|ASPECT|CENTER|CURSOR|DELETE|DIALOG|DIVIDE|DURING|ERRORS|EVENTS|EXTEND|FILTER|HANDLE|HAVING|IGNORE|LITTLE|MEMORY|NO-GAP|OCCURS|OPTION|PERSON|PLACES|PUBLIC|REDUCE|REPORT|RESULT|SINGLE|SORTED|SWITCH|SYNTAX|TARGET|VALUES|WRITER|ASSERT|BLOCKS|BOUNDS|BUFFER|CHANGE|COLUMN|COMMIT|CONCAT|COPIES|CREATE|DDMMYY|DEFINE|ENDIAN|ESCAPE|EXPAND|KERNEL|LAYOUT|LEGACY|LEVELS|MMDDYY|NUMBER|OUTPUT|RANGES|READER|RETURN|SCREEN|SEARCH|SELECT|SHARED|SOURCE|STABLE|STATIC|SUBKEY|SUFFIX|TABLES|UNWIND|YYMMDD|ASSIGN|BACKUP|BEFORE|BINARY|BIT-OR|BLANKS|CLIENT|CODING|COMMON|DEMAND|DYNPRO|EXCEPT|EXISTS|EXPORT|FIELDS|GLOBAL|GROUPS|LENGTH|LOCALE|MEDIUM|METHOD|MODIFY|NESTED|OTHERS|REJECT|SCROLL|SUPPLY|SYMBOL|ENDFOR|STRLEN|ALIGN|BEGIN|BOUND|ENDAT|ENTRY|EVENT|FINAL|FLUSH|GRANT|INNER|SHORT|USING|WRITE|AFTER|BLACK|BLOCK|CLOCK|COLOR|COUNT|DUMMY|EMPTY|ENDDO|ENDON|GREEN|INDEX|INOUT|LEAVE|LEVEL|LINES|MODIF|ORDER|OUTER|RANGE|RESET|RETRY|RIGHT|SMART|SPLIT|STYLE|TABLE|THROW|UNDER|UNTIL|UPPER|UTF-8|WHERE|ALIAS|BLANK|CLEAR|CLOSE|EXACT|FETCH|FIRST|FOUND|GROUP|LLANG|LOCAL|OTHER|REGEX|SPOOL|TITLE|TYPES|VALID|WHILE|ALPHA|BOXED|CATCH|CHAIN|CHECK|CLASS|COVER|ENDIF|EQUIV|FIELD|FLOOR|FRAME|INPUT|LOWER|MATCH|NODES|PAGES|PRINT|RAISE|ROUND|SHIFT|SPACE|SPOTS|STAMP|STATE|TASKS|TIMES|TRMAC|ULINE|UNION|VALUE|WIDTH|EQUAL|LOG10|TRUNC|BLOB|CASE|CEIL|CLOB|COND|EXIT|FILE|GAPS|HOLD|INCL|INTO|KEEP|KEYS|LAST|LINE|LONG|LPAD|MAIL|MODE|OPEN|PINK|READ|ROWS|TEST|THEN|ZERO|AREA|BACK|BADI|BYTE|CAST|EDIT|EXEC|FAIL|FIND|FKEQ|FONT|FREE|GKEQ|HIDE|INIT|ITNO|LATE|LOOP|MAIN|MARK|MOVE|NEXT|NULL|RISK|ROLE|UNIT|WAIT|ZONE|BASE|CALL|CODE|DATA|DATE|FKGE|GKGE|HIGH|KIND|LEFT|LIST|MASK|MESH|NAME|NODE|PACK|PAGE|POOL|SEND|SIGN|SIZE|SOME|STOP|TASK|TEXT|TIME|USER|VARY|WITH|WORD|BLUE|CONV|COPY|DEEP|ELSE|FORM|FROM|HINT|ICON|JOIN|LIKE|LOAD|ONLY|PART|SCAN|SKIP|SORT|TYPE|UNIX|VIEW|WHEN|WORK|ACOS|ASIN|ATAN|COSH|EACH|FRAC|LESS|RTTI|SINH|SQRT|TANH|AVG|BIT|DIV|ISO|LET|OUT|PAD|SQL|ALL|CI_|CPI|END|LOB|LPI|MAX|MIN|NEW|OLE|RUN|SET|\?TO|YES|ABS|ADD|AND|BIG|FOR|HDB|JOB|LOW|NOT|SAP|TRY|VIA|XML|ANY|GET|IDS|KEY|MOD|OFF|PUT|RAW|RED|REF|SUM|TAB|XSD|CNT|COS|EXP|LOG|SIN|TAN|XOR|AT|CO|CP|DO|GT|ID|IF|NS|OR|BT|CA|CS|GE|NA|NB|EQ|IN|LT|NE|NO|OF|ON|PF|TO|AS|BY|CN|IS|LE|NP|UP|E|I|M|O|Z|C|X'.split('|')
16
+
17
+ return keyword
18
+
19
+ @staticmethod
20
+ def comment_regex():
21
+ pattern = re.compile(r'(?P<comment>^\*.*?$|".*?$|\(\*[\s\S]*?\*\)|\(\*.*?$|^.*?\*\))|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^*"\'"]*)', re.DOTALL | re.MULTILINE)
22
+ return pattern
23
+
24
+ @staticmethod
25
+ def number_regex():
26
+ pattern = re.compile(r'\b\d+\b')
27
+ return pattern
28
+
29
+ @staticmethod
30
+ def operator_regex():
31
+ pattern = re.compile(r'(\s)(?:\*\*?|<[=>]?|>=?|\?=|[-+\/=])(?=\s)')
32
+ return pattern
33
+
34
+ @staticmethod
35
+ def keywords_regex():
36
+ return re.compile(r'\b(' + '|'.join(Abap.keywords()) + r')\b')
37
+
38
+ @staticmethod
39
+ def remove_comments(source_code: str, isList: bool = False) -> str:
40
+ result = []
41
+ for match in Abap.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(Abap.keywords_regex()), '', source)
52
+
@@ -0,0 +1,52 @@
1
+ import re
2
+ from PyReprism.utils import extension
3
+
4
+
5
+ class ActionScript:
6
+ def __init__():
7
+ pass
8
+
9
+ @staticmethod
10
+ def file_extension() -> str:
11
+ return extension.actionscript
12
+
13
+ @staticmethod
14
+ def keywords() -> list:
15
+ keyword = 'as|break|case|catch|class|const|default|delete|do|else|extends|finally|for|function|if|implements|import|in|instanceof|interface|internal|is|native|new|null|package|private|protected|public|return|super|switch|this|throw|try|typeof|use|var|void|while|with|dynamic|each|final|get|include|namespace|native|override|set|static'.split('|')
16
+
17
+ return keyword
18
+
19
+ @staticmethod
20
+ def comment_regex():
21
+ pattern = re.compile(r'(?P<comment>^\*.*?$|".*?$|\(\*[\s\S]*?\*\)|\(\*.*?$|^.*?\*\))|(?P<noncomment>\'(\\.|[^\\\'])*\'|"(\\.|[^\\"])*"|.[^*"\'"]*)', re.DOTALL | re.MULTILINE)
22
+ return pattern
23
+
24
+ @staticmethod
25
+ def number_regex():
26
+ pattern = re.compile(r'\b\d+\b')
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(ActionScript.keywords()) + r')\b')
37
+
38
+ @staticmethod
39
+ def remove_comments(source_code: str, isList: bool = False) -> str:
40
+ result = []
41
+ for match in ActionScript.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(ActionScript.keywords_regex()), '', source)
52
+