1
2/* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/D-Programming-Language/dmd/blob/master/src/macro.h
9 */
10
11#pragma once
12
13#include "root/dsystem.h"
14#include "root/root.h"
15
16
17struct Macro
18{
19  private:
20    Macro *next;                // next in list
21
22    const utf8_t *name;        // macro name
23    size_t namelen;             // length of macro name
24
25    const utf8_t *text;        // macro replacement text
26    size_t textlen;             // length of replacement text
27
28    int inuse;                  // macro is in use (don't expand)
29
30    Macro(const utf8_t *name, size_t namelen, const utf8_t *text, size_t textlen);
31    Macro *search(const utf8_t *name, size_t namelen);
32
33  public:
34    static Macro *define(Macro **ptable, const utf8_t *name, size_t namelen, const utf8_t *text, size_t textlen);
35
36    void expand(OutBuffer *buf, size_t start, size_t *pend,
37        const utf8_t *arg, size_t arglen);
38};
39