Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int lexical_class, num; // В lexical_class мы присваиваем функцию getLC
- 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;
- // const int OBR = 1, CBR = 2, MINUS = 3, PLUS = 4, DOT = 5, SLASH = 6, MULTIPLICATION = 7, LETTER = 8, DIGIT = 9, DOUBLEDOT = 10, RAVNO = 11; в примере марины
- void ERROR(char ch, int lc);
- void S();
- void E();
- void T();
- void M();
- void I();
- void C();
- bool A();
- bool D();
- void nextStep(int lc); // Смотрит, если
- int getLC(); // Возвращает текущий терминал, а если она не находит терминалы, то она возвращает ошибку
- ifstream fin ("input.txt");
- ofstream fout ("output.txt");
- int main()
- {
- // possible functions:
- /*int getLC();
- void nextStep(int lc);
- void error (char ch);
- void S();
- void E();
- void T();
- void M();
- void I();
- void С();
- bool A();
- bool D();
- */
- }
- void nextStep(int lc)
- {
- if (lc == lexical_class)
- {
- lexical_class= getLC();
- }
- else
- {
- ERROR('N', lc);
- }
- }
- void S()
- {
- I();
- nextStep(DOUBLEDOT);
- nextStep(RAVNO);
- E();
- nextStep(DC);
- }
- void E()
- {
- T();
- if (lexical_class == '>' || lexical_class == '<' || lexical_class == '=')
- {
- T();
- }
- }
- bool D()
- {
- return (lexical_class == '0' || lexical_class == '1');
- }
- bool A()
- {
- return (lexical_class >= 'a' && lexical_class <= 'z');
- }
- void M()
- {
- switch (lexical_class)
- {
- case VOSKL:
- lexical_class = getLC();
- M();
- break;
- case OBR:
- lexical_class = getLC();
- E();
- nextStep(CBR);
- break;
- case LETTER:
- case DIGIT:
- }
- }
- void I()
- {
- A();
- if (lexical_class == DIGIT)
- {
- D();
- break;
- }
- if
- }
Advertisement
Add Comment
Please, Sign In to add comment