OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
|
The default parser for OPAL-9. More...
#include <OpalParser.h>
Public Member Functions | |
OpalParser () | |
virtual | ~OpalParser () |
virtual void | parse (Statement &) const |
Parse and execute current statement. More... | |
virtual Statement * | readStatement (TokenStream *) const |
Read complete statement from a token stream. More... | |
virtual void | run () const |
Read current stream. More... | |
virtual void | run (TokenStream *) const |
Read given stream. More... | |
void | stop () const |
Set stop flag. More... | |
Public Member Functions inherited from Parser | |
Parser () | |
virtual | ~Parser () |
virtual void | parse (Statement &stat) const =0 |
Parse and execute the statement. More... | |
virtual Statement * | readStatement (TokenStream *ts) const =0 |
Read complete statement from token stream. More... | |
virtual void | run (TokenStream *ts) const =0 |
Read statements and parse. More... | |
Static Public Member Functions | |
static Token | readToken () |
Return next input token. More... | |
Protected Member Functions | |
void | execute (Object *, const std::string &) const |
Execute or check the current command. More... | |
virtual Object * | find (const std::string &) const |
Find object by name in the main directory. More... | |
virtual void | parseAction (Statement &) const |
Parse executable command. More... | |
virtual void | parseAssign (Statement &) const |
Parse assignment statement. More... | |
virtual void | parseDefine (Statement &) const |
Parse definition. More... | |
virtual void | parseEnd (Statement &) const |
Check for end of statement. More... | |
virtual void | parseMacro (const std::string &name, Statement &) const |
Parse macro definition or call. More... | |
virtual void | printHelp (const std::string &) const |
Print help on named command. More... | |
Private Member Functions | |
OpalParser (const OpalParser &) | |
void | operator= (const OpalParser &) |
Static Private Member Functions | |
static void | parseBracketList (char close, Statement &) |
static void | parseTokenList (Statement &) |
static std::string | getHint (const std::string &, const std::string &="attribute") |
Private Attributes | |
bool | stopFlag |
Static Private Attributes | |
static std::vector< Pointer< TokenStream > > | inputStack |
The default parser for OPAL-9.
Definition at line 44 of file OpalParser.h.
OpalParser::OpalParser | ( | ) |
Definition at line 58 of file OpalParser.cpp.
|
virtual |
Definition at line 62 of file OpalParser.cpp.
|
private |
|
protected |
Execute or check the current command.
Definition at line 126 of file OpalParser.cpp.
References endl(), OpalData::getInstance(), gmsg, Options::mtrace, name, Object::shouldTrace(), Object::shouldUpdate(), and OpalData::update().
Referenced by parseAction(), parseDefine(), and parseMacro().
|
protectedvirtual |
Find object by name in the main directory.
Reimplemented in TrackParser.
Definition at line 151 of file OpalParser.cpp.
References OpalData::find(), OpalData::getInstance(), and name.
Referenced by parse(), parseAction(), parseAssign(), parseDefine(), parseMacro(), SequenceParser::parseMember(), and printHelp().
|
staticprivate |
Definition at line 642 of file OpalParser.cpp.
References any(), AttributeHandler::COMMAND, AttributeHandler::ELEMENT, AttributeHandler::getOwner(), name, AttributeHandler::STATEMENT, and AttributeHandler::SUB_COMMAND.
Referenced by parse(), and parseAction().
|
private |
|
virtual |
Parse and execute current statement.
Implements Parser.
Reimplemented in SequenceParser.
Definition at line 66 of file OpalParser.cpp.
References Statement::atEnd(), Statement::delimiter(), find(), Statement::getCurrent(), getHint(), OpalData::getInstance(), Token::getLex(), Statement::keyword(), Statement::mark(), name, parseAction(), parseAssign(), parseDefine(), parseMacro(), Expressions::parseString(), Statement::position(), Statement::print(), printHelp(), Statement::restore(), and Statement::start().
|
protectedvirtual |
Parse executable command.
Definition at line 156 of file OpalParser.cpp.
References Object::clone(), Statement::delimiter(), execute(), find(), getHint(), Object::parse(), parseEnd(), Expressions::parseString(), printHelp(), Statement::start(), and stopFlag.
Referenced by parse().
|
protectedvirtual |
Parse assignment statement.
Definition at line 192 of file OpalParser.cpp.
References Object::clone(), OpalData::define(), Statement::delimiter(), find(), OpalData::find(), Object::findAttribute(), OpalData::getInstance(), Object::isTreeMember(), Statement::keyword(), OpalData::makeDirty(), Expressions::parseDelimiter(), parseEnd(), Expressions::parseRealConst(), Expressions::parseString(), and Statement::start().
Referenced by parse().
|
staticprivate |
Definition at line 457 of file OpalParser.cpp.
References Statement::append(), Token::isDel(), Token::isEOF(), parseBracketList(), and readToken().
Referenced by parseBracketList(), parseTokenList(), and readStatement().
|
protectedvirtual |
Parse definition.
Definition at line 326 of file OpalParser.cpp.
References Object::clone(), OpalData::define(), Statement::delimiter(), execute(), find(), OpalData::getInstance(), Statement::keyword(), Object::makeInstance(), Object::parse(), parseEnd(), Expressions::parseString(), Object::setShared(), and Statement::start().
Referenced by parse().
|
protectedvirtual |
Check for end of statement.
Definition at line 373 of file OpalParser.cpp.
References Statement::atEnd(), Statement::delimiter(), Statement::position(), and Statement::print().
Referenced by SequenceParser::parse(), parseAction(), parseAssign(), parseDefine(), and SequenceParser::parseMember().
|
protectedvirtual |
Parse macro definition or call.
Definition at line 389 of file OpalParser.cpp.
References OpalData::define(), Statement::delimiter(), execute(), find(), Statement::getCurrent(), OpalData::getInstance(), inputStack, Object::makeInstance(), Object::makeTemplate(), Statement::mark(), Expressions::parseString(), and Statement::restore().
Referenced by parse().
|
staticprivate |
Definition at line 478 of file OpalParser.cpp.
References Statement::append(), Token::isDel(), Token::isEOF(), parseBracketList(), and readToken().
Referenced by readStatement().
|
protectedvirtual |
Print help on named command.
Definition at line 445 of file OpalParser.cpp.
References endl(), find(), and gmsg.
Referenced by parse(), and parseAction().
|
virtual |
Read complete statement from a token stream.
Implements Parser.
Definition at line 508 of file OpalParser.cpp.
References Statement::append(), endl(), IpplInfo::Error, ERRORMSG, Token::getFile(), Token::getLine(), gmsg, inputStack, Token::isDel(), Token::isEOF(), Token::isKey(), Token::isString(), Token::isWord(), parseBracketList(), parseTokenList(), Statement::printWhere(), readStatement(), TokenStream::readToken(), Statement::start(), and ClassicException::what().
Referenced by readStatement(), and run().
|
static |
Return next input token.
Definition at line 499 of file OpalParser.cpp.
References inputStack, and Token::IS_EOF.
Referenced by parseBracketList(), and parseTokenList().
|
virtual |
Read current stream.
Definition at line 602 of file OpalParser.cpp.
References endl(), inputStack, readStatement(), stopFlag, ClassicException::what(), and ClassicException::where().
Referenced by Call::execute(), TrackCmd::execute(), SequenceTemplate::makeInstance(), opalMain(), Sequence::parse(), run(), and run_opal().
|
virtual |
Read given stream.
Implements Parser.
Definition at line 631 of file OpalParser.cpp.
References inputStack, and run().
void OpalParser::stop | ( | ) | const |
Set stop flag.
Definition at line 638 of file OpalParser.cpp.
References stopFlag.
Referenced by TrackEnd::execute(), and SequenceParser::parse().
|
staticprivate |
Definition at line 119 of file OpalParser.h.
Referenced by parseMacro(), readStatement(), readToken(), and run().
|
mutableprivate |
Definition at line 116 of file OpalParser.h.
Referenced by parseAction(), run(), and stop().