36 "A \"MACRO\" command defines a subroutine:\n"
37 "\t<name>(<arguments>):MACRO{<body>}"),
65 "Inconsistent number of macro arguments.");
74 while(! token.
isEOF()) {
78 std::string word = token.
getWord();
80 for(std::vector<std::string>::size_type i = 0;
83 std::vector<Token> act =
actuals[i];
107 bool isMacro = statement.
keyword(
"MACRO");
114 if(statement.
atEnd()) {
116 "MACRO body is not closed.");
120 if(token.
isDel(
'{')) {
122 }
else if(token.
isDel(
'}')) {
123 if(--level == 0)
break;
131 "Missing MACRO body, should be \"{...}\".");
The base class for all OPAL objects.
Interface for abstract language parser.
virtual void run(TokenStream *ts) const =0
Read statements and parse.
Interface for statements.
Token & getCurrent()
Return current token and skip it.
bool keyword(const char *s)
Test for keyword.
bool atEnd() const
Test for end of command.
bool delimiter(char c)
Test for delimiter.
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.
Abstract interface for a stream of input tokens.
Abstract base class for macros.
virtual void parseFormals(Statement &)
Parse formal arguments.
std::vector< std::string > formals
The formal argument list.
std::vector< std::vector< Token > > actuals
The actual argument list.
virtual void parseActuals(Statement &)
Parse actual arguments.
virtual Object * makeInstance(const std::string &name, Statement &, const Parser *)
Make a macro instance.
virtual Object * makeTemplate(const std::string &, TokenStream &, Statement &)
Make a macro template.
Pointer< MacroStream > body
virtual void execute()
Execute the macro command.
An input buffer for macro commands.
void append(Token &)
Append a token to the stream.
void start()
Reset stream to start.
virtual Token readToken()
Read a token from the stream.