26#include "Utility/PAssert.h"
36 "This object defines a beamline list with arguments.\n"
41 :
Macro(name, parent), body(name) {}
46 throw ParseError(
"LineTemplate::clone()",
"You cannot use this object without attributes.");
57 "LineTemplate::makeInstance()",
"Inconsistent number of macro arguments.");
64 while (!token.
isEOF()) {
67 std::string word = token.
getWord();
69 for (std::vector<std::string>::size_type i = 0; i <
formals.size(); i++) {
71 std::vector<Token> act =
actuals[i];
80 if (!found) expansion.
append(token);
86 instance = model->
clone(name);
89 instance->
parse(expansion);
105 bool isLine = statement.
keyword(
"LINE");
110 if (token.
isDel(
'=')) {
113 while (!statement.
atEnd()) {
115 if (token.
isDel(
'(')) {
117 }
else if (token.
isDel(
')')) {
119 if (--level == 0)
break;
124 throw ParseError(
"LineTemplate::parseTemplate()",
"Equals sign '=' expected.");
void parseTemplate(TokenStream &is, Statement &stat)
Parse the line template.
virtual Object * makeInstance(const std::string &name, Statement &stat, const Parser *)
Make line instance.
virtual LineTemplate * clone(const std::string &name)
Make clone.
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a line template.
virtual void parse(Statement &stat)
Parse the line object.
virtual Line * clone(const std::string &name)
Make clone.
void append(Token &)
Append a token to the stream.
void start()
Reset stream to start.
virtual Token readToken()
Read a token from the stream.
Abstract base class for macros.
std::vector< std::vector< Token > > actuals
The actual argument list.
virtual void parseFormals(Statement &)
Parse formal arguments.
std::vector< std::string > formals
The formal argument list.
virtual void parseActuals(Statement &)
Parse actual arguments.
The base class for all OPAL objects.
const std::string & getOpalName() const
Return object name.
void copyAttributes(const Object &)
Copy attributes from another object.
Object * find(const std::string &name)
Find entry.
static OpalData * getInstance()
Interface for abstract language parser.
A simple input statement in token form.
Interface for statements.
Token & getCurrent()
Return current token and skip it.
void append(const Token &)
Append a token.
bool keyword(const char *s)
Test for keyword.
bool atEnd() const
Test for end of command.
void start()
Return to start.
Abstract interface for a stream of input tokens.
Representation of a single input token.
bool isDel(char del) const
Test for delimiter.
bool isWord() const
Test for word.
bool isEOF() const
Test for end of file.
std::string getWord() const
Return word value.