homebrew-core/Formula/antlr.rb
Alykhan Kanji 0c8a2baaa0 antlr: switch to sha256
Closes Homebrew/homebrew#42067.

Signed-off-by: Alex Dunn <dunn.alex@gmail.com>
2015-07-23 18:06:56 -07:00

35 lines
1.1 KiB
Ruby

class Antlr < Formula
desc "ANTLR: ANother Tool for Language Recognition"
homepage "http://www.antlr.org/"
url "http://www.antlr.org/download/antlr-4.5-complete.jar"
sha256 "4a4ebb20c3c09bf5700af78080afadec0879e425cba4695fd21a1084fc171f2c"
def install
prefix.install "antlr-#{version}-complete.jar"
bin.write_jar_script prefix/"antlr-#{version}-complete.jar", "antlr4"
(bin+"grun").write <<-EOS.undent
#!/bin/bash
java -classpath #{prefix}/antlr-#{version}-complete.jar:. org.antlr.v4.runtime.misc.TestRig "$@"
EOS
end
test do
path = testpath/"Expr.g4"
path.write <<-EOS.undent
grammar Expr;
prog:\t(expr NEWLINE)* ;
expr:\texpr ('*'|'/') expr
|\texpr ('+'|'-') expr
|\tINT
|\t'(' expr ')'
;
NEWLINE :\t[\\r\\n]+ ;
INT :\t[0-9]+ ;
EOS
ENV.prepend "CLASSPATH", "#{prefix}/antlr-#{version}-complete.jar", ":"
ENV.prepend "CLASSPATH", ".", ":"
system "#{bin}/antlr4", "Expr.g4"
system "javac", *Dir["Expr*.java"]
assert_match(/^$/, pipe_output("#{bin}/grun Expr prog", "22+20\n"))
end
end