diff options
author | Teddy <[email protected]> | 2014-03-25 18:34:44 +0800 |
---|---|---|
committer | Teddy <[email protected]> | 2014-03-25 18:34:44 +0800 |
commit | 546a8dd1f1129bb74f6e07c1d22366ccf8506ad3 (patch) | |
tree | 027203836a90878ac0df6ce325ab5d7388b61071 | |
parent | 32cc498a2eb0b189cc90918dc28f8933b2f55278 (diff) |
user-friendly help message
-rw-r--r-- | main.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -14,6 +14,7 @@ int yywrap() { int yyerror(char *s) { fprintf(stderr, "%s\n", s); + return 0; } void print_ast() { @@ -30,6 +31,16 @@ void print_ast() { } void print_help() { + fprintf(stderr, + "CBIC -- C Implemented Bare and Ingenuous Compiler\n\n" + "Copyright (C) 2014 Ted Yin\n" + "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" + "There is NO WARRANTY, to the extent permitted by law.\n" + "Usage: [options] filename\n" + "Options:\n" + "\t --ast \t\t Print AST Construction\n" + "\t --help \t Show this info\n" + ); } static struct option lopts[] = { @@ -44,7 +55,7 @@ enum { } mode = PRINT_HELP; int main(int argc, char **argv) { - int option_index = 0, i; + int option_index = 0; while (1) { int c = getopt_long(argc, argv, "ah", lopts, &option_index); @@ -63,7 +74,7 @@ int main(int argc, char **argv) { yyin = fopen(fname, "r"); if (!yyin) { - fprintf(stderr, "Error while opening file."); + fprintf(stderr, "Error while opening file.\n"); return 1; } } |