Snel
A shell implementation for A.U.TH (Operating Systems Lab)
snel::Sequencer Class Reference

#include <sequencer.h>

Public Member Functions

Sequencerparse (const std::string &input)
 
Sequencerexecute ()
 

Private Member Functions

bool is_seperator (std::string &s)
 separator trait predicate More...
 
bool is_pipe (std::string &s)
 pipe trait predicate
 

Private Attributes

std::vector< std::vector< Child > > seq_ {}
 The sequencer data representation.
 

Detailed Description

The main object to represent and handle a command flow.

We store commands as vector of vectors of commands. The inner vector represent a command chain. For example the line:

ls | more && uname; cat lala

is an input with 2 command chains and result to a:

vector<
vector<(ls |), (more &&), (uname)>,
vector<(cat)>
>

By storing them in different vector we make the execution model simpler. Each chain can stopped and the sequencer will continue with the next chain etc... So in this example if more returns false(child::execute() returned true), then uname will not parsed and executed and the flow will continue to cat

Definition at line 160 of file sequencer.h.

Member Function Documentation

◆ execute()

Sequencer & snel::Sequencer::execute ( )

The main sequencer execution. We recurse for each command chain and each child in the chain and we parse-execute the child

Returns
Reference to Sequence for chaining

Definition at line 343 of file sequencer.cpp.

◆ is_seperator()

bool snel::Sequencer::is_seperator ( std::string &  s)
inlineprivate

separator trait predicate

private tools

Definition at line 169 of file sequencer.h.

◆ parse()

Sequencer & snel::Sequencer::parse ( const std::string &  input)

First parsing of each line. We split input in ';' to create command chains and split each chain further to create child tokens. These token will be processed further by the child's make_arguments()

Parameters
inputThe input string to parse
Returns
Reference to Sequencer for chaining

Definition at line 299 of file sequencer.cpp.


The documentation for this class was generated from the following files: