/
thomas-king
/
Interpretator
Обзор
Документация
Войти
/
thomas-king
/
Interpretator
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
main.cpp
34 строки
725 B
AceRodstin
Add error handling
28 ноя 2022, 12:48
28 ноя 2022, 12:48
caccb3e
Код
Авторство
О чём код?
// // Created by Ace Rodstin on 25 Nov 2022. // #include <iostream> #include "include/Lexer/Parser.h" #include "include/Interpretator/Interpretator.h" #include "include/Expression/Parser.h" using namespace std; int main() { string expression = "1 / 0"; Lexer::Parser lexer_parser; auto tokens = lexer_parser.parse(expression); Expression::Parser expression_parser; auto tree = expression_parser.parse(tokens); try { Interpretator interpretator; auto result = interpretator.calculate(tree); cout << result << endl; } catch (Interpretator::Error &error) { switch (error.reason) { case Interpretator::Error::Reason::division_by_zero: cout << "Error code: 1." << endl; break; } } return 0; }