Fix multiplicity count parsing
This commit is contained in:
parent
8cd648fc8f
commit
449eec4982
@ -172,16 +172,21 @@ module Imbecile
|
|||||||
end
|
end
|
||||||
|
|
||||||
def parse_curly_count
|
def parse_curly_count
|
||||||
if @pattern =~ /^(\d+)(?:,(\d+))?\}(.*)$/
|
if @pattern =~ /^(\d+)(?:(,)(\d*))?\}(.*)$/
|
||||||
min_count = $1.to_i
|
min_count, comma, max_count, pattern = $1, $2, $3, $4
|
||||||
max_count = nil
|
min_count = min_count.to_i
|
||||||
if $2 != ""
|
if comma.to_s == ""
|
||||||
max_count = $2.to_i
|
max_count = min_count
|
||||||
|
else
|
||||||
|
max_count = nil
|
||||||
|
end
|
||||||
|
if max_count.to_s != ""
|
||||||
|
max_count = max_count.to_i
|
||||||
if max_count < min_count
|
if max_count < min_count
|
||||||
raise Error.new("Maximum repetition count cannot be less than minimum repetition count")
|
raise Error.new("Maximum repetition count cannot be less than minimum repetition count")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@pattern = $3
|
@pattern = pattern
|
||||||
[min_count, max_count]
|
[min_count, max_count]
|
||||||
else
|
else
|
||||||
raise Error.new("Unexpected match count at #{@pattern}")
|
raise Error.new("Unexpected match count at #{@pattern}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user