2 construct_embedded written by Mitchell Foral. mitchell<att>caladbolg<dott>net.
5 def has_embedded?(parser_file)
6 return IO.read(parser_file).include?('#EMBED')
9 def construct_language(parser_file)
10 parser_text = IO.read(parser_file).gsub(/#EMBED\([\w_]+\)/) do |elang|
11 lang = elang.scan(/^#EMBED\(([\w_]+)\)/)[0][0]
12 eparser_file = lang + '.rl'
13 if File.exists?(eparser_file)
14 eparser = IO.read(eparser_file)
15 ragel = eparser.scan(/%%\{(.+?)\}%%/m)[0][0]
16 # eliminate machine definition, writes, and includes
17 ragel.gsub!(/^\s*machine[^;]+;\s+write[^;]+;\s+include[^;]+;\s+/, '')
23 f = File.new(parser_file + '.tmp', 'w')