#include #include "parser.hpp" #include int main() { elna::source::driver driver{ "-" }; std::istringstream inp(R"( const world = 5, hello = 7; var x: int, y: boolean; proc f(); begin x := 8 end; begin while false do inc(5) end. )"); elna::source::lexer lexer(inp); yy::parser parser(lexer, driver); if (auto result = parser()) { for (const auto& error : driver.errors()) { std::cerr << error->path().string() << ':' << error->line() << ':' << error->column() << ": error: " << error->what() << '.' << std::endl; } return result; } for (auto& definition : driver.tree->definitions()) { if (auto const_definition = dynamic_cast(definition.get())) { std::cout << "const " << const_definition->identifier() << " = " << const_definition->body().number() << std::endl; } else if (auto proc_definition = dynamic_cast(definition.get())) { std::cout << "const " << proc_definition->identifier() << "()" << std::endl; } } return 0; }