diff options
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/transcode-tblgen.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb index dbd03e3028..14a09dbadf 100755 --- a/tool/transcode-tblgen.rb +++ b/tool/transcode-tblgen.rb @@ -133,6 +133,12 @@ class StrSet } end + def has_nonempty? + @pat.any? {|seq| + !seq.empty? + } + end + def first_bytes result = {} @pat.each {|seq| @@ -228,6 +234,18 @@ class ActionMap @map.keys.map {|k| k.max_length }.max end + def check_conflict + has_empty = false + has_nonempty = false + @map.each {|ss, action| + has_empty = true if ss.emptyable? + has_nonempty = true if ss.has_nonempty? + } + if has_empty && has_nonempty + raise "conflict between empty and nonempty sequence" + end + end + def empty_action @map.each {|ss, action| return action if ss.emptyable? @@ -440,6 +458,7 @@ End table = Array.new(0x100, :invalid) each_firstbyte(valid_encoding) {|byte, rest, rest_valid_encoding| + rest.check_conflict if a = rest.empty_action table[byte] = a else |