Files
2023-08-20 18:33:18 -07:00

43 lines
1.2 KiB
Ruby

class Flex < Formula
desc "Fast Lexical Analyzer, generates Scanners (tokenizers)"
homepage "http://flex.sourceforge.net"
url "https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz"
sha256 "e87aae032bf07c26f85ac0ed3250998c37621d95f8bd748b31f15b33c45ee995"
bottle do
sha256 "81739615809b39fd54aa558c1a4f0a2677813f162459f7b6e63a99ad220d1488" => :tiger_altivec
end
keg_only :provided_by_osx, "Some formulae require a newer version of flex."
depends_on "gettext"
def install
system "./configure", "--disable-dependency-tracking",
"--disable-shared",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test.flex").write <<-EOS.undent
CHAR [a-z][A-Z]
%%
{CHAR}+ printf("%s", yytext);
[ \\t\\n]+ printf("\\n");
%%
int main()
{
yyin = stdin;
yylex();
}
EOS
system "#{bin}/flex", "test.flex"
system ENV.cc, "lex.yy.c", "-L#{lib}", "-lfl", "-o", "test"
assert_equal shell_output("echo \"Hello World\" | ./test"), <<-EOS.undent
Hello
World
EOS
end
end