vendor/github.com/hashicorp/hcl/v2/hclsyntax/unicode2ragel.rb
##
# Generate the state maching to stdout
Generate the state maching to stdout
Generate the state maching to stdout
def generate_machine( name, property )
  pipe = " "
  @output.puts "    #{name} = "
  each_alpha( @chart_url, property ) do |range, desc|
    codes = (@encoding == :ucs4) ? to_ucs4(range) : to_utf8(range)
    range_width = codes.map { |a| a.size }.max
    range_width = RANGE_WIDTH if range_width < RANGE_WIDTH
    desc_width  = TOTAL_WIDTH - RANGE_WIDTH - 11
    desc_width -= (range_width - RANGE_WIDTH) if range_width > RANGE_WIDTH
    if desc.size > desc_width
      desc = desc[0..desc_width - 4] + "..."
    end
    codes.each_with_index do |r, idx|
      desc = "" unless idx.zero?
      code = "%-#{range_width}s" % r
      @output.puts "      #{pipe} #{code} ##{desc}"
      pipe = "|"
    end
  end
  @output.puts "      ;"
  @output.puts ""
end
def generate_machine ( name , property ) pipe = " " @output . puts "    #{name} = " each_alpha ( @chart_url , property ) do | range , desc | codes = ( @encoding == :ucs4 ) ? to_ucs4 ( range ) : to_utf8 ( range ) range_width = codes . map { | a | a . size } . max range_width = RANGE_WIDTH if range_width < RANGE_WIDTH desc_width = TOTAL_WIDTH - RANGE_WIDTH - 11 desc_width -= ( range_width - RANGE_WIDTH ) if range_width > RANGE_WIDTH if desc . size > desc_width desc = desc [ 0 .. desc_width - 4 ] + "..." end codes . each_with_index do | r , idx | desc = "" unless idx . zero? code = "%-#{range_width}s" % r @output . puts "      #{pipe} #{code} ##{desc}" pipe = "|" end end @output . puts "      ;" @output . puts "" end
Generate the state maching to stdout
Generate the state maching to stdout
#raise "Invalid encoding of range #{range}: #{codes.inspect}" unless  #  is_valid? range, desc, codes
name
property