bux API Reference 1.9.0
Static library of whatever are seen required in general purpose but not directly supported from Modern C++. Or whatever reusable originated from my side projects.
Loading...
Searching...
No Matches
parsergen/example/MinLang/main.cpp
#include "Parser.h" // C_Parser, errors
#include "Scanner.h" // C_Scanner
//-------------------------------------------------------------
#include "bux/StrUtil.h" // HRTN()
#include "bux/MemIn.h" // bux::C_IMemStream<>
#include <iostream> // std::cin, std::cerr
int main()
{
std::string line;
while (std::getline(std::cin, line))
{
C_Parser parser;
C_Scanner scanner{parser};
try
{
bux::scanFile(">", in, scanner);
}
catch (const std::exception &e)
{
std::cerr <<HRTN(e) <<": " <<e.what() <<"\n"
"Fail to parse!\n";
continue;
}
// Acceptance
if (parser.accepted())
break;
std::cerr <<"Incomplete expression!\n"; // Never reach here!
}
// Ok
std::cerr <<"Mission complete!\n";
}
#define HRTN(t)
Definition StrUtil.h:22
void scanFile(std::string_view filename, std::istream &in, I_Scanner< T_Char > &scanner, T_LexID endToken=TID_EOF, T_Encoding encoding=0)