mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-12-28 09:29:57 +00:00
ERROR terminal for parser.
This commit is contained in:
parent
6d929aa87f
commit
31f33096cb
@ -446,6 +446,11 @@ int error_command::execute(Environment &e, const fdmask &fds, bool throwup) {
|
||||
|
||||
if (control_c) throw execution_of_input_terminated();
|
||||
|
||||
if (type == ERROR) {
|
||||
fprintf(stderr, "%s\n", text.c_str());
|
||||
return e.status(-3);
|
||||
}
|
||||
|
||||
std::string s = expand_vars(text, e);
|
||||
|
||||
e.echo("%s", s.c_str());
|
||||
|
@ -22,7 +22,7 @@ struct command {
|
||||
{}
|
||||
|
||||
virtual bool terminal() const noexcept {
|
||||
return type == EVALUATE || type == COMMAND || type == BREAK || type == CONTINUE;
|
||||
return type == EVALUATE || type == COMMAND || type == BREAK || type == CONTINUE || type == ERROR;
|
||||
}
|
||||
|
||||
int type = 0;
|
||||
|
@ -110,15 +110,20 @@ term(RV) ::= paren_command(C). { RV = std::move(C); }
|
||||
term(RV) ::= loop_command(C). { RV = std::move(C); }
|
||||
term(RV) ::= for_command(C). { RV = std::move(C); }
|
||||
|
||||
|
||||
/* lexer error (mismatched quotes, etc) */
|
||||
term(RV) ::= ERROR(C). {
|
||||
RV = std::make_unique<error_command>(@C, std::move(C));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fall back to an end error. w/o fallback, it will cause a parse conflict.
|
||||
*/
|
||||
/*
|
||||
%fallback ERROR END RPAREN ELSE ELSE_IF.
|
||||
|
||||
term(RV) ::= ERROR(C). {
|
||||
RV = std::make_unique<error_command>(@C, std::move(C));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user