From 2c64f9cf93e3d854c6aff23e657ea8fb72e6d57a Mon Sep 17 00:00:00 2001 From: Andrew Huth Date: Wed, 31 Jan 2024 20:29:26 -0500 Subject: [PATCH] Discard first match, instead of discarding --- src/cpu.ts | 3 +-- src/reducer.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cpu.ts b/src/cpu.ts index 22246ac..293b07e 100644 --- a/src/cpu.ts +++ b/src/cpu.ts @@ -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) { diff --git a/src/reducer.ts b/src/reducer.ts index ee31158..03fc829 100644 --- a/src/reducer.ts +++ b/src/reducer.ts @@ -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, }; }