2014-02-26 18:50:16 +00:00
|
|
|
rule '.rb' => '.rl' do |task|
|
|
|
|
sh "ragel -F1 -R #{task.source} -o #{task.name}"
|
2014-05-01 22:40:10 +00:00
|
|
|
|
|
|
|
puts "Applying patch http://git.io/ow6e1A to #{task.name}"
|
|
|
|
|
|
|
|
# Patches the lexer based on http://git.io/ow6e1A.
|
|
|
|
input = File.read(task.source)
|
|
|
|
output = File.read(task.name)
|
|
|
|
getkey = input.match(/getkey\s+(.+);/)[1]
|
|
|
|
|
|
|
|
output = output.gsub(getkey, '_wide')
|
|
|
|
output = output.gsub('_trans = if', "_wide = #{getkey}\n _trans = if")
|
|
|
|
|
|
|
|
File.open(task.name, 'w') do |handle|
|
|
|
|
handle.write(output)
|
|
|
|
end
|
2014-02-26 18:50:16 +00:00
|
|
|
end
|
|
|
|
|
2014-05-09 22:28:23 +00:00
|
|
|
rule '.c' => ['.rl', 'ext/ragel/base_lexer.rl'] do |task|
|
2014-05-06 22:50:34 +00:00
|
|
|
sh "ragel -I ext/ragel -C -G2 #{task.source} -o #{task.name}"
|
2014-05-04 22:25:34 +00:00
|
|
|
end
|
|
|
|
|
2014-05-09 22:28:23 +00:00
|
|
|
rule '.java' => ['.rl', 'ext/ragel/base_lexer.rl'] do |task|
|
2014-05-06 22:50:34 +00:00
|
|
|
sh "ragel -I ext/ragel -J #{task.source} -o #{task.name}"
|
2014-05-06 08:20:30 +00:00
|
|
|
end
|
|
|
|
|
2014-05-04 22:25:34 +00:00
|
|
|
desc 'Generates the lexers'
|
2014-05-06 08:20:30 +00:00
|
|
|
multitask :lexer => [
|
2014-05-06 22:29:10 +00:00
|
|
|
'ext/c/lexer.c',
|
2014-05-14 06:48:49 +00:00
|
|
|
'ext/java/org/liboga/xml/Lexer.java',
|
|
|
|
'lib/oga/xpath/lexer.rb'
|
2014-05-06 08:20:30 +00:00
|
|
|
]
|