Skip to content

Commit

Permalink
Raise error if trying to create empty ranges (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
renatahodovan authored Oct 3, 2023
1 parent aba79b8 commit be1fd0f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions grammarinator/tool/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ class Charset(object):
_cnt = 0

def __init__(self, ranges):
if not ranges:
raise ValueError('Charset must contain at least one range')
for start, end in ranges:
if end <= start:
raise ValueError(f"Charset range must not be empty: '\\u{{{start:x}}}'..'\\u{{{end - 1:x}}}', '{chr(start)}'..'{chr(end - 1)}'")
self.id = Charset._cnt
Charset._cnt += 1
self.ranges = ranges
Expand Down

0 comments on commit be1fd0f

Please sign in to comment.