CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
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 ()
 
const std::vector< std::string > & pathNames ()
 

Private Attributes

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

Detailed Description

Definition at line 162 of file L1GTAlgoBlockProducer.cc.

Member Function Documentation

◆ addBeginParenthesis()

void pathStatusExpression::ShuntingYardAlgorithm::addBeginParenthesis ( )
inline

Definition at line 224 of file L1GTAlgoBlockProducer.cc.

References operatorStack.

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

224 { operatorStack.push_back(std::make_unique<BeginParenthesis>()); }
std::vector< std::unique_ptr< Evaluator > > operatorStack

◆ addEndParenthesis()

void pathStatusExpression::ShuntingYardAlgorithm::addEndParenthesis ( )
inline

Definition at line 226 of file L1GTAlgoBlockProducer.cc.

References pathStatusExpression::Evaluator::And, pathStatusExpression::Evaluator::BeginParen, moveBinaryOperator(), moveNotOperator(), pathStatusExpression::Evaluator::Not, operatorStack, and pathStatusExpression::Evaluator::Or.

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

226  {
227  while (!operatorStack.empty()) {
228  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
229  if (backEvaluator->type() == Evaluator::BeginParen) {
230  operatorStack.pop_back();
231  break;
232  }
233  if (backEvaluator->type() == Evaluator::And || backEvaluator->type() == Evaluator::Or) {
235  } else if (backEvaluator->type() == Evaluator::Not) {
236  moveNotOperator();
237  }
238  }
239  }
std::vector< std::unique_ptr< Evaluator > > operatorStack

◆ addOperatorAnd()

void pathStatusExpression::ShuntingYardAlgorithm::addOperatorAnd ( )
inline

Definition at line 196 of file L1GTAlgoBlockProducer.cc.

References pathStatusExpression::Evaluator::And, moveBinaryOperator(), moveNotOperator(), pathStatusExpression::Evaluator::Not, and operatorStack.

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

196  {
197  while (!operatorStack.empty()) {
198  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
199  if (backEvaluator->type() == Evaluator::And) {
201  } else if (backEvaluator->type() == Evaluator::Not) {
202  moveNotOperator();
203  } else {
204  break;
205  }
206  }
207  operatorStack.push_back(std::make_unique<AndOperator>());
208  }
std::vector< std::unique_ptr< Evaluator > > operatorStack

◆ addOperatorNot()

void pathStatusExpression::ShuntingYardAlgorithm::addOperatorNot ( )
inline

Definition at line 169 of file L1GTAlgoBlockProducer.cc.

References pathStatusExpression::Evaluator::Not, and operatorStack.

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

169  {
170  if (operatorStack.empty() || operatorStack.back()->type() != Evaluator::Not) {
171  operatorStack.push_back(std::make_unique<NotOperator>());
172  } else {
173  // Two Not operations in a row cancel and are the same as no operation at all.
174  operatorStack.pop_back();
175  }
176  }
std::vector< std::unique_ptr< Evaluator > > operatorStack

◆ addOperatorOr()

void pathStatusExpression::ShuntingYardAlgorithm::addOperatorOr ( )
inline

Definition at line 210 of file L1GTAlgoBlockProducer.cc.

References pathStatusExpression::Evaluator::And, moveBinaryOperator(), moveNotOperator(), pathStatusExpression::Evaluator::Not, operatorStack, and pathStatusExpression::Evaluator::Or.

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

210  {
211  while (!operatorStack.empty()) {
212  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
213  if (backEvaluator->type() == Evaluator::And || backEvaluator->type() == Evaluator::Or) {
215  } else if (backEvaluator->type() == Evaluator::Not) {
216  moveNotOperator();
217  } else {
218  break;
219  }
220  }
221  operatorStack.push_back(std::make_unique<OrOperator>());
222  }
std::vector< std::unique_ptr< Evaluator > > operatorStack

◆ addPathName()

void pathStatusExpression::ShuntingYardAlgorithm::addPathName ( std::vector< char > const &  s)
inline

Definition at line 164 of file L1GTAlgoBlockProducer.cc.

References operandStack, pathNames_, and alignCSCRings::s.

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

164  {
165  operandStack.push_back(std::make_unique<Operand>(s));
166  pathNames_.emplace_back(s.begin(), s.end());
167  }
std::vector< std::unique_ptr< Evaluator > > operandStack

◆ finish()

std::unique_ptr<Evaluator> pathStatusExpression::ShuntingYardAlgorithm::finish ( )
inline

Definition at line 241 of file L1GTAlgoBlockProducer.cc.

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

Referenced by progressbar.ProgressBar::__next__(), and L1GTAlgoBlockProducer::L1GTAlgoBlockProducer().

241  {
242  while (!operatorStack.empty()) {
243  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
244  // Just a sanity check. The grammar defined for the boost Spirit parser
245  // should catch any errors of this type before we get here.
246  if (backEvaluator->type() == Evaluator::BeginParen) {
247  throw cms::Exception("LogicError") << "Should be impossible to get this error. Contact a Framework developer";
248  }
249  if (backEvaluator->type() == Evaluator::And || backEvaluator->type() == Evaluator::Or) {
251  } else if (backEvaluator->type() == Evaluator::Not) {
252  moveNotOperator();
253  }
254  }
255  // Just a sanity check. The grammar defined for the boost Spirit parser
256  // should catch any errors of this type before we get here.
257  if (!operatorStack.empty() || operandStack.size() != 1U) {
258  throw cms::Exception("LogicError") << "Should be impossible to get this error. Contact a Framework developer";
259  }
260  std::unique_ptr<Evaluator> temp = std::move(operandStack.back());
261  operandStack.pop_back();
262  return temp;
263  }
std::vector< std::unique_ptr< Evaluator > > operandStack
std::vector< std::unique_ptr< Evaluator > > operatorStack
def move(src, dest)
Definition: eostools.py:511

◆ moveBinaryOperator()

void pathStatusExpression::ShuntingYardAlgorithm::moveBinaryOperator ( )
inline

Definition at line 178 of file L1GTAlgoBlockProducer.cc.

References eostools::move(), operandStack, and operatorStack.

Referenced by addEndParenthesis(), addOperatorAnd(), addOperatorOr(), and finish().

178  {
179  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
180  backEvaluator->setRight(std::move(operandStack.back()));
181  operandStack.pop_back();
182  backEvaluator->setLeft(std::move(operandStack.back()));
183  operandStack.pop_back();
184  operandStack.push_back(std::move(backEvaluator));
185  operatorStack.pop_back();
186  }
std::vector< std::unique_ptr< Evaluator > > operandStack
std::vector< std::unique_ptr< Evaluator > > operatorStack
def move(src, dest)
Definition: eostools.py:511

◆ moveNotOperator()

void pathStatusExpression::ShuntingYardAlgorithm::moveNotOperator ( )
inline

Definition at line 188 of file L1GTAlgoBlockProducer.cc.

References eostools::move(), operandStack, and operatorStack.

Referenced by addEndParenthesis(), addOperatorAnd(), addOperatorOr(), and finish().

188  {
189  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
190  backEvaluator->setLeft(std::move(operandStack.back()));
191  operandStack.pop_back();
192  operandStack.push_back(std::move(backEvaluator));
193  operatorStack.pop_back();
194  }
std::vector< std::unique_ptr< Evaluator > > operandStack
std::vector< std::unique_ptr< Evaluator > > operatorStack
def move(src, dest)
Definition: eostools.py:511

◆ pathNames()

const std::vector<std::string>& pathStatusExpression::ShuntingYardAlgorithm::pathNames ( )
inline

Definition at line 265 of file L1GTAlgoBlockProducer.cc.

References pathNames_.

Referenced by L1GTAlgoBlockProducer::L1GTAlgoBlockProducer().

265 { return pathNames_; }

Member Data Documentation

◆ operandStack

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

Definition at line 269 of file L1GTAlgoBlockProducer.cc.

Referenced by addPathName(), finish(), moveBinaryOperator(), and moveNotOperator().

◆ operatorStack

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

◆ pathNames_

std::vector<std::string> pathStatusExpression::ShuntingYardAlgorithm::pathNames_
private

Definition at line 268 of file L1GTAlgoBlockProducer.cc.

Referenced by addPathName(), and pathNames().