Installing Bison-1.28

Estimated build time:           1 minute
Estimated required disk space:  3 MB

Installation of Bison

Install Bison by running the following commands:

./configure --prefix=/usr \
���--datadir=/usr/share/bison &&
make &&
make install

Some programs don't know about bison and try to find the yacc program (bison is a (better) alternative for yacc). So to please those few programs out there we'll create a yacc script that calls bison and have it emulate yacc's output file name conventions.

Create a new file /usr/bin/yacc by running the following:

cat > /usr/bin/yacc << "EOF"
#!/bin/sh
# Begin /usr/bin/yacc

exec /usr/bin/bison -y "$@"

# End /usr/bin/yacc
EOF
chmod 755 /usr/bin/yacc

Command explanations

--datadir=/usr/share/bison: This installs the bison grammar files in /usr/share/bison rather than /usr/share.

Contents

The Bison package contains the bison program.

Description

Bison is a parser generator, a replacement for YACC. YACC stands for Yet Another Compiler Compiler. What is Bison then? It is a program that generates a program that analyzes the structure of a text file. Instead of writing the actual program a user specifies how things should be connected and with those rules a program is constructed that analyzes the text file.

There are a lot of examples where structure is needed and one of them is the calculator.

Given the string :

        1 + 2 * 3

A human can easily come to the result 7. Why? Because of the structure. Our brain knows how to interpret the string. The computer doesn't know that and Bison is a tool to help it understand by presenting the string in the following way to the compiler:

            +
           / \
          *   1
         / \
        2   3

Starting at the bottom of a tree and coming across the numbers 2 and 3 which are joined by the multiplication symbol, the computer multiplies 2 and 3. The result of that multiplication is remembered and the next thing that the computer sees is the result of 2*3 and the number 1 which are joined by the add symbol. Adding 1 to the previous result makes 7. In calculating the most complex calculations can be broken down in this tree format and the computer just starts at the bottom and works its way up to the top and comes with the correct answer. Of course, Bison isn't only used for calculators alone.

Dependencies

Bison-1.28 needs the following to be installed:


sh from the bash package

ar from the binutils package
as from the binutils package
ld from the binutils package

cmp from the diffutils package

rm from the fileutils package
cp from the fileutils package
mkdir from the fileutils package
ls from the fileutils package
chmod from the fileutils package
mv from the fileutils package
ln from the fileutils package

cc from the gcc package

grep from the grep package

make from the make package

sed from the sed package

basename from the sh-utils package
expr from the sh-utils package
sleep from the sh-utils package

tr from the textutils package
cat from the textutils package