-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (41 loc) · 1.62 KB
/
main.cpp
File metadata and controls
49 lines (41 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <string>
#include "Lex.h"
#include "Scanner.h"
#include "Interpretator.h"
using namespace std;
//Таблица служебных слов
const char *
Scanner::TW [] = { "", "and", "begin", "boolean", "do", "else", "end", "if", "false", "integer", "not", "or", "program",
"read", "then", "true", "var", "while", "write", "procedure", "function", "array", "of", NULL };
//Таблица разделителей
const char *
Scanner::TD [] = {".", ";", ",", ":", ":=", "(", ")", "=", "<", ">", "+", "-", "*", "/", "<=", "!=", ">=", "[", "]", NULL };
/*==========================================================================
*----------------------------------Main------------------------------------
*==========================================================================
* Запуск интерпретации, вывод сообщений об ошибке
*==========================================================================
*/
int main () {
try {
Interpretator I ( "C:\\Users\\ivr0m\\CLionProjects\\pascal\\prog.txt" );
I.interpretation ();
return 0;
}
//лексическая ошибка
catch ( char c ) {
cout << "unexpected symbol " << c << endl;
return 1;
}
//синтаксическая ошибка
catch ( Lex l ) {
cout << "unexpected lexeme" << l << endl;
return 1;
}
//семантическая ошибка, ошибка выполнения
catch ( const char *source ) {
cout << source << endl;
return 1;
}
}