summaryrefslogtreecommitdiff
path: root/TAO/CIAO/CCF/CCF/IDL2/IDL2_SemanticAction.hpp
blob: 3fb04f4c8dc1225a5d349256d04aaa16ed35a507 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// $Id$
#ifndef CCF_IDL2_SEMANTIC_ACTION_HPP
#define CCF_IDL2_SEMANTIC_ACTION_HPP

#include "MSVC_Pragmas.hpp"

#include "CCF/CompilerElements/Token.hpp"
#include "CCF/CompilerElements/SemanticAction.hpp"

namespace IDL2
{
  namespace SemanticAction
  {
    using ::SemanticAction::Base;

    class Include : public virtual Base
    {
    public:
      virtual
      ~Include () throw () {}

      virtual void
      begin (StringLiteralPtr const& sl) = 0;

      virtual void
      end () = 0;
    };

    class Scope : public virtual Base
    {
    public:
      virtual
      ~Scope () throw () {}

      virtual void
      open_scope () = 0;

      virtual void
      close_scope () = 0;
    };

    class Module : public virtual Scope
    {
    public:
      virtual
      ~Module () throw () {}

      virtual void
      begin (SimpleIdentifierPtr const& id) = 0;

      virtual void
      end () = 0;
    };

    class Interface : public virtual Scope
    {
    public:
      virtual
      ~Interface () throw () {}

      struct Qualifier
      {
        enum Value
        {
          LOCAL,
          ABSTRACT,
          UNCONSTRAINED,
        };

        friend std::ostream&
        operator<< (std::ostream& o, Value d)
        {
          if (d == LOCAL) o << "local";
          else if (d == ABSTRACT) o << "abstract";
          else o << "unconstrained";
          return o;
        }
      };

      virtual void
      begin (Qualifier::Value qualifier, SimpleIdentifierPtr const& id) = 0;

      virtual void
      inherits (IdentifierPtr const& id) = 0;

      virtual void
      end () = 0;
    };

    class Attribute
    {
    public:
      virtual
      ~Attribute () throw () {}

      virtual void
      type (IdentifierPtr const& id) = 0;

      virtual void
      name (SimpleIdentifierPtr const& id) = 0;
    };

    class Operation
    {
    public:

      virtual void
      begin (IdentifierPtr const& type_id,
             SimpleIdentifierPtr const& name_id) = 0;

      struct Direction
      {
        enum Value
        {
          IN,
          OUT,
          INOUT
        };

        friend std::ostream&
        operator<< (std::ostream& o, Value d)
        {
          if (d == IN) o << "in";
          else if (d == OUT) o << "out";
          else o << "inout";
          return o;
        }
      };

      virtual void
      parameter (Direction::Value direction,
                 IdentifierPtr const& type_id,
                 SimpleIdentifierPtr const& name_id) = 0;

      virtual void
      end () = 0;
    };
  }

  class SemanticActionFactory
  {
  public:
    virtual
    ~SemanticActionFactory () throw () {}

    virtual SemanticAction::Include&
    include () = 0;

    virtual SemanticAction::Module&
    module () = 0;

    virtual SemanticAction::Interface&
    interface () = 0;

    virtual SemanticAction::Attribute&
    attribute () = 0;

    virtual SemanticAction::Operation&
    operation () = 0;
  };
}

#endif // CCF_IDL2_SEMANTIC_ACTION_HPP