bison-desc.xml 2.0 KB

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