Project

General

Profile

root / trunk / compiler / cppAst / ast / identifiers / IdentifierBlock.hpp @ 9

1
/**
2
  *
3
  *                  OOAS Compiler - C++ AST
4
  *
5
  * Copyright 2015, AIT Austrian Institute of Technology.
6
  * All rights reserved.
7
  *
8
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
9
  *
10
  * If you modify the file please update the list of contributors below to in-
11
  * clude your name. Please also stick to the coding convention of using TABs
12
  * to do the basic (block-level) indentation and spaces for anything after
13
  * that. (Enable the display of special chars and it should be pretty obvious
14
  * what this means.) Also, remove all trailing whitespace.
15
  *
16
  * Contributors:
17
  *               Willibald Krenn (AIT)
18
  *               Stephan Zimmerer (AIT)
19
  *               Christoph Czurda (AIT)
20
  *
21
  */
22

    
23

    
24

    
25

    
26
#pragma once
27

    
28
#include <ast/identifiers/Identifier.hpp>
29
#include <deque>
30
#include <ast/IAstVisitor.hpp>
31
#include <ast/Containers.hpp>
32

    
33
namespace Ast {
34

    
35
enum class IdentifierBlockKind {
36
        normal = 0,
37
        nondeterministic = 1,
38
        seqential = 2,
39
        prioritized = 3
40
};
41

    
42
class IdentifierBlock
43
        : public Identifier
44
{
45
protected:
46
        IdentifierList m_list;
47

    
48
        IdentifierBlock(IdentifierKind kind):
49
                Identifier(kind),
50
                m_list()
51
        {}
52
public:
53
        IdentifierBlock(const IdentifierBlock &toCopy):
54
                Identifier(toCopy),
55
                m_list(toCopy.m_list)
56
        {}
57

    
58

    
59
        IdentifierList& identifiers() {return m_list;};
60
        void addElement(Identifier* toAdd) {m_list.push_back(toAdd);};
61
};
62

    
63
class UnspecIdentifierBlock final
64
        : public IdentifierBlock
65
{
66
        UnspecIdentifierBlock():
67
                IdentifierBlock(IdentifierKind::List_Normal)
68
        {}
69
        UnspecIdentifierBlock(const UnspecIdentifierBlock &toCopy):
70
                IdentifierBlock(toCopy)
71
        {}
72

    
73
        static UnspecIdentifierBlock* create() {return new UnspecIdentifierBlock();}
74
        static UnspecIdentifierBlock* createCopy(const UnspecIdentifierBlock& toCopy) {return new UnspecIdentifierBlock(toCopy);}
75
public:
76
        friend class Ast;
77
        friend class Identifier;
78

    
79
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
80
};
81

    
82
class SeqIdentifierBlock final
83
        : public IdentifierBlock
84
{
85
protected:
86
        SeqIdentifierBlock():
87
                IdentifierBlock(IdentifierKind::List_Seqential)
88
        {}
89
        SeqIdentifierBlock(const SeqIdentifierBlock &toCopy):
90
                IdentifierBlock(toCopy)
91
        {}
92

    
93
        static SeqIdentifierBlock* create() {return new SeqIdentifierBlock();}
94
        static SeqIdentifierBlock* createCopy(const SeqIdentifierBlock& toCopy) {return new SeqIdentifierBlock(toCopy);}
95
public:
96
        friend class Ast;
97
        friend class Identifier;
98

    
99
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
100
};
101

    
102
class NondetIdentifierBlock final
103
        : public IdentifierBlock
104
{
105
protected:
106
        NondetIdentifierBlock():
107
                IdentifierBlock(IdentifierKind::List_Nondeterministic)
108
        {}
109
        NondetIdentifierBlock(const NondetIdentifierBlock &toCopy):
110
                IdentifierBlock(toCopy)
111
        {}
112

    
113
        static NondetIdentifierBlock* create() {return new NondetIdentifierBlock();}
114
        static NondetIdentifierBlock* createCopy(const NondetIdentifierBlock& toCopy) {return new NondetIdentifierBlock(toCopy);}
115
public:
116
        friend class Ast;
117
        friend class Identifier;
118

    
119
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
120
};
121

    
122
class PrioIdentifierBlock final
123
        : public IdentifierBlock
124
{
125
        PrioIdentifierBlock():
126
                IdentifierBlock(IdentifierKind::List_Prioritized)
127
        {}
128
        PrioIdentifierBlock(const PrioIdentifierBlock &toCopy):
129
                IdentifierBlock(toCopy)
130
        {}
131

    
132
        static PrioIdentifierBlock* create() {return new PrioIdentifierBlock();}
133
        static PrioIdentifierBlock* createCopy(const PrioIdentifierBlock& toCopy) {return new PrioIdentifierBlock(toCopy);}
134
public:
135
        friend class Ast;
136
        friend class Identifier;
137

    
138
        void accept(IAstVisitor& visitor) override {visitor.visit(this);};
139
};
140
}