Show non-printable characters better in NFA#to_s
This commit is contained in:
parent
952bffc33c
commit
3a1650906e
@ -49,6 +49,13 @@ module Imbecile
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
|
chr = lambda do |value|
|
||||||
|
if value < 32 || value > 127
|
||||||
|
"{#{value}}"
|
||||||
|
else
|
||||||
|
value.chr
|
||||||
|
end
|
||||||
|
end
|
||||||
rv = ""
|
rv = ""
|
||||||
states = {start_state => 0}
|
states = {start_state => 0}
|
||||||
to_visit = [start_state]
|
to_visit = [start_state]
|
||||||
@ -66,9 +73,9 @@ module Imbecile
|
|||||||
if range.nil?
|
if range.nil?
|
||||||
range_s = "nil"
|
range_s = "nil"
|
||||||
else
|
else
|
||||||
range_s = range.first.chr
|
range_s = chr[range.first]
|
||||||
if range.size > 1
|
if range.size > 1
|
||||||
range_s += "-" + range.last.chr
|
range_s += "-" + chr[range.last]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
accepts_s = dest_state.accepts ? " *" : ""
|
accepts_s = dest_state.accepts ? " *" : ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user