home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / compcomp / os2yacc / example.y < prev    next >
Encoding:
Text File  |  1983-12-31  |  2.1 KB  |  122 lines

  1.  
  2.  %term ONE
  3.  %term TWO
  4.  %term THREE
  5.  %term FOUR
  6.  %term FIVE
  7.  %term SIX
  8.  %term SEVEN
  9.  %term EIGHT
  10.  %term NINE
  11.  %term DOT
  12. %%
  13. number    :front =
  14. {       float _L1L_;
  15. { _L1L_ = (float) _ap [0]._t1;
  16.  
  17.                     _ap += 1; 
  18. --_ap; _ap[0]._t0 = _L1L_;
  19.   }
  20. }
  21.              |front DOT back =
  22. {       float _L1L_;
  23. { _L1L_ = (float) _ap [2]._t1 + _ap [0]._t0;
  24.  
  25.                     _ap += 3; 
  26. --_ap; _ap[0]._t0 = _L1L_;
  27.   }
  28. };
  29. front    :id 
  30.              |front id =
  31. {       int _L1L_;
  32. { _L1L_ = 10 * _ap [1]._t1 + _ap [0]._t1;
  33.  
  34.                     _ap += 2; 
  35. --_ap; _ap[0]._t1 = _L1L_;
  36.   }
  37. };
  38. back    :zero_th_digit fd 
  39.              |back inc_dig_pos fd =
  40. {       int _L1L_;
  41.        float _L2L_;
  42. { _L2L_ = _ap [2]._t0 + _ap [0]._t0;
  43.  
  44.                     _ap += 4; 
  45. --_ap; _ap[0]._t1 = _L1L_;
  46. --_ap; _ap[0]._t0 = _L2L_;
  47.   }
  48. };
  49. fd    :id =
  50. {       float _L1L_;
  51. { _L1L_ = ( (float) _ap [0]._t1) / (power (10, _ap [1]._t1));
  52.  
  53.                     _ap += 1; 
  54. --_ap; _ap[0]._t0 = _L1L_;
  55.   }
  56. };
  57. zero_th_digit    :=
  58. {     _ap -= 1;
  59. { _ap [0]._t1 = 1;
  60.  
  61.                 }
  62. };
  63. inc_dig_pos    :=
  64. {     _ap -= 1;
  65. { _ap [0]._t1 = _ap [2]._t1 + 1;
  66.  
  67.                 }
  68. };
  69. id    :ONE =
  70. {     _ap -= 1;
  71. { _ap [0]._t1 = 1;
  72.  
  73.                 }
  74. }
  75.              |TWO =
  76. {     _ap -= 1;
  77. { _ap [0]._t1 = 2;
  78.  
  79.                 }
  80. }
  81.              |THREE =
  82. {     _ap -= 1;
  83. { _ap [0]._t1 = 3;
  84.  
  85.                 }
  86. }
  87.              |FOUR =
  88. {     _ap -= 1;
  89. { _ap [0]._t1 = 4;
  90.  
  91.                 }
  92. }
  93.              |FIVE =
  94. {     _ap -= 1;
  95. { _ap [0]._t1 = 5;
  96.  
  97.                 }
  98. }
  99.              |SIX =
  100. {     _ap -= 1;
  101. { _ap [0]._t1 = 6;
  102.  
  103.                 }
  104. }
  105.              |SEVEN =
  106. {     _ap -= 1;
  107. { _ap [0]._t1 = 7;
  108.  
  109.                 }
  110. }
  111.              |EIGHT =
  112. {     _ap -= 1;
  113. { _ap [0]._t1 = 8;
  114.  
  115.                 }
  116. }
  117.              |NINE =
  118. {     _ap -= 1;
  119. { _ap [0]._t1 = 9;
  120.  
  121.                 }
  122. };
  123.  
  124. %%
  125.  
  126.  
  127.  
  128. #ifndef ATT_SIZE
  129. #define ATT_SIZE     150
  130. #endif
  131.  
  132. union _attr_elem {
  133.   float  _t0;
  134.   int  _t1;
  135. } _attr_stack [ATT_SIZE];
  136. union _attr_elem *_ap =      &_attr_stack [ATT_SIZE - 1];
  137.  
  138.  /* processed by a YACC preprocessor */ 
  139.