From 5127ca8c37d5c0acabb6c8f0a65ff1103e31551c Mon Sep 17 00:00:00 2001 From: Josh C <32071009+JoshC8C7@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:06:23 +0100 Subject: [PATCH] Allow invalid state regexes to exit rather than raise no allowed tokens error (#87) --- lmformatenforcer/regexparser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lmformatenforcer/regexparser.py b/lmformatenforcer/regexparser.py index c782531..ed134b3 100644 --- a/lmformatenforcer/regexparser.py +++ b/lmformatenforcer/regexparser.py @@ -51,7 +51,7 @@ def add_character(self, new_character: str) -> 'RegexParser': return RegexParser(self.context, self.config, RegexParser.INVALID_STATE) def can_end(self) -> bool: - return self.current_state in self.context.pattern.finals + return self.current_state in self.context.pattern.finals or self.current_state == RegexParser.INVALID_STATE def get_allowed_characters(self) -> str: if self.current_state not in self.context.pattern.map: