You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
943 B

require "net/http"
require "uri"
version ="VERSION").strip
file "lib/pegjs-runtime-#{version}.min.js" => "lib/runtime.js" do |t|
response = Net::HTTP.post_form(
"js_code" =>,
"compilation_level" => "SIMPLE_OPTIMIZATIONS",
"output_format" => "text",
"output_info" => "compiled_code"
if response.code != "200"
abort "Error calling Google Closure Compiler API: #{response.message}"
end, "w") { |f| f.write(response.body) }
file "lib/metagrammar.js" => "lib/metagrammar.pegjs" do |t|
system "bin/pegjs --start-rule grammar PEG.grammarParser lib/metagrammar.pegjs"
desc "Build the minified parser runtime"
task :minify => "lib/pegjs-runtime-#{version}.min.js"
desc "Generate the grammar parser"
task :metaparser => "lib/metagrammar.js"