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 163 of file L1GTAlgoBlockProducer.cc.

Member Function Documentation

◆ addBeginParenthesis()

void pathStatusExpression::ShuntingYardAlgorithm::addBeginParenthesis ( )
inline

Definition at line 225 of file L1GTAlgoBlockProducer.cc.

References operatorStack.

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

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

◆ addEndParenthesis()

void pathStatusExpression::ShuntingYardAlgorithm::addEndParenthesis ( )
inline

Definition at line 227 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().

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

◆ addOperatorAnd()

void pathStatusExpression::ShuntingYardAlgorithm::addOperatorAnd ( )
inline

Definition at line 197 of file L1GTAlgoBlockProducer.cc.

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

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

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

◆ addOperatorNot()

void pathStatusExpression::ShuntingYardAlgorithm::addOperatorNot ( )
inline

Definition at line 170 of file L1GTAlgoBlockProducer.cc.

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

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

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

◆ addOperatorOr()

void pathStatusExpression::ShuntingYardAlgorithm::addOperatorOr ( )
inline

Definition at line 211 of file L1GTAlgoBlockProducer.cc.

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

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

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

◆ addPathName()

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

Definition at line 165 of file L1GTAlgoBlockProducer.cc.

References operandStack, pathNames_, and alignCSCRings::s.

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

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

◆ finish()

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

Definition at line 242 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().

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

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

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

179  {
180  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
181  backEvaluator->setRight(std::move(operandStack.back()));
182  operandStack.pop_back();
183  backEvaluator->setLeft(std::move(operandStack.back()));
184  operandStack.pop_back();
185  operandStack.push_back(std::move(backEvaluator));
186  operatorStack.pop_back();
187  }
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 189 of file L1GTAlgoBlockProducer.cc.

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

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

189  {
190  std::unique_ptr<Evaluator>& backEvaluator = operatorStack.back();
191  backEvaluator->setLeft(std::move(operandStack.back()));
192  operandStack.pop_back();
193  operandStack.push_back(std::move(backEvaluator));
194  operatorStack.pop_back();
195  }
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 266 of file L1GTAlgoBlockProducer.cc.

References pathNames_.

Referenced by L1GTAlgoBlockProducer::L1GTAlgoBlockProducer().

266 { return pathNames_; }

Member Data Documentation

◆ operandStack

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

Definition at line 270 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 269 of file L1GTAlgoBlockProducer.cc.

Referenced by addPathName(), and pathNames().