mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2025-01-13 21:34:16 +00:00
parse | pipe lines.
This commit is contained in:
parent
2fdca6ea9d
commit
0524d10590
11
command.cpp
11
command.cpp
@ -372,7 +372,7 @@ int break_command::execute(Environment &env, const fdmask &fds, bool throwup) {
|
||||
|
||||
env.echo("%s", s.c_str());
|
||||
if (!env.loop()) {
|
||||
fputs("MPW Shell - Break must be within for or loop.\n", stderr);
|
||||
fputs("### MPW Shell - Break must be within for or loop.\n", stderr);
|
||||
return env.status(-3, throwup);
|
||||
}
|
||||
|
||||
@ -394,7 +394,7 @@ int continue_command::execute(Environment &env, const fdmask &fds, bool throwup)
|
||||
|
||||
env.echo("%s", s.c_str());
|
||||
if (!env.loop()) {
|
||||
fputs("MPW Shell - Continue must be within for or loop.\n", stderr);
|
||||
fputs("### MPW Shell - Continue must be within for or loop.\n", stderr);
|
||||
return env.status(-3, throwup);
|
||||
}
|
||||
|
||||
@ -433,6 +433,13 @@ int and_command::execute(Environment &e, const fdmask &fds, bool throwup) {
|
||||
}
|
||||
|
||||
|
||||
int pipe_command::execute(Environment &e, const fdmask &fds, bool throwup) {
|
||||
// not yet supported!
|
||||
fputs( "### MPW Shell - Pipes are not yet supported.\n", stderr);
|
||||
return e.status(1, throwup);
|
||||
}
|
||||
|
||||
|
||||
int vector_command::execute(Environment &e, const fdmask &fds, bool throwup) {
|
||||
|
||||
int rv = 0;
|
||||
|
@ -114,15 +114,13 @@ struct and_command : public binary_command {
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
struct pipe_command : public binary_command {
|
||||
and_command(command_ptr &&a, command_ptr &&b) :
|
||||
pipe_command(command_ptr &&a, command_ptr &&b) :
|
||||
binary_command(PIPE, std::move(a), std::move(b))
|
||||
{}
|
||||
|
||||
virtual int execute(Environment &e) final override;
|
||||
virtual int execute(Environment &e, const fdmask &fds, bool throwup) final override;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct vector_command : public command {
|
||||
|
@ -29,6 +29,9 @@ bool phase2_parser::continuation() const {
|
||||
if (e.major == PIPE_PIPE) return true;
|
||||
if (e.major == LOOP) return true;
|
||||
if (e.major == FOR) return true;
|
||||
if (e.major == PIPE) return true;
|
||||
if (e.major == PIPE_PIPE) return true;
|
||||
if (e.major == AMP_AMP) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -92,11 +95,9 @@ command(RV) ::= command(L) AMP_AMP opt_nl command(R). {
|
||||
RV = std::make_unique<and_command>(std::move(L), std::move(R));
|
||||
}
|
||||
|
||||
/*
|
||||
command(RV) ::= command PIPE opt_nl command. {
|
||||
command(RV) ::= command(L) PIPE opt_nl command(R). {
|
||||
RV = std::make_unique<pipe_command>(std::move(L), std::move(R));
|
||||
}
|
||||
*/
|
||||
|
||||
command(RV) ::= term(T). { RV = std::move(T); }
|
||||
|
||||
|
21
phase2.rl
21
phase2.rl
@ -42,6 +42,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
action parse_pipe_any {
|
||||
if (!special()) {
|
||||
scratch.pop_back();
|
||||
flush();
|
||||
parse(PIPE, "|");
|
||||
}
|
||||
fhold;
|
||||
fgoto main;
|
||||
}
|
||||
|
||||
action parse_pipe_eof {
|
||||
|
||||
if (!special()) {
|
||||
scratch.pop_back();
|
||||
flush();
|
||||
parse(PIPE, "|");
|
||||
}
|
||||
}
|
||||
|
||||
action parse_lparen {
|
||||
if (scratch.empty()) {
|
||||
parse(LPAREN, "(");
|
||||
@ -88,6 +107,8 @@
|
||||
| ';' $parse_semi
|
||||
| '(' $parse_lparen
|
||||
| ')' $parse_rparen
|
||||
| '|' <eof(parse_pipe_eof)
|
||||
| '|' [^|] $parse_pipe_any
|
||||
| '|' '|' $parse_pipe_pipe
|
||||
| '&' '&' $parse_amp_amp
|
||||
| escape_seq
|
||||
|
Loading…
x
Reference in New Issue
Block a user