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) +