MacroCmd.h 2.07 KB
Newer Older
gsell's avatar
gsell committed
1
//
2
// Class MacroCmd
gsell's avatar
gsell committed
3
//
4 5 6 7
//   This class parses the MACRO command.
//   Encapsulate the buffer for the ``archetypes'' of all macros.
//   The macro is stored as a MacroStream.  For execution, first the
//   parameters are replaced, then the resulting stream is sent to the parser.
gsell's avatar
gsell committed
8
//
9
// Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
gsell's avatar
gsell committed
10
//
11 12 13 14 15 16 17 18 19 20 21 22 23 24
// All rights reserved
//
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#ifndef CLASSIC_MacroCmd_HH
#define CLASSIC_MacroCmd_HH
gsell's avatar
gsell committed
25 26 27 28 29

#include "OpalParser/Macro.h"
#include "OpalParser/MacroStream.h"
#include "MemoryManagement/Pointer.h"
#include <iosfwd>
30
#include <string>
gsell's avatar
gsell committed
31 32 33 34 35 36 37 38 39

// Class MacroCmd
// ------------------------------------------------------------------------

class MacroCmd: public Macro {

public:

    MacroCmd();
40
    MacroCmd(const std::string &name, MacroCmd *parent);
gsell's avatar
gsell committed
41 42 43 44 45 46 47 48 49 50
    virtual ~MacroCmd();

    /// Execute the macro command.
    virtual void execute();

    /// Make a macro instance.
    //  Expects parse pointer in the statement to be set on the first argument.
    //  The parser is used to determine the parse mode
    //  (normal, error, match, edit, track).
    virtual Object *makeInstance
51
    (const std::string &name, Statement &, const Parser *);
gsell's avatar
gsell committed
52 53 54

    /// Make a macro template.
    //  Expects parse pointer in the statement to be set on the first argument.
55
    virtual Object *makeTemplate(const std::string &, TokenStream &, Statement &);
gsell's avatar
gsell committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69

private:

    // Not implemented.
    MacroCmd(const MacroCmd &);
    void operator=(const MacroCmd &);

    // The stream of tokens representing the macro command.
    Pointer<MacroStream> body;

    // Pointer to the parser to be used in execution.
    const Parser *itsParser;
};

70
#endif // CLASSIC_MacroCmd_HH