Skip to content

Commit 022ff1f

Browse files
committed
Implement Parser#comp
1 parent e7f2377 commit 022ff1f

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/parser.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ def dest
4242
end
4343
end
4444

45+
def comp
46+
current
47+
.split('=').last
48+
.split(';').first
49+
end
50+
4551
private
4652

4753
attr_reader :lines, :current

spec/unit/parser_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@
242242
'D=D-M' => 'D-M',
243243
'M=M-D' => 'M-D',
244244
'M=D&M' => 'D&M',
245-
'M=D|M' => 'D|M'
245+
'M=D|M' => 'D|M',
246+
'D=0;JMP' => '0'
246247
}.each do |command, mnemonic|
247248
context "when the comp mnemonic is #{mnemonic}" do
248249
let(:input) { command }

0 commit comments

Comments
 (0)