Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify generated code #61

Merged
merged 3 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,39 @@ 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.map do |parser_file|
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
Expand Down
Loading
Loading