feat: Разметил токены парсера

This commit is contained in:
ElectronixTM
2025-03-15 22:58:28 +03:00
parent 1b0e59922e
commit 88b5217f70

26
src/rulesparser.py Normal file
View File

@ -0,0 +1,26 @@
from collections import OrderedDict
import re
class RulesParser:
TRANSFORM = r'->'
B_TRANSFORM = r'->\|'
NEWLINE = '\n'
IGNORE = r'\s'
COMMENTS = r'//.+$'
EMPTY = r'\$'
def parse(self, file: str) -> OrderedDict[str, str]:
"""
Parsing file according to syntax, specified
in class variables. Hardcoded for now (and forever)
"""
with open(file, 'r') as f:
text = f.read()
def _remove_comments(self, src: str) -> str:
"""
removes comments from end of lines and returns
cleaned text
"""
return re.sub(self.COMMENTS, "", src)