bison-desc.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <sect2><title>Contents of Bison</title>
  2. <para>Last checked against version &bison-contversion;.</para>
  3. <sect3><title>Program Files</title>
  4. <para>bison and yacc</para></sect3>
  5. <sect3><title>Descriptions</title>
  6. <sect4><title>bison</title>
  7. <para>bison is a parser generator, a replacement for yacc. yacc stands for Yet
  8. Another Compiler Compiler. What is bison then? It is a program that
  9. generates a program that analyzes the structure of a text file. Instead of
  10. writing the actual program a user specifies how things should be connected
  11. and with those rules a program is constructed that analyzes the
  12. text file. There are a lot of examples where structure is needed and
  13. one of them is the calculator.</para>
  14. <para>Given the string :</para>
  15. <blockquote><literallayout> 1 + 2 * 3</literallayout></blockquote>
  16. <para>A human can easily come to the result 7. Why? Because of the structure.
  17. Our brain knows
  18. how to interpret the string. The computer doesn't know that and bison is a
  19. tool to help it understand by presenting the string in the following way
  20. to the compiler:</para>
  21. <blockquote><literallayout> +
  22. / \
  23. * 1
  24. / \
  25. 2 3</literallayout></blockquote>
  26. <para>Starting at the bottom of a tree and coming across the numbers 2 and
  27. 3 which are joined by the multiplication symbol, the computer
  28. multiplies 2 and 3. The result of that multiplication is remembered and
  29. the next thing that the computer sees is the result of 2*3 and the
  30. number 1 which are joined by the add symbol. Adding 1 to the previous
  31. result makes 7. In calculating, the most complex calculations can be
  32. broken down in this tree format and the computer just starts at the
  33. bottom and works its way up to the top and comes with the correct
  34. answer. Of course, bison isn't only used for calculators
  35. alone.</para></sect4>
  36. <sect4><title>yacc</title>
  37. <para>We create a bash script called yacc which calls bison using the -y
  38. option. This is for compatibility purposes for programs which use yacc
  39. instead of bison.</para></sect4>
  40. </sect3>
  41. </sect2>