20void usage(std::ostream &out,
const char *name)
22 out <<
"Performs semantic analysis of the input.\n"
23 <<
"USAGE:\n\t" << name <<
" [<FILE>...]"
27int main(
int argc,
const char **argv)
31#define ADD(TYPE, VAR, INIT, SHORT, LONG, DESCR, CALLBACK)\
34 AP.add<TYPE>(SHORT, LONG, DESCR, CALLBACK);\
38 "prints this help message",
56 usage(std::cout, argv[0]);
57 std::cout <<
"WHERE\n" << AP;
58 std::exit(EXIT_SUCCESS);
70 bool sema_error =
false;
74 for (
auto filename :
args) {
75 if (
streq(filename,
"-")) {
80 in =
new std::ifstream(filename, std::ios_base::in);
85 std::cerr <<
"Failed to open stdin: ";
87 std::cerr <<
"Failed to open the file '" << filename <<
"': ";
88 std::cerr << strerror(errno) << std::endl;
95 while (parser.
token()) {
101 auto cmd = sema.
analyze(std::move(stmt));
108 if (is<const DDLCommand>(cmd))
116 std::exit(sema_error ? EXIT_FAILURE : EXIT_SUCCESS);
bool show_help
whether to show a help message
void usage(std::ostream &out, const char *name)
#define ADD(TYPE, VAR, INIT, SHORT, LONG, DESCR, CALLBACK)
A parser for command line arguments.
void parse_args(int argc, const char **argv)
Parses the arguments from argv.
const std::vector< const char * > & args() const
Returns all positional arguments.
bool streq(const char *first, const char *second)
The catalog contains all Databases and keeps track of all meta information of the database system.
ThreadSafeStringPool & get_pool()
Returns a reference to the StringPool.
static Catalog & Get()
Return a reference to the single Catalog instance.
void clear()
Resets the error counter.
unsigned num_errors() const
Returns the number of errors emitted since the last call to clear().
static Options & Get()
Return a reference to the single Options instance.
std::unique_ptr< Stmt > parse_Stmt()
std::unique_ptr< DatabaseCommand > analyze(std::unique_ptr< ast::Command > ast)
Perform semantic analysis of an ast::Command.