Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class build():
- ALLOWED_TYPES = ['echo', 'print', 'var', '']
- RECOGNIZED_TYPES = []
- RECOGNIZED_TYPE_VALUES = []
- def __init__(self, FileName):
- self.FileName = FileName
- self.buildFromFile()
- def buildFromFile(self):
- with open(self.FileName, 'r', encoding='utf-8') as FileDocument:
- for i, DocumentLines in enumerate(FileDocument):
- DocumentLines = DocumentLines.lower()
- Line = DocumentLines.split('\n')
- Type = Line[0].split(" ")
- if Type[0] in self.ALLOWED_TYPES and Type[0] != '':
- self.RECOGNIZED_TYPES.append({i: Type})
- elif Type[0] == '':
- pass
- else:
- print("Unrecognized type of '"+Type[0]+"' on line "+str((i+1))+", program terminated.")
- return
- self.CheckTypes()
- def Type_echo(self, TypeValue):
- #[{'echo': "'aaaaa'"}, {'print': "'aaaaa'"}, {'var': "'a'"}]
- print(TypeValue)
- def Type_print(self, TypeValue):
- self.Typeecho(TypeValue)
- def Type_var(self, Variable):
- # Variable structure: var NAME = 'VALUE';
- pass
- def CheckTypes(self):
- # echo 'Neco'
- # print 'Neco'
- # var neco = 'neco'
- for i, Type in enumerate(self.RECOGNIZED_TYPES):
- #tst = self.RECOGNIZED_TYPE_VALUES[i].get(Type)
- #tst = str(self.RECOGNIZED_TYPE_VALUES[i]).split("'")
- pass
- '''
- ['{', 'echo', ': "', 'aaaaa', '"}']
- ['{', 'print', ': "', 'aaaaa', '"}']
- ['{', 'var', ': "', 'a', '"}']
- '''
- #print(self.RECOGNIZED_TYPE_VALUES)
- #exec("self.Type_"+Type + '('+tst+')')
- cls = build('test.txt')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement