46 lines
No EOL
951 B
C++
46 lines
No EOL
951 B
C++
#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::symbol_kind::S_YYEOF)
|
|
{
|
|
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;
|
|
}
|
|
|
|
if (config.debug_lexer)
|
|
{
|
|
dump_tokens(ctx);
|
|
return 0;
|
|
}
|
|
|
|
return ctx.parser->parse();
|
|
} |