aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2014-03-25 18:34:44 +0800
committerTeddy <[email protected]>2014-03-25 18:34:44 +0800
commit546a8dd1f1129bb74f6e07c1d22366ccf8506ad3 (patch)
tree027203836a90878ac0df6ce325ab5d7388b61071
parent32cc498a2eb0b189cc90918dc28f8933b2f55278 (diff)
user-friendly help message
-rw-r--r--main.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/main.c b/main.c
index d82d911..45f3226 100644
--- a/main.c
+++ b/main.c
@@ -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;
}
}