Skip to content

Commit

Permalink
Allow invalid state regexes to exit rather than raise no allowed toke…
Browse files Browse the repository at this point in the history
…ns error (#87)
  • Loading branch information
JoshC8C7 authored Apr 12, 2024
1 parent 9247311 commit 5127ca8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lmformatenforcer/regexparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5127ca8

Please sign in to comment.