simpliest c++ example

This commit is contained in:
bronku 2025-11-20 16:35:10 +01:00
parent d587646b32
commit 909a43114b
9 changed files with 73 additions and 221 deletions

View file

@ -1,41 +1,7 @@
#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(ParserCtx &ctx)
int main()
{
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[])
{
ParserCtx ctx;
Configuration config(argc, argv);
if (config.debug_lexer)
{
dump_tokens(ctx);
return 0;
}
return ctx.parser->parse();
yy::parser p;
return p.parse();
}