token dump

This commit is contained in:
bronku 2025-11-20 13:09:53 +01:00
parent fd2d08fb24
commit 660306f6a5
3 changed files with 34 additions and 2 deletions

View file

@ -1,14 +1,44 @@
#include "../build/parser.hpp"
#include "../build/lexer.hpp"
#include "../src/config.hpp"
#include "../src/ParserCtx.hpp"
#include <iostream>
#include <fstream>
yy::Parser::symbol_type yylex(yyscan_t yyscanner, yy::location &loc);
void dump_tokens(Elite::ParserCtx &ctx)
{
while (true)
{
auto tok = yylex(ctx.lexer, *ctx.loc);
std::cout
<< "Token: "
<< yy::Parser::symbol_name(tok.kind())
<< ", Location: " << tok.location
<< '\n';
if (tok.kind() == yy::Parser::token::END)
break;
}
}
int main(int argc, char *argv[])
{
Elite::ParserCtx ctx;
Configuration config(argc, argv);
if (!config.valid)
{
std::cout << "Please provide a valid configuration\n";
return -1;
}
Elite::ParserCtx ctx;
if (config.debug_lexer)
{
dump_tokens(ctx);
return 0;
}
return ctx.parser->parse();
}