Reference

Version

src.PyReprism.__version__

Current PyReprism version.

Python

class PyReprism.languages.python.Python

Bases: BaseLanguage

This is the class for processing Python source code

__module__ = 'PyReprism.languages.python'
classmethod comment_regex() Pattern

Compile and return a regular expression pattern to identify different types of comments and non-comment code in Python source files.

Returns:

A compiled regex pattern with named groups to match single-line comments, multiline comments, and non-comment code elements.

Return type:

re.Pattern

classmethod delimiters_regex() Pattern

Compile and return a regular expression pattern to identify Python delimiters.

Returns:

A compiled regex pattern to match Python delimiters.

Return type:

re.Pattern

classmethod file_extension() str

Return the file extension used for Python files.

Returns:

The file extension for Python files.

Return type:

str

classmethod keywords() list

Return a list of Python keywords and built-in functions.

Returns:

A list of Python keywords and built-in function names.

Return type:

list

classmethod number_regex() Pattern

Compile and return a regular expression pattern to identify numeric literals in Python code.

Returns:

A compiled regex pattern to match Python numeric literals, including integers, floats, and complex numbers.

Return type:

re.Pattern

classmethod operator_regex() Pattern

Compile and return a regular expression pattern to identify Python operators.

Returns:

A compiled regex pattern to match various Python operators and logical keywords.

Return type:

re.Pattern

classmethod remove_comments(source_code: str, isList: bool = False) str

Remove comments from the provided Python source code string.

Parameters:
  • source_code (str) – The Python source code from which to remove comments.

  • isList (bool) – (Optional) A flag indicating if the input is a list of source code lines. This parameter is not used in the function logic.

Returns:

The source code with all comments removed.

Return type:

str

classmethod remove_keywords(source: str) str

Remove all Python keywords from the provided source code string.

Parameters:

source (str) – The source code string from which to remove Python keywords.

Returns:

The source code string with all Python keywords removed.

Return type:

str

Java

class PyReprism.languages.java.Java

Bases: BaseLanguage

Java language helper; migrated to BaseLanguage pattern.

Provides regex helpers and delegates comment/keyword removal to BaseLanguage.

__annotations__ = {}
__module__ = 'PyReprism.languages.java'
classmethod boolean_regex() Pattern

Regex for Java boolean literals.

Parameters:

source – The source code string from which to remove Java keywords.

Return type:

re.Pattern

classmethod comment_regex() Pattern

Regex to capture comments (group ‘comment’) and non-comment fragments (group ‘noncomment’).

Return type:

re.Pattern

classmethod delimiters_regex() Pattern

Regex for Java delimiters.

Return type:

re.Pattern

classmethod file_extension() str

Return the file extension used for Java files. :rtype: str

classmethod keywords() list

Return a list of Java keywords and built-in functions. :rtype: list[str]

classmethod keywords_regex() Pattern

Compile and return a regex that matches Java keywords.

Return type:

re.Pattern

classmethod number_regex() Pattern

Regex for numeric literals.

Return type:

re.Pattern

classmethod operator_regex() Pattern

Regex for Java operators.

Return type:

re.Pattern

classmethod remove_comments(source_code: str, isList: bool = False)

Preserve original Java behavior: for scalar output perform a substitution then strip (as older implementation did). If the caller requests a list, fall back to BaseLanguage’s behavior.

Parameters:
  • source_code – The Java source code to process.

  • isList – If True, return a list of non-comment segments; otherwise, return a single string.

Return type:

str or list[str]

classmethod remove_keywords(source: str) str

Delegate keyword removal to BaseLanguage.

Parameters:

source – The source code string from which to remove Java keywords.

Return type:

str

C++

class PyReprism.languages.cpp.CPP

Bases: BaseLanguage

__annotations__ = {}
__module__ = 'PyReprism.languages.cpp'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False) str

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

C

class PyReprism.languages.c.C

Bases: BaseLanguage

__annotations__ = {}
__module__ = 'PyReprism.languages.c'
classmethod comment_regex() Pattern

Returns a compiled regex pattern to match comments and non-comment parts in C source code. This pattern matches both single-line (//) and multi-line (/* … */) comments

Returns:

A compiled regex pattern.

Type:

re.Pattern

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern

Returns a compiled regex pattern to match numeric literals in C source code. This pattern matches hexadecimal, decimal, and floating-point numbers

Returns:

A compiled regex pattern.

Type:

re.Pattern

classmethod operator_regex() Pattern

Returns a compiled regex pattern to match operators in C source code. This pattern matches various C operators including arithmetic, comparison, and logical operators.

Returns:

A compiled regex pattern.

Type:

re.Pattern

classmethod remove_comments(source_code: str, isList: bool = False) str

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

Scala

class PyReprism.languages.scala.Scala

Bases: BaseLanguage

Scala language helper.

Provides keyword list and regex helpers for comment, number, operator, and delimiter handling. Delegates removal logic to BaseLanguage.

__annotations__ = {}
__module__ = 'PyReprism.languages.scala'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False)

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

Dart

class PyReprism.languages.dart.Dart

Bases: BaseLanguage

Dart language helper migrated to BaseLanguage pattern.

__annotations__ = {}
__module__ = 'PyReprism.languages.dart'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False)

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

Rust

class PyReprism.languages.rust.Rust

Bases: BaseLanguage

Rust language helper.

Provides comment/number/operator regexes and a list of Rust keywords.

__annotations__ = {}
__module__ = 'PyReprism.languages.rust'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False)

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

Kotlin

class PyReprism.languages.kotlin.Kotlin

Bases: BaseLanguage

Kotlin language helper.

Implements comment, number, operator, delimiter and keyword helpers for Kotlin. Delegates removal logic to BaseLanguage.

__annotations__ = {}
__module__ = 'PyReprism.languages.kotlin'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False)

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

Swift

class PyReprism.languages.swift.Swift

Bases: BaseLanguage

Swift language helper.

__annotations__ = {}
__module__ = 'PyReprism.languages.swift'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod keywords_regex() Pattern
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False)

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

JavaScript

class PyReprism.languages.javascript.JavaScript

Bases: BaseLanguage

__annotations__ = {}
__module__ = 'PyReprism.languages.javascript'
classmethod boolean_regex() Pattern
classmethod comment_regex() Pattern

Return a compiled regex with named groups ‘comment’ and ‘noncomment’.

classmethod delimiters_regex() Pattern
classmethod file_extension() str
classmethod keywords() list
classmethod number_regex() Pattern
classmethod operator_regex() Pattern
classmethod remove_comments(source_code: str, isList: bool = False) str

Strip comments using the language’s comment_regex.

The regex is expected to provide a ‘noncomment’ named group for text to keep. Returns either the joined string or a list of non-comment segments when isList=True.

classmethod remove_keywords(source: str) str

JSX

class PyReprism.languages.jsx.Jsx

Bases: BaseLanguage

JSX/React-like language helper migrated to BaseLanguage.

Keeps comment-removal semantics from the original implementation (only append non-empty ‘noncomment’ matches). Keywords removal is delegated to the base class.

__annotations__ = {}
__module__ = 'PyReprism.languages.jsx'
classmethod boolean_regex() Pattern

Return a regex matching boolean-like literals.

Return type:

re.Pattern

classmethod comment_regex() Pattern

Compile and return a regex that captures comments and non-comment fragments in JSX-like source.

The pattern includes single-line // comments, C-style /* … / block comments, and JSX fragments like {/*/}. It provides named groups comment and noncomment as required by BaseLanguage helpers.

Return type:

re.Pattern

classmethod delimiters_regex() Pattern

Return a regex matching delimiter characters used in JSX/JS.

Return type:

re.Pattern

classmethod file_extension() str

Return the file extension used for JSX/TSX files.

Return type:

str

classmethod keywords() list

Return a list of JavaScript/JSX keywords used for token filtering.

Return type:

list

classmethod keywords_regex() Pattern

Compile a regex that matches any of the language keywords.

Return type:

re.Pattern

classmethod number_regex() Pattern

Return a regex matching numeric literals used in JSX/JavaScript.

Return type:

re.Pattern

classmethod operator_regex() Pattern

Return a regex matching common JavaScript operators.

Return type:

re.Pattern

classmethod remove_comments(source_code: str, isList: bool = False)

Remove comments from source, returning either the joined string or a list of non-comment fragments when isList is True.

Parameters:
  • source_code (str) – the source text to process

  • isList (bool) – if True return list of fragments instead of string

Return type:

list[str] or str

classmethod remove_keywords(source: str) str

Remove known keywords from the source using BaseLanguage helper.

Parameters:

source (str) – input source text

Return type:

str