Initial commit - fix problems & refactor code

This commit is contained in:
2025-12-22 19:10:46 +03:00
commit ff36917cb5
39 changed files with 1499 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
from core.environment import IGNORE, MEANINGFUL
import re
def processString(source: str) -> str:
"""Remove blank characters and comments from source code.
Args:
source: The source code string.
Returns:
The cleaned source code.
"""
source = source.lstrip(IGNORE)
while source and source[0] == ";":
line_end: int = source.find("\n")
if line_end < 0:
return ""
source = source[line_end:].lstrip(IGNORE)
return source
def findPrefix(source: str, separators: str = IGNORE + MEANINGFUL) -> str:
"""Find a meaningful prefix (token) in the source string.
Args:
source: The source code string.
separators: Characters that mark token boundaries.
Returns:
The prefix token found, or empty string if none.
"""
pattern: str = rf"^[^{separators}]*"
match = re.match(pattern, source)
return match.group(0) if match else ""