CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::pathStatusExpression::ShuntingYardAlgorithm Class Reference

Public Member Functions

void addBeginParenthesis ()
 
void addEndParenthesis ()
 
void addOperatorAnd ()
 
void addOperatorNot ()
 
void addOperatorOr ()
 
void addPathName (std::vector< char > const &s)
 
std::unique_ptr< Evaluatorfinish ()
 
void moveBinaryOperator ()
 
void moveNotOperator ()
 

Private Attributes

std::vector< std::unique_ptr< Evaluator > > operandStack
 
std::vector< std::unique_ptr< Evaluator > > operatorStack
 

Detailed Description

Definition at line 196 of file PathStatusFilter.cc.

Member Function Documentation

void edm::pathStatusExpression::ShuntingYardAlgorithm::addBeginParenthesis ( )
inline

Definition at line 255 of file PathStatusFilter.cc.

Referenced by edm::pathStatusExpression::Grammar< Iterator >::Grammar().

255 { operatorStack.push_back(std::make_unique<BeginParenthesis>()); }
std::vector< std::unique_ptr< Evaluator > > operatorStack
void edm::pathStatusExpression::ShuntingYardAlgorithm::addEndParenthesis ( )
inline
void edm::pathStatusExpression::ShuntingYardAlgorithm::addOperatorAnd ( )
inline

Definition at line 227 of file PathStatusFilter.cc.

References edm::pathStatusExpression::Evaluator::And, and edm::pathStatusExpression::Evaluator::Not.

Referenced by edm::pathStatusExpression::Grammar< Iterator >::Grammar().

227  {
228  while (!operatorStack.empty()) {
229  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
230  if (backEvaluator->type() == Evaluator::And) {
232  } else if (backEvaluator->type() == Evaluator::Not) {
233  moveNotOperator();
234  } else {
235  break;
236  }
237  }
238  operatorStack.push_back(std::make_unique<AndOperator>());
239  }
std::vector< std::unique_ptr< Evaluator > > operatorStack
void edm::pathStatusExpression::ShuntingYardAlgorithm::addOperatorNot ( )
inline

Definition at line 200 of file PathStatusFilter.cc.

References edm::pathStatusExpression::Evaluator::Not.

Referenced by edm::pathStatusExpression::Grammar< Iterator >::Grammar().

200  {
201  if (operatorStack.empty() || operatorStack.back()->type() != Evaluator::Not) {
202  operatorStack.push_back(std::make_unique<NotOperator>());
203  } else {
204  // Two Not operations in a row cancel and are the same as no operation at all.
205  operatorStack.pop_back();
206  }
207  }
std::vector< std::unique_ptr< Evaluator > > operatorStack
void edm::pathStatusExpression::ShuntingYardAlgorithm::addOperatorOr ( )
inline

Definition at line 241 of file PathStatusFilter.cc.

References edm::pathStatusExpression::Evaluator::And, edm::pathStatusExpression::Evaluator::Not, and edm::pathStatusExpression::Evaluator::Or.

Referenced by edm::pathStatusExpression::Grammar< Iterator >::Grammar().

241  {
242  while (!operatorStack.empty()) {
243  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
244  if (backEvaluator->type() == Evaluator::And || backEvaluator->type() == Evaluator::Or) {
246  } else if (backEvaluator->type() == Evaluator::Not) {
247  moveNotOperator();
248  } else {
249  break;
250  }
251  }
252  operatorStack.push_back(std::make_unique<OrOperator>());
253  }
std::vector< std::unique_ptr< Evaluator > > operatorStack
void edm::pathStatusExpression::ShuntingYardAlgorithm::addPathName ( std::vector< char > const &  s)
inline

Definition at line 198 of file PathStatusFilter.cc.

Referenced by edm::pathStatusExpression::Grammar< Iterator >::Grammar().

198 { operandStack.push_back(std::make_unique<Operand>(s)); }
std::vector< std::unique_ptr< Evaluator > > operandStack
std::unique_ptr<Evaluator> edm::pathStatusExpression::ShuntingYardAlgorithm::finish ( )
inline

Definition at line 272 of file PathStatusFilter.cc.

References edm::pathStatusExpression::Evaluator::And, edm::pathStatusExpression::Evaluator::BeginParen, Exception, eostools::move(), edm::pathStatusExpression::Evaluator::Not, edm::pathStatusExpression::Evaluator::Or, groupFilesInBlocks::temp, and mitigatedMETSequence_cff::U.

Referenced by progressbar.ProgressBar::__next__(), and edm::PathStatusFilter::PathStatusFilter().

272  {
273  while (!operatorStack.empty()) {
274  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
275  // Just a sanity check. The grammar defined for the boost Spirit parser
276  // should catch any errors of this type before we get here.
277  if (backEvaluator->type() == Evaluator::BeginParen) {
278  throw cms::Exception("LogicError")
279  << "Should be impossible to get this error. Contact a Framework developer";
280  }
281  if (backEvaluator->type() == Evaluator::And || backEvaluator->type() == Evaluator::Or) {
283  } else if (backEvaluator->type() == Evaluator::Not) {
284  moveNotOperator();
285  }
286  }
287  // Just a sanity check. The grammar defined for the boost Spirit parser
288  // should catch any errors of this type before we get here.
289  if (!operatorStack.empty() || operandStack.size() != 1U) {
290  throw cms::Exception("LogicError") << "Should be impossible to get this error. Contact a Framework developer";
291  }
292  std::unique_ptr<Evaluator> temp = std::move(operandStack.back());
293  operandStack.pop_back();
294  return temp;
295  }
std::vector< std::unique_ptr< Evaluator > > operatorStack
std::vector< std::unique_ptr< Evaluator > > operandStack
def move(src, dest)
Definition: eostools.py:511
void edm::pathStatusExpression::ShuntingYardAlgorithm::moveBinaryOperator ( )
inline

Definition at line 209 of file PathStatusFilter.cc.

References eostools::move().

209  {
210  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
211  backEvaluator->setRight(std::move(operandStack.back()));
212  operandStack.pop_back();
213  backEvaluator->setLeft(std::move(operandStack.back()));
214  operandStack.pop_back();
215  operandStack.push_back(std::move(backEvaluator));
216  operatorStack.pop_back();
217  }
std::vector< std::unique_ptr< Evaluator > > operatorStack
std::vector< std::unique_ptr< Evaluator > > operandStack
def move(src, dest)
Definition: eostools.py:511
void edm::pathStatusExpression::ShuntingYardAlgorithm::moveNotOperator ( )
inline

Definition at line 219 of file PathStatusFilter.cc.

References eostools::move().

219  {
220  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
221  backEvaluator->setLeft(std::move(operandStack.back()));
222  operandStack.pop_back();
223  operandStack.push_back(std::move(backEvaluator));
224  operatorStack.pop_back();
225  }
std::vector< std::unique_ptr< Evaluator > > operatorStack
std::vector< std::unique_ptr< Evaluator > > operandStack
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::vector<std::unique_ptr<Evaluator> > edm::pathStatusExpression::ShuntingYardAlgorithm::operandStack
private

Definition at line 298 of file PathStatusFilter.cc.

std::vector<std::unique_ptr<Evaluator> > edm::pathStatusExpression::ShuntingYardAlgorithm::operatorStack
private

Definition at line 299 of file PathStatusFilter.cc.