Class: Assembler::Translator
- Inherits:
-
Object
- Object
- Assembler::Translator
- Defined in:
- lib/hackasm/assembler/translator.rb
Instance Method Summary collapse
-
#initialize(text) ⇒ Translator
constructor
A new instance of Translator.
- #translate ⇒ Object
Constructor Details
#initialize(text) ⇒ Translator
Returns a new instance of Translator.
9 10 11 |
# File 'lib/hackasm/assembler/translator.rb', line 9 def initialize(text) @text = text end |
Instance Method Details
#translate ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/hackasm/assembler/translator.rb', line 13 def translate expressions = parser.parse(@text) expressions.map do |expression| process_instruction(expression) end.compact.join("\n") << "\n" rescue Parslet::ParseFailed => failure failure.parse_failure_cause.ascii_tree end |