Skip to content

Commit

Permalink
adding help option
Browse files Browse the repository at this point in the history
  • Loading branch information
0culus committed Aug 18, 2016
1 parent 984182a commit 218789c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <optimize/optimizer.h>
#include <parse/parser.h>

void dump_help(const char **argv);
void dump_tokens(bf::lex::lexer& l);
void dump_commands(const bf::prog::program& p);

Expand Down Expand Up @@ -42,14 +43,20 @@ int main(int argc, const char* argv[]) {
outfile = argv[i + 1];
++i;
}
else if (std::strcmp(arg, "-h") == 0) {
dump_help(argv);
return 1;
}
else {
std::cerr << "unexpected argument: " << arg << '\n';
dump_help(argv);
return 1;
}
}

if (!filename) {
std::cerr << "no input\n";
dump_help(argv);
return 1;
}

Expand Down Expand Up @@ -99,6 +106,11 @@ int main(int argc, const char* argv[]) {
}
}

void dump_help(const char **argv) {
std::cerr << "Usage: " << argv[0] << " [--dump-tokens] [--dump-commands] [--optimize] [-o outfile] [-h help]"
<< " brainfuck_file" << std::endl;
}

void dump_tokens(bf::lex::lexer& l) {
auto tok = l.next_token();

Expand Down

0 comments on commit 218789c

Please sign in to comment.