elna/parser/main.cpp

23 lines
598 B
C++
Raw Normal View History

2024-07-07 18:50:15 +02:00
#include "parser.hpp"
#include <sstream>
int main()
{
std::istringstream inp("const world = 5, hello = 7;");
std::unique_ptr<elna::source::program> program;
elna::syntax::FooLexer lexer(inp);
yy::parser parser(lexer, program);
auto result = parser();
for (auto& definition : program->definitions())
{
auto const_definition = dynamic_cast<elna::source::constant_definition *>(definition.get());
std::cout << "const " << const_definition->identifier() << " = "
<< const_definition->body().number() << std::endl;
}
return result;
}