OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Macro.h
Go to the documentation of this file.
1#ifndef CLASSIC_Macro_HH
2#define CLASSIC_Macro_HH
3
4// ------------------------------------------------------------------------
5// $RCSfile: Macro.h,v $
6// ------------------------------------------------------------------------
7// $Revision: 1.1.1.1 $
8// ------------------------------------------------------------------------
9// Copyright: see Copyright.readme
10// ------------------------------------------------------------------------
11//
12// Class: Macro
13//
14// ------------------------------------------------------------------------
15//
16// $Date: 2000/03/27 09:33:43 $
17// $Author: Andreas Adelmann $
18//
19// ------------------------------------------------------------------------
20
22#include "Parser/Token.h"
23#include <vector>
24
25class Statement;
26class TokenStream;
27
28
29// Class Macro
30// ------------------------------------------------------------------------
32// The base class for storing the ``archetype'' for all macro-like commands.
33
34class Macro: public Object {
35
36public:
37
39 Macro(int size, const char *name, const char *help);
40
42 Macro(const std::string &name, Object *parent);
43
44 virtual ~Macro();
45
47 // Throw ParseError, since for macro we must make a template and not
48 // a clone.
49 virtual Macro *clone(const std::string &name);
50
52 // Return the string "MACRO".
53 virtual const std::string getCategory() const;
54
56 // If true, the object's execute() function should be traced.
57 // Always false for macros.
58 virtual bool shouldTrace() const;
59
61 // If true, the data structure should be updated before calling execute().
62 // Always false for macros.
63 virtual bool shouldUpdate() const;
64
65
67 // Expects parse pointer in the statement to be set on the first argument.
68 virtual void parseActuals(Statement &);
69
71 // Expects parse pointer in the statement to be set on the first argument.
72 virtual void parseFormals(Statement &);
73
74protected:
75
77 // Each formal argument is represented as a name and stored as a string.
78 std::vector<std::string> formals;
79
81 // Each actual argument is stored as a vector of tokens.
82 std::vector<std::vector < Token > > actuals;
83
84private:
85
86 // Not implemented.
88 Macro(const Macro &);
89 void operator=(const Macro &);
90};
91
92#endif // CLASSIC_Macro_HH
const std::string name
The base class for all OPAL objects.
Definition: Object.h:48
Interface for statements.
Definition: Statement.h:38
Abstract interface for a stream of input tokens.
Definition: TokenStream.h:33
Abstract base class for macros.
Definition: Macro.h:34
virtual const std::string getCategory() const
Return the object category as a string.
Definition: Macro.cpp:49
virtual Macro * clone(const std::string &name)
Make clone.
Definition: Macro.cpp:42
virtual bool shouldUpdate() const
Update flag.
Definition: Macro.cpp:59
virtual ~Macro()
Definition: Macro.cpp:38
void operator=(const Macro &)
Macro(const Macro &)
virtual void parseFormals(Statement &)
Parse formal arguments.
Definition: Macro.cpp:100
std::vector< std::string > formals
The formal argument list.
Definition: Macro.h:78
std::vector< std::vector< Token > > actuals
The actual argument list.
Definition: Macro.h:82
virtual void parseActuals(Statement &)
Parse actual arguments.
Definition: Macro.cpp:64
virtual bool shouldTrace() const
Trace flag.
Definition: Macro.cpp:54