From 88b5217f7078231a7209490d87d4f8089a200385 Mon Sep 17 00:00:00 2001 From: ElectronixTM Date: Sat, 15 Mar 2025 22:58:28 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=A0=D0=B0=D0=B7=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=82=D0=BE=D0=BA=D0=B5=D0=BD=D1=8B=20=D0=BF?= =?UTF-8?q?=D0=B0=D1=80=D1=81=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rulesparser.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/rulesparser.py diff --git a/src/rulesparser.py b/src/rulesparser.py new file mode 100644 index 0000000..cb629a2 --- /dev/null +++ b/src/rulesparser.py @@ -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) +