def main_of_analizer(jackfilename):

    #getting jack file name
    (jfilename, jextension) = os.path.splitext(jackfilename)
    jackxml = jfilename + ".xml"  #just to be consistent with the book

    compiler = CompilationEngine(jackfilename, jackxml)
Example #2
0
def main():
    files = []
    in_path = sys.argv[1]
    if os.path.isfile(in_path):
        print('main: in: file')
        in_file_name = os.path.basename(in_path)
        files.append(in_path)
    else:
        print('main: in: directory')
        for entry in os.scandir(in_path):
            if entry.path.endswith('.jack'):
                files.append(entry.path)
                
    for in_f in files:
        out_file_path = make_out_file_path(in_f)
        print(f'compiling file: {in_f}')
        print(f'out: {out_file_path}')
        tokenizer = JackTokenizer(in_f)  
        compilation_engine = CompilationEngine(tokenizer, out_file_path)
        compilation_engine.compile_class()