parser: don’t exit(1) on invalid command, use better error message
This commit is contained in:
parent
0e264cb5c4
commit
e07fee4472
|
@ -49,8 +49,7 @@ static char *json_output;
|
||||||
void cmdyyerror(const char *error_message) {
|
void cmdyyerror(const char *error_message) {
|
||||||
ELOG("\n");
|
ELOG("\n");
|
||||||
ELOG("CMD: %s\n", error_message);
|
ELOG("CMD: %s\n", error_message);
|
||||||
ELOG("CMD: in file \"%s\", line %d:\n",
|
ELOG("CMD: in command:\n");
|
||||||
context->filename, context->line_number);
|
|
||||||
ELOG("CMD: %s\n", context->line_copy);
|
ELOG("CMD: %s\n", context->line_copy);
|
||||||
ELOG("CMD: ");
|
ELOG("CMD: ");
|
||||||
for (int c = 1; c <= context->last_column; c++)
|
for (int c = 1; c <= context->last_column; c++)
|
||||||
|
@ -66,9 +65,6 @@ int cmdyywrap() {
|
||||||
}
|
}
|
||||||
|
|
||||||
char *parse_cmd(const char *new) {
|
char *parse_cmd(const char *new) {
|
||||||
|
|
||||||
//const char *new = "[level-up workspace] attach $output, focus";
|
|
||||||
|
|
||||||
cmdyy_scan_string(new);
|
cmdyy_scan_string(new);
|
||||||
|
|
||||||
match_init(¤t_match);
|
match_init(¤t_match);
|
||||||
|
@ -76,8 +72,10 @@ char *parse_cmd(const char *new) {
|
||||||
context->filename = "cmd";
|
context->filename = "cmd";
|
||||||
FREE(json_output);
|
FREE(json_output);
|
||||||
if (cmdyyparse() != 0) {
|
if (cmdyyparse() != 0) {
|
||||||
fprintf(stderr, "Could not parse configfile\n");
|
fprintf(stderr, "Could not parse command\n");
|
||||||
exit(1);
|
FREE(context->line_copy);
|
||||||
|
free(context);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
printf("done, json output = %s\n", json_output);
|
printf("done, json output = %s\n", json_output);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
test:
|
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
|
all: test
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue