Skip to content

Commit

Permalink
Merge pull request #61 from funny-falcon/some_simplifications
Browse files Browse the repository at this point in the history
Simplify generated code
  • Loading branch information
evanphx authored Aug 14, 2023
2 parents 07e3dc1 + 0c3d2fd commit 01fb95d
Show file tree
Hide file tree
Showing 15 changed files with 5,312 additions and 4,439 deletions.
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

0 comments on commit 01fb95d

Please sign in to comment.