Implemented Parser Method
This commit is contained in:
+28
-3
@@ -1,7 +1,32 @@
|
||||
from os import listdir
|
||||
class VirtualMachineCompiler:
|
||||
def __init__(self):
|
||||
pass
|
||||
def __init__(self,file_path):
|
||||
self.file_path=file_path
|
||||
self.files=[]
|
||||
self.files_content=[]
|
||||
self.is_folder=True
|
||||
if ".vm" in file_path:
|
||||
self.is_folder=False
|
||||
self.files.append(file_path)
|
||||
def folder_search(self):
|
||||
for item in listdir(self.file_path):
|
||||
if ".vm" in item:
|
||||
self.files.append(self.file_path+"\\"+item)
|
||||
def parser_module(self):
|
||||
pass
|
||||
if self.is_folder:
|
||||
self.folder_search()
|
||||
for file in self.files:
|
||||
file_content=open(file)
|
||||
for line in file_content:
|
||||
command=[None,None,None]
|
||||
line=line[:line.find("//")]
|
||||
line = line.strip()
|
||||
if line =="":
|
||||
continue
|
||||
line_array=line.split()
|
||||
for index in range(len(line_array)):
|
||||
command[index]=line_array[index]
|
||||
self.files_content.append(command)
|
||||
file_content.close()
|
||||
def code_writer_module(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user