parser: don’t exit(1) on invalid command, use better error message

This commit is contained in:
Michael Stapelberg 2010-11-12 20:22:55 +01:00
parent 0e264cb5c4
commit e07fee4472
2 changed files with 6 additions and 8 deletions

View File

@ -49,8 +49,7 @@ static char *json_output;
void cmdyyerror(const char *error_message) {
ELOG("\n");
ELOG("CMD: %s\n", error_message);
ELOG("CMD: in file \"%s\", line %d:\n",
context->filename, context->line_number);
ELOG("CMD: in command:\n");
ELOG("CMD: %s\n", context->line_copy);
ELOG("CMD: ");
for (int c = 1; c <= context->last_column; c++)
@ -66,9 +65,6 @@ int cmdyywrap() {
}
char *parse_cmd(const char *new) {
//const char *new = "[level-up workspace] attach $output, focus";
cmdyy_scan_string(new);
match_init(&current_match);
@ -76,8 +72,10 @@ char *parse_cmd(const char *new) {
context->filename = "cmd";
FREE(json_output);
if (cmdyyparse() != 0) {
fprintf(stderr, "Could not parse configfile\n");
exit(1);
fprintf(stderr, "Could not parse command\n");
FREE(context->line_copy);
free(context);
return;
}
printf("done, json output = %s\n", json_output);

View File

@ -1,5 +1,5 @@
test:
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1)" -It/lib t/*.t
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1)" -It/lib t/34*.t
all: test