-
Notifications
You must be signed in to change notification settings - Fork 31
/
Rakefile
63 lines (47 loc) · 1.3 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- ruby -*-
require 'rubygems'
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
end
task :test => :parser
task :grammar do
require 'kpeg'
require 'kpeg/format'
require 'kpeg/grammar_renderer'
gr = KPeg::GrammarRenderer.new(KPeg::FORMAT)
gr.render(STDOUT)
end
rule ".rb" => ".kpeg" do |t|
ruby "-Ilib bin/kpeg -s -o #{t.name} -f #{t.source}"
end
rule ".kpeg.rb" => ".kpeg" do |t|
ruby "-Ilib bin/kpeg -s -o #{t.name} -f #{t.source}"
end
PARSER_FILES = %w[
lib/kpeg/string_escape.rb
lib/kpeg/format_parser.rb
]
PARSER_FILES.each do |parser_file|
file parser_file => 'lib/kpeg/compiled_parser.rb'
file parser_file => 'lib/kpeg/code_generator.rb'
file parser_file => 'lib/kpeg/position.rb'
file parser_file => parser_file.sub(/\.rb$/, '.kpeg')
end
EXAMPLE_FILES = Dir.glob('examples/*/*.kpeg').map{|f| f + ".rb" }
EXAMPLE_FILES.each do |example_file|
file example_file => 'lib/kpeg/compiled_parser.rb'
file example_file => 'lib/kpeg/code_generator.rb'
file example_file => 'lib/kpeg/position.rb'
file example_file => example_file.sub(/\.rb$/, '')
end
desc "build the parser"
task :parser => PARSER_FILES
desc "build the examples"
task :examples => EXAMPLE_FILES
task :test => :examples
task :gem do
sh "gem build"
end
# vim: syntax=ruby