bison-desc.xml 1.7 KB

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