[ragel-users] string representation of entities in dot files

Gaspard Bucher gaspard at teti.ch
Wed Dec 3 14:43:19 UTC 2008


Hi list !

Anyone knows if there is an option to "ragel -V" to show litteral
values instead of numerical ones in the "dot" generated file ?

A --- 34 ---> B

is less readable then

A --- " ---> B

If there is no such option and such a filter could help others, here's
a simple ruby script that does the job.

====== filter.rb =======
#!/usr/bin/env ruby
STDIN.read.split("\n").each do |l|
  new_l = l.sub(/([^\"]*)\"([^\"]*)\"/) do
    pre = $1
    str = $2
    str.gsub!(/([0-9]+)/) do
      val = $1.to_i
      if val <= 31
        val.to_s
      elsif val == 32
        "' '"
      elsif val == 47
        "'/'"
      elsif val == 34
        "\\\""
      elsif val == 92
        "'\\\\'"
      elsif val < 126
        val.chr
      else
        val.to_s
      end
    end
    "#{pre}\"#{str}\""
  end
  puts new_l
end
===================


Gaspard




More information about the ragel-users mailing list