-
Notifications
You must be signed in to change notification settings - Fork 0
/
Process_MDRI.py
51 lines (41 loc) · 1.39 KB
/
Process_MDRI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import argparse
from lexer import Lexer
from parser import Parser
from execution_engine import ExecutionEngine
from error_corrector import ErrorCorrector
from jit_compiler import JITCompiler
from logger import Logger
from plugin_manager import plugin_manager
def process_mdri(file_path):
with open(file_path, 'r') as file:
content = file.read()
# Error correction
error_corrector = ErrorCorrector()
corrected_content = error_corrector.correct_errors(content)
Logger.info("Error correction complete")
# Tokenization
lexer = Lexer(corrected_content)
tokens = lexer.tokens
Logger.debug(f"Tokens: {tokens}")
# Parsing
parser = Parser(tokens)
ast = parser.ast
Logger.debug(f"AST: {ast}")
# JIT Compilation
jit_compiler = JITCompiler()
compiled_code = jit_compiler.compile(corrected_content)
Logger.info("JIT compilation complete")
# Execution
execution_engine = ExecutionEngine(ast)
execution_engine.execute()
Logger.info("Execution complete")
# Plugin execution
plugin_manager.execute_plugins(corrected_content.splitlines())
Logger.info("Plugin execution complete")
def main():
parser = argparse.ArgumentParser(description='MDRI Processing Engine')
parser.add_argument('file', help='Path to the MDRI file')
args = parser.parse_args()
process_mdri(args.file)
if __name__ == "__main__":
main()