2002-04-19 19:27:01 +01:00
|
|
|
<sect2><title>Contents of Bison-&bison-contversion;</title>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2002-02-06 23:15:46 +00:00
|
|
|
<sect3><title>Program Files</title>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2002-02-06 23:15:46 +00:00
|
|
|
<para>bison and yacc</para></sect3>
|
|
|
|
|
|
|
|
<sect3><title>Descriptions</title>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2002-02-06 23:15:46 +00:00
|
|
|
<sect4><title>bison</title>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>Bison is a parser generator, a replacement for YACC. YACC stands for Yet
|
2001-01-24 00:31:17 +00:00
|
|
|
Another Compiler Compiler. What is Bison then? It is a program that
|
2002-02-06 23:15:46 +00:00
|
|
|
generates a program that analyzes the structure of a text file. Instead of
|
2001-03-14 19:26:45 +00:00
|
|
|
writing the actual program a user specifies how things should be connected
|
2002-02-06 23:15:46 +00:00
|
|
|
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.</para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>Given the string :</para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<blockquote><literallayout> 1 + 2 * 3</literallayout></blockquote>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>A human can easily come to the result 7. Why? Because of the structure.
|
2001-03-20 08:33:53 +00:00
|
|
|
Our brain knows
|
2001-04-08 03:35:02 +01:00
|
|
|
how to interpret the string. The computer doesn't know that and Bison
|
2001-01-24 00:31:17 +00:00
|
|
|
is a
|
|
|
|
tool to help it understand by presenting the string in the following way
|
2001-07-22 20:45:10 +01:00
|
|
|
to the compiler:</para>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<blockquote><literallayout> +
|
2001-01-24 00:31:17 +00:00
|
|
|
/ \
|
|
|
|
* 1
|
|
|
|
/ \
|
2001-07-22 20:45:10 +01:00
|
|
|
2 3</literallayout></blockquote>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
2001-07-22 20:45:10 +01:00
|
|
|
<para>Starting at the bottom of a tree and coming across the numbers 2 and
|
2001-03-14 19:26:45 +00:00
|
|
|
3 which are joined by the multiplication symbol, the computer
|
2001-01-24 00:31:17 +00:00
|
|
|
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
|
2001-11-07 15:42:16 +00:00
|
|
|
bottom and works its way up to the top and comes with the correct
|
2002-02-06 23:15:46 +00:00
|
|
|
answer. Of course, Bison isn't only used for calculators
|
|
|
|
alone.</para></sect4>
|
|
|
|
|
|
|
|
<sect4><title>yacc</title>
|
|
|
|
|
|
|
|
<para>We create a yacc script which calls bison using the -y option.
|
|
|
|
This is for compatibility purposes for programs which use yacc instead
|
|
|
|
of bison.</para></sect4>
|
|
|
|
|
|
|
|
</sect3>
|
2001-01-24 00:31:17 +00:00
|
|
|
|
|
|
|
</sect2>
|
|
|
|
|