OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
OpalParser Class Reference

The default parser for OPAL-9. More...

#include <OpalParser.h>

Inheritance diagram for OpalParser:
Inheritance graph
[legend]
Collaboration diagram for OpalParser:
Collaboration graph
[legend]

Public Member Functions

 OpalParser ()
 
virtual ~OpalParser ()
 
virtual void parse (Statement &) const
 Parse and execute current statement. More...
 
virtual StatementreadStatement (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 StatementreadStatement (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 Objectfind (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
 

Detailed Description

The default parser for OPAL-9.

Definition at line 44 of file OpalParser.h.

Constructor & Destructor Documentation

◆ OpalParser() [1/2]

OpalParser::OpalParser ( )

Definition at line 58 of file OpalParser.cpp.

◆ ~OpalParser()

OpalParser::~OpalParser ( )
virtual

Definition at line 62 of file OpalParser.cpp.

◆ OpalParser() [2/2]

OpalParser::OpalParser ( const OpalParser )
private

Member Function Documentation

◆ execute()

void OpalParser::execute ( Object object,
const std::string &  name 
) const
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().

Here is the call graph for this function:

◆ find()

Object * OpalParser::find ( const std::string &  name) const
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().

Here is the call graph for this function:

◆ getHint()

std::string OpalParser::getHint ( const std::string &  name,
const std::string &  type = "attribute" 
)
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().

Here is the call graph for this function:

◆ operator=()

void OpalParser::operator= ( const OpalParser )
private

◆ parse()

void OpalParser::parse ( Statement stat) const
virtual

◆ parseAction()

void OpalParser::parseAction ( Statement stat) const
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().

Here is the call graph for this function:

◆ parseAssign()

void OpalParser::parseAssign ( Statement stat) const
protectedvirtual

◆ parseBracketList()

void OpalParser::parseBracketList ( char  close,
Statement stat 
)
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().

Here is the call graph for this function:

◆ parseDefine()

void OpalParser::parseDefine ( Statement stat) const
protectedvirtual

◆ parseEnd()

void OpalParser::parseEnd ( Statement stat) const
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().

Here is the call graph for this function:

◆ parseMacro()

void OpalParser::parseMacro ( const std::string &  name,
Statement stat 
) const
protectedvirtual

◆ parseTokenList()

void OpalParser::parseTokenList ( Statement stat)
staticprivate

Definition at line 478 of file OpalParser.cpp.

References Statement::append(), Token::isDel(), Token::isEOF(), parseBracketList(), and readToken().

Referenced by readStatement().

Here is the call graph for this function:

◆ printHelp()

void OpalParser::printHelp ( const std::string &  cmdName) const
protectedvirtual

Print help on named command.

Definition at line 445 of file OpalParser.cpp.

References endl(), find(), and gmsg.

Referenced by parse(), and parseAction().

Here is the call graph for this function:

◆ readStatement()

Statement * OpalParser::readStatement ( TokenStream is) const
virtual

◆ readToken()

Token OpalParser::readToken ( )
static

Return next input token.

Definition at line 499 of file OpalParser.cpp.

References inputStack, and Token::IS_EOF.

Referenced by parseBracketList(), and parseTokenList().

◆ run() [1/2]

void OpalParser::run ( ) const
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().

Here is the call graph for this function:

◆ run() [2/2]

void OpalParser::run ( TokenStream is) const
virtual

Read given stream.

Implements Parser.

Definition at line 631 of file OpalParser.cpp.

References inputStack, and run().

Here is the call graph for this function:

◆ stop()

void OpalParser::stop ( ) const

Set stop flag.

Definition at line 638 of file OpalParser.cpp.

References stopFlag.

Referenced by TrackEnd::execute(), and SequenceParser::parse().

Member Data Documentation

◆ inputStack

std::vector< Pointer< TokenStream > > OpalParser::inputStack
staticprivate

Definition at line 119 of file OpalParser.h.

Referenced by parseMacro(), readStatement(), readToken(), and run().

◆ stopFlag

bool OpalParser::stopFlag
mutableprivate

Definition at line 116 of file OpalParser.h.

Referenced by parseAction(), run(), and stop().


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