{
vector<page *> out;
for (auto pb: pipe->branches)
- for (auto ps: pb->selectors)
- {
- int f = validate_page_index(pages, ps.from);
- int t = validate_page_index(pages, ps.to);
- int step = (f <= t) ? 1 : -1;
- for (int i=f; f<=t; f += step)
- {
- vector<page *> selected;
+ {
+ vector<page *> selected;
+ for (auto ps: pb->selectors)
+ {
+ int f = validate_page_index(pages, ps.from);
+ int t = validate_page_index(pages, ps.to);
+ int step = (f <= t) ? 1 : -1;
+ for (int i=f; f<=t; f += step)
selected.push_back(pages[i]);
- selected = run_command_list(pb->commands, selected);
- for (auto p: selected)
- out.push_back(p);
- }
- }
+ }
+ auto processed = run_command_list(pb->commands, selected);
+ for (auto p: processed)
+ out.push_back(p);
+ }
return out;
}
pipeline_branch *pb = new pipeline_branch;
pp->branches.push_back(pb);
+ token_type t;
for (;;)
{
- token_type t = next_token();
- if (t == TOK_CLOSE_BRACE || t == TOK_END)
- parse_error("Premature end of pipeline");
- if (t == TOK_COLON)
+ t = next_token();
+ if (t == TOK_END)
+ parse_error("Missing close brace");
+ if (t == TOK_CLOSE_BRACE || t == TOK_COLON || t == TOK_COMMA)
break;
- if (pb->selectors.size())
- {
- if (t != TOK_COMMA)
- parse_error("Invalid pipeline selector");
- t = next_token();
- if (t == TOK_CLOSE_BRACE || t == TOK_END)
- parse_error("Premature end of pipeline");
- }
-
pipeline_selector ps;
if (t != TOK_NUMBER)
parse_error("Pipeline selectors must start with a number");
pb->selectors.push_back(ps);
}
- parse_commands(pb->commands);
+ if (t == TOK_COLON)
+ parse_commands(pb->commands);
+ else
+ return_token();
}
c->pipe = pp;