This is an example of how to use IDL_FrontEnd class.
#ifndef NIDLFE_EXAMPLE_IDL_PRINT_H_
#define NIDLFE_EXAMPLE_IDL_PRINT_H_
#if __cplusplus < 201703L && _MSVC_LANG < 201703L
#error C++17 compliant compiler is required.
#endif
#include <filesystem>
{
public:
IDL_Print () :
{}
private:
private:
std::filesystem::path out_dir_;
};
#endif
Abstract Syntax Tree root.
IDL_FrontEnd(unsigned flags=0, std::ostream &err_out=std::cerr)
Constructor.
virtual void generate_code(const AST::Root &tree)=0
Generate user code from AST.
virtual void print_usage_info(const char *exe_name)
Prints usage information to std::cout.
static const unsigned FLAG_ENABLE_CONST_OBJREF
Allow Nirvana const interface references.
virtual bool parse_command_line(CmdLine &args)
Parse command line parameter.
#include "IDL_Print.h"
#include "Printer.h"
#include <iostream>
using namespace std;
using namespace std::filesystem;
void IDL_Print::print_usage_info (const char* exe_name)
{
cout << "Compile and print IDL.\n";
cout << "Output options:\n"
"\t-d directory\tDirectory for output files.\n";
}
bool IDL_Print::parse_command_line (CmdLine& args)
{
return true;
if (args.arg () [1] == 'd') {
out_dir_ = args.parameter (args.arg () + 2);
assert (!out_dir_.empty ());
args.next ();
return true;
}
return false;
}
void IDL_Print::generate_code (
const AST::Root& tree)
{
path file = out_dir_ / tree.
file ().filename ();
file.replace_extension (".txt");
Printer printer (file);
if (tree.
visit (printer))
cerr << "Warning, some unsupported Building Blocks were ignored.\n";
}
const std::filesystem::path & file() const noexcept
bool visit(CodeGen &cg) const
Visit all items for the code generation.