Parser - abstract resetForNewParse in prep for error handling

This commit is contained in:
2026-03-02 23:08:00 -06:00
parent f778507f39
commit bd3453c9b0

View File

@@ -70,14 +70,18 @@ export class Parser extends BehaviorSubject<Executable<CommandData>> {
}) })
return return
} finally { } finally {
this.parseCandidate = undefined this.resetForNewParse()
this.inputForCandidate = []
} }
} }
throw new InternalParseError('Encountered invalid token.') throw new InternalParseError('Encountered invalid token.')
} }
private resetForNewParse() {
this.parseCandidate = undefined
this.inputForCandidate = []
}
private isKeyword(token: LexToken): token is (LexInput & {literal: undefined}) { private isKeyword(token: LexToken): token is (LexInput & {literal: undefined}) {
return token.type === 'input' && !token.literal return token.type === 'input' && !token.literal
} }