-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Bison < Formula | ||
desc "Parser generator" | ||
homepage "https://www.gnu.org/software/bison/" | ||
# X.Y.9Z are beta releases that sometimes get accidentally uploaded to the release FTP | ||
url "https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz" | ||
mirror "https://ftpmirror.gnu.org/bison/bison-3.8.2.tar.xz" | ||
sha256 "9bba0214ccf7f1079c5d59210045227bcf619519840ebfa80cd3849cff5a5bf2" | ||
license "GPL-3.0-or-later" | ||
version_scheme 1 | ||
|
||
bottle do | ||
root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/bison-3.8.2" | ||
sha256 cellar: :any_skip_relocation, aarch64_linux: "2a0732c30f659e4581b2c6eefc5a2a0acf5596302f6be2982a8517a9b3863e22" | ||
end | ||
|
||
keg_only :provided_by_macos | ||
|
||
uses_from_macos "m4" | ||
|
||
def install | ||
system "./configure", "--disable-dependency-tracking", | ||
"--enable-relocatable", | ||
"--prefix=/output", | ||
"M4=m4" | ||
system "make", "install", "DESTDIR=#{buildpath}" | ||
prefix.install Dir["#{buildpath}/output/*"] | ||
end | ||
|
||
test do | ||
(testpath/"test.y").write <<~EOS | ||
%{ #include <iostream> | ||
using namespace std; | ||
extern void yyerror (char *s); | ||
extern int yylex (); | ||
%} | ||
%start prog | ||
%% | ||
prog: // empty | ||
| prog expr '\\n' { cout << "pass"; exit(0); } | ||
; | ||
expr: '(' ')' | ||
| '(' expr ')' | ||
| expr expr | ||
; | ||
%% | ||
char c; | ||
void yyerror (char *s) { cout << "fail"; exit(0); } | ||
int yylex () { cin.get(c); return c; } | ||
int main() { yyparse(); } | ||
EOS | ||
system bin/"bison", "test.y" | ||
system ENV.cxx, "test.tab.c", "-o", "test" | ||
assert_equal "pass", shell_output("echo \"((()(())))()\" | ./test") | ||
assert_equal "fail", shell_output("echo \"())\" | ./test") | ||
end | ||
end |