aLT22

3semlab3 BETA VERS

Dec 24th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int lexical_class, num; // В lexical_class мы присваиваем функцию getLC
  7. const int OBR = 1, CBR = 2, MINUS = 3, PLUS = 4, VOSKL = 5, RAVNO = 6, MORE = 7, LESS = 8, DOUBLEDOT = 9, LETTER = 10, DIGIT = 11, DC = 12;
  8. // const int OBR = 1, CBR = 2, MINUS = 3, PLUS = 4, DOT = 5, SLASH = 6, MULTIPLICATION = 7, LETTER = 8, DIGIT = 9, DOUBLEDOT = 10, RAVNO = 11; в примере марины
  9.  
  10. void ERROR(char ch, int lc);
  11. void S();
  12. void E();
  13. void T();
  14. void M();
  15. void I();
  16. void C();
  17. bool A();
  18. bool D();
  19. void nextStep(int lc); // Смотрит, если
  20. int getLC(); // Возвращает текущий терминал, а если она не находит терминалы, то она возвращает ошибку
  21.  
  22. ifstream fin ("input.txt");
  23. ofstream fout ("output.txt");
  24.  
  25. int main()
  26. {
  27.     // possible functions:
  28.     /*int getLC();
  29.     void nextStep(int lc);
  30.     void error (char ch);
  31.     void S();
  32.     void E();
  33.     void T();
  34.     void M();
  35.     void I();
  36.     void С();
  37.     bool A();
  38.     bool D();
  39.     */
  40. }
  41.  
  42. void nextStep(int lc)
  43. {
  44.     if (lc == lexical_class)
  45.     {
  46.         lexical_class= getLC();
  47.     }
  48.     else
  49.     {
  50.         ERROR('N', lc);
  51.     }
  52. }
  53.  
  54. void S()
  55. {
  56.     I();
  57.     nextStep(DOUBLEDOT);
  58.     nextStep(RAVNO);
  59.     E();
  60.     nextStep(DC);
  61. }
  62.  
  63. void E()
  64. {
  65.     T();
  66.     if (lexical_class == '>' || lexical_class == '<' || lexical_class == '=')
  67.     {
  68.         T();
  69.     }
  70. }
  71.  
  72. bool D()
  73. {
  74.     return (lexical_class == '0' || lexical_class == '1');
  75. }
  76.  
  77. bool A()
  78. {
  79.     return (lexical_class >= 'a' && lexical_class <= 'z');
  80. }
  81.  
  82. void M()
  83. {
  84.     switch (lexical_class)
  85.     {
  86.     case VOSKL:
  87.         lexical_class = getLC();
  88.         M();
  89.         break;
  90.     case OBR:
  91.         lexical_class = getLC();
  92.         E();
  93.         nextStep(CBR);
  94.         break;
  95.     case LETTER:
  96.  
  97.     case DIGIT:
  98.  
  99.     }
  100. }
  101.  
  102. void I()
  103. {
  104.     A();
  105.     if (lexical_class == DIGIT)
  106.     {
  107.         D();
  108.         break;
  109.     }
  110.     if
  111. }
Advertisement
Add Comment
Please, Sign In to add comment