Class: Vm::Translator
- Inherits:
-
Object
- Object
- Vm::Translator
- Defined in:
- lib/hackasm/vm/translator.rb
Instance Method Summary collapse
-
#initialize(text, object_name) ⇒ Translator
constructor
A new instance of Translator.
- #translate ⇒ Object
Constructor Details
#initialize(text, object_name) ⇒ Translator
Returns a new instance of Translator.
7 8 9 10 |
# File 'lib/hackasm/vm/translator.rb', line 7 def initialize(text, object_name) @text = text @object_name = object_name end |
Instance Method Details
#translate ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/hackasm/vm/translator.rb', line 12 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 |