lib/hack_assembler.rb in hack_assembler-0.1.0 vs lib/hack_assembler.rb in hack_assembler-0.2.0

- old
+ new

@@ -4,16 +4,21 @@ require_relative 'hack_assembler/computation_translator' require_relative 'hack_assembler/destination_translator' require_relative 'hack_assembler/jump_translator' require_relative 'hack_assembler/c_instruction' require_relative 'hack_assembler/assembler' +require_relative 'hack_assembler/symbol_table' module HackAssembler def self.translate_file(input_file, output_file) source_file = File.open(input_file) source_code = source_file.read - machine_code = Assembler.translate(source_code) + symbol_table = SymbolTable.new + + label_less_code = Assembler.scan_and_remove_labels(source_code, symbol_table) + processed_source = Assembler.process_symbols(label_less_code, symbol_table) + machine_code = Assembler.translate(processed_source) File.open(output_file, 'w') { |file| file.write(machine_code); file.close } source_file.close end