Sha256: 4ba334c373393c10f23983f9d1df00b6eb840c3f3c3ba938cb4c2195fd8aa387
Contents?: true
Size: 1.71 KB
Versions: 4
Compression:
Stored size: 1.71 KB
Contents
require "java/java" module Buildr # Provides ANTLR grammar generation tasks. Require explicitly using <code>require "buildr/antlr"</code>. module ANTLR REQUIRES = [ "org.antlr:antlr:jar:3.0", "antlr:antlr:jar:2.7.7", "org.antlr:stringtemplate:jar:3.0" ] Java.wrapper.classpath << REQUIRES class << self def antlr(*args) options = Hash === args.last ? args.pop : {} rake_check_options options, :output, :token args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.g"] : f }.flatten args = ["-o", options[:output]] + args if options[:output] if options[:token] # antlr expects the token directory to exist when it starts mkdir_p options[:token] args = ["-lib", options[:token]] + args end Java.wrapper do |wrapper| antlr_class = wrapper.import("org.antlr.Tool") antlr_tool = antlr_class.new_with_sig("[Ljava.lang.String;", args) antlr_tool.process #wrapper.import("org.antlr.Tool").main(args) == 0 or # fail "Failed to run ANTLR, see errors above." end end end def antlr(*args) if Hash === args.last options = args.pop in_package = options[:in_package].split(".") token = options[:token].split(".") if options[:token] else in_package = []; token = nil end file(path_to(:target, "generated/antlr")=>args.flatten) do |task| args = {:output=>File.join(task.name, in_package)} args.merge!({:token=>File.join(task.name, token)}) if token ANTLR.antlr task.prerequisites, args end end end class Project include ANTLR end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
buildr-1.2.10 | lib/buildr/antlr.rb |
buildr-1.2.7 | lib/buildr/antlr.rb |
buildr-1.2.9 | lib/buildr/antlr.rb |
buildr-1.2.8 | lib/buildr/antlr.rb |