Skip to content

Instantly share code, notes, and snippets.

@Tyrael
Last active August 29, 2015 14:24
Show Gist options
  • Save Tyrael/ff27e95a218f92da2b87 to your computer and use it in GitHub Desktop.
Save Tyrael/ff27e95a218f92da2b87 to your computer and use it in GitHub Desktop.
class Flex < Formula
desc "Fast Lexical Analyzer, generates Scanners (tokenizers)"
homepage "http://flex.sourceforge.net"
url "https://ftp.gnu.org/old-gnu/gnu-0.2/src/flex-2.5.4.tar.gz"
sha1 "308b912c41f68504f1256e57218bde266fc07c57"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment