Skip to content

Commit

Permalink
Discard first match, instead of discarding
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuth committed Feb 1, 2024
1 parent 421fecb commit 2c64f9c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/cpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ export function parse(code: string): Instruction[] {
throw new Error('Invalid instruction!');
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_fullMatch, cond, operator, raw_operands = ''] = matches;
const [, cond, operator, raw_operands = ''] = matches;
const operands = raw_operands.split(/\s/).map(Number);

switch (operator) {
Expand Down
2 changes: 1 addition & 1 deletion src/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function reducer(state: State, action: Action) {
return {
...state,
index: state.index + 1,
onLine: state.instructions[state.index + 1]?.line ?? state.onLine,
onLine: state.instructions[state.index + 1]?.line ?? state.onLine + 1,
stack: nextStack,
};
}
Expand Down

0 comments on commit 2c64f9c

Please sign in to comment.